[macruby-changes] [4180] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jun 1 02:11:38 PDT 2010
Revision: 4180
http://trac.macosforge.org/projects/ruby/changeset/4180
Author: eloy.de.enige at gmail.com
Date: 2010-06-01 02:11:36 -0700 (Tue, 01 Jun 2010)
Log Message:
-----------
Updated IRB to DietRB 0.4.5
Modified Paths:
--------------
MacRuby/trunk/bin/irb
MacRuby/trunk/lib/irb/context.rb
MacRuby/trunk/lib/irb/source.rb
MacRuby/trunk/lib/irb/version.rb
MacRuby/trunk/lib/irb.rb
Added Paths:
-----------
MacRuby/trunk/lib/irb/completion.rb
MacRuby/trunk/lib/irb/deprecated.rb
Modified: MacRuby/trunk/bin/irb
===================================================================
--- MacRuby/trunk/bin/irb 2010-06-01 08:35:09 UTC (rev 4179)
+++ MacRuby/trunk/bin/irb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -5,9 +5,12 @@
unless ARGV.empty?
require 'optparse'
+ ignore_irbrc = false
+
OptionParser.new do |opt|
bin = File.basename($0)
opt.banner = "Usage: #{bin} [options] [programfile] [arguments]"
+ opt.on("-f", "Ignore ~/.irbrc") { |ignore| ignore_irbrc = ignore }
opt.on("-r load-lib", "Loads the given library (same as `ruby -r')") { |lib| require lib }
opt.on("-d", "Set $DEBUG to true (same as `ruby -d')") { $DEBUG = true }
opt.on("-I path", "Add path to $LOAD_PATH") { |path| $LOAD_PATH.unshift(path) }
@@ -20,8 +23,10 @@
end.parse!(ARGV)
end
-irbrc = File.expand_path("~/.irbrc")
-load(irbrc) if File.exist?(irbrc)
+unless ignore_irbrc
+ irbrc = File.expand_path("~/.irbrc")
+ load(irbrc) if File.exist?(irbrc)
+end
IRB.formatter.filter_from_backtrace << /^#{__FILE__}/
Added: MacRuby/trunk/lib/irb/completion.rb
===================================================================
--- MacRuby/trunk/lib/irb/completion.rb (rev 0)
+++ MacRuby/trunk/lib/irb/completion.rb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -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
Modified: MacRuby/trunk/lib/irb/context.rb
===================================================================
--- MacRuby/trunk/lib/irb/context.rb 2010-06-01 08:35:09 UTC (rev 4179)
+++ MacRuby/trunk/lib/irb/context.rb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -34,6 +34,7 @@
@line = 1
clear_buffer
+ @underscore_assigner = __evaluate__("_ = nil; proc { |val| _ = val }")
@processors = self.class.processors.map { |processor| processor.new(self) }
end
@@ -42,10 +43,12 @@
end
def evaluate(source)
- result = __evaluate__("_ = (#{source})", '(irb)', @line - @source.buffer.size + 1)
+ result = __evaluate__(source.to_s, '(irb)', @line - @source.buffer.size + 1)
+ store_result(result)
puts formatter.result(result)
result
rescue Exception => e
+ store_exception(e)
puts formatter.exception(e)
end
@@ -82,7 +85,7 @@
# process_line("quit") # => false
def process_line(line)
@source << line
- return false if @source.to_s == "quit"
+ return false if @source.terminate?
if @source.syntax_error?
puts formatter.syntax_error(@line, @source.syntax_error)
@@ -108,6 +111,14 @@
def clear_buffer
@source = Source.new
end
+
+ def store_result(result)
+ @underscore_assigner.call(result)
+ end
+
+ def store_exception(exception)
+ $e = $EXCEPTION = exception
+ end
end
end
@@ -118,4 +129,4 @@
end
private :irb
-end
\ No newline at end of file
+end
Added: MacRuby/trunk/lib/irb/deprecated.rb
===================================================================
--- MacRuby/trunk/lib/irb/deprecated.rb (rev 0)
+++ MacRuby/trunk/lib/irb/deprecated.rb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -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: MacRuby/trunk/lib/irb/source.rb
===================================================================
--- MacRuby/trunk/lib/irb/source.rb 2010-06-01 08:35:09 UTC (rev 4179)
+++ MacRuby/trunk/lib/irb/source.rb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -51,6 +51,11 @@
def syntax_error?
reflect.syntax_error?
end
+
+ # Reflects on the accumulated source to see if it contains a terminate signal.
+ def terminate?
+ reflect.terminate?
+ end
# Reflects on the accumulated source and returns the actual syntax error
# message if one occurs.
@@ -110,6 +115,20 @@
def syntax_error?
!@syntax_error.nil?
end
+
+ # Returns whether or not the source contains a call to toplevel
+ # quit or exit, namely if the current session should be terminated
+ #
+ # For example, this would terminate the session
+ #
+ # def foo; end; quit
+ #
+ # This does not:
+ #
+ # def foo; quit; end
+ def terminate?
+ !@terminate.nil?
+ end
UNEXPECTED_END = "syntax error, unexpected $end"
@@ -120,6 +139,7 @@
end
INCREASE_LEVEL_KEYWORDS = %w{ class module def begin if unless case while for do }
+ TERMINATE_KEYWORDS = %w{ exit quit }
def on_kw(token) #:nodoc:
case token
@@ -145,6 +165,14 @@
@level += 1
super
end
+
+ def on_ident(token) #:nodoc:
+ if @level == 0 && TERMINATE_KEYWORDS.include?(token)
+ @terminate = true
+ else
+ super
+ end
+ end
def on_lbrace(token) #:nodoc:
@level += 1
@@ -157,4 +185,4 @@
end
end
end
-end
\ No newline at end of file
+end
Modified: MacRuby/trunk/lib/irb/version.rb
===================================================================
--- MacRuby/trunk/lib/irb/version.rb 2010-06-01 08:35:09 UTC (rev 4179)
+++ MacRuby/trunk/lib/irb/version.rb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -8,7 +8,7 @@
module VERSION #:nodoc:
MAJOR = 0
MINOR = 4
- TINY = 2
+ TINY = 5
STRING = [MAJOR, MINOR, TINY].join('.')
DESCRIPTION = "#{STRING} (DietRB)"
Modified: MacRuby/trunk/lib/irb.rb
===================================================================
--- MacRuby/trunk/lib/irb.rb 2010-06-01 08:35:09 UTC (rev 4179)
+++ MacRuby/trunk/lib/irb.rb 2010-06-01 09:11:36 UTC (rev 4180)
@@ -8,8 +8,25 @@
require 'irb/source'
require 'irb/version'
+require 'irb/deprecated'
+
require 'irb/ext/history'
+require 'irb/ext/completion'
-# if !ENV['SPECCING'] && defined?(RUBY_ENGINE) && RUBY_ENGINE == "macruby"
-# require 'irb/ext/macruby'
-# end
+if !ENV['SPECCING'] && defined?(RUBY_ENGINE) && RUBY_ENGINE == "macruby"
+ require 'irb/ext/macruby'
+end
+
+module IRB
+ class << self
+ # This is just here for so the ruby 1.9 IRB will seemingly work, but actually
+ # loads DietRB, how cunning...
+ #
+ # This will obviously be removed once we've conquered the world.
+ def start(*)
+ warn "[!] Note that you are now actually using DietRB (#{IRB::VERSION::STRING})\n"
+ load File.expand_path('../../bin/dietrb', __FILE__)
+ end
+ alias_method :setup, :start
+ end
+end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100601/42430e60/attachment-0001.html>
More information about the macruby-changes
mailing list