[macruby-changes] [4697] DietRB/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 8 04:01:12 PDT 2010


Revision: 4697
          http://trac.macosforge.org/projects/ruby/changeset/4697
Author:   eloy.de.enige at gmail.com
Date:     2010-10-08 04:01:11 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Add some deprecation warnings to at least not leave people baffled.

From: Eloy Duran <eloy.de.enige at gmail.com>

Modified Paths:
--------------
    DietRB/trunk/TODO
    DietRB/trunk/lib/irb.rb

Added Paths:
-----------
    DietRB/trunk/lib/irb/completion.rb
    DietRB/trunk/lib/irb/deprecated.rb

Modified: DietRB/trunk/TODO
===================================================================
--- DietRB/trunk/TODO	2010-10-08 11:01:02 UTC (rev 4696)
+++ DietRB/trunk/TODO	2010-10-08 11:01:11 UTC (rev 4697)
@@ -1,3 +1,4 @@
+* Configurable history file? (:HISTORY_FILE) Configurable number of saved history lines? (:SAVE_HISTORY)
 * Make sure the following formatters work: hirb, awesome_print, and looksee
 * Make sure the majority of the utils in utility_belt work
 * Possibly add copy-paste support as an ext

Added: DietRB/trunk/lib/irb/completion.rb
===================================================================
--- DietRB/trunk/lib/irb/completion.rb	                        (rev 0)
+++ DietRB/trunk/lib/irb/completion.rb	2010-10-08 11:01:11 UTC (rev 4697)
@@ -0,0 +1 @@
+IRB.deprecated "The file `irb/completion' has moved to `irb/ext/ecompletion' and is loaded by default.", caller
\ No newline at end of file

Added: DietRB/trunk/lib/irb/deprecated.rb
===================================================================
--- DietRB/trunk/lib/irb/deprecated.rb	                        (rev 0)
+++ DietRB/trunk/lib/irb/deprecated.rb	2010-10-08 11:01:11 UTC (rev 4697)
@@ -0,0 +1,43 @@
+module IRB
+  def self.deprecated(message, caller)
+    caller = caller.first.split(':')[0..-2].join(':')
+    warn "[!] Deprecation warning from #{caller}: #{message}"
+  end
+  
+  def self.deprecated_feature(old_feature, new_feature, caller)
+    deprecated "Usage of #{old_feature} will be deprecated, #{new_feature}", caller
+  end
+  
+  def self.conf
+    @conf ||= DeprecatedConf.new
+  end
+  
+  class DeprecatedConf
+    DEFAULT_MESSAGE = "please create a patch/ticket"
+    
+    def deprecated_conf(key, message, caller)
+      message ||= DEFAULT_MESSAGE
+      IRB.deprecated_feature("IRB.conf[:#{key}]", message, caller)
+    end
+    
+    def [](key)
+      IRB.deprecated("Usage of the IRB.conf hash for configuration is, currently, not supported", caller)
+      nil
+    end
+    
+    def []=(key, value)
+      message = nil
+      case key
+      when :PROMPT_MODE
+        message = "use `IRB.formatter.prompt = :#{value.downcase}'"
+        IRB.formatter.prompt = "#{value.to_s.downcase}".to_sym
+      when :USE_READLINE
+        message = "for now DietRB only has a readline module"
+      when :SAVE_HISTORY
+        message = "history is always saved"
+      end
+      deprecated_conf key, message, caller
+      value
+    end
+  end
+end
\ No newline at end of file

Modified: DietRB/trunk/lib/irb.rb
===================================================================
--- DietRB/trunk/lib/irb.rb	2010-10-08 11:01:02 UTC (rev 4696)
+++ DietRB/trunk/lib/irb.rb	2010-10-08 11:01:11 UTC (rev 4697)
@@ -8,6 +8,8 @@
 require 'irb/source'
 require 'irb/version'
 
+require 'irb/deprecated'
+
 require 'irb/ext/history'
 require 'irb/ext/completion'
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/39191309/attachment.html>


More information about the macruby-changes mailing list