dietrb 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/dietrb +17 -1
- data/dietrb.gemspec +1 -1
- data/lib/irb/context.rb +2 -2
- data/lib/irb/ext/completion.rb +5 -5
- data/lib/irb.rb +2 -2
- data/spec/context_spec.rb +7 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/bin/dietrb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
unless ARGV.empty?
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
OptionParser.new do |opt|
|
7
|
+
bin = File.basename($0)
|
8
|
+
opt.banner = "Usage: #{bin} [options] [programfile] [arguments]"
|
9
|
+
opt.on("-r load-lib", "Loads the given library (same as `ruby -r')") { |lib| require lib }
|
10
|
+
opt.on("-d", "Set $DEBUG to true (same as `ruby -d')") { $DEBUG = true }
|
11
|
+
opt.on("-I path", "Add path to $LOAD_PATH") { |path| $LOAD_PATH.unshift(path) }
|
12
|
+
opt.on("-v", "--version", "Print the version of #{bin}") do
|
13
|
+
puts File.read(File.expand_path('../../VERSION', __FILE__))
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
end.parse!(ARGV)
|
17
|
+
end
|
18
|
+
|
3
19
|
require 'irb'
|
4
|
-
irb(self)
|
20
|
+
irb(self, TOPLEVEL_BINDING)
|
data/dietrb.gemspec
CHANGED
data/lib/irb/context.rb
CHANGED
@@ -15,9 +15,9 @@ module IRB
|
|
15
15
|
|
16
16
|
attr_reader :object, :binding, :line, :source
|
17
17
|
|
18
|
-
def initialize(object)
|
18
|
+
def initialize(object, explicit_binding = nil)
|
19
19
|
@object = object
|
20
|
-
@binding = object.instance_eval { binding }
|
20
|
+
@binding = explicit_binding || object.instance_eval { binding }
|
21
21
|
@line = 1
|
22
22
|
clear_buffer
|
23
23
|
end
|
data/lib/irb/ext/completion.rb
CHANGED
@@ -108,15 +108,15 @@ module IRB
|
|
108
108
|
end.instance_methods
|
109
109
|
end
|
110
110
|
|
111
|
-
def methods_of_object_in_variable(
|
112
|
-
|
111
|
+
def methods_of_object_in_variable(path)
|
112
|
+
type, name = path[VALUE][0..1]
|
113
113
|
|
114
|
-
if
|
115
|
-
if
|
114
|
+
if path[TYPE] == :top_const_ref
|
115
|
+
if type == :@const && Object.constants.include?(name.to_sym)
|
116
116
|
evaluate("::#{name}").methods
|
117
117
|
end
|
118
118
|
else
|
119
|
-
case
|
119
|
+
case type
|
120
120
|
when :@ident
|
121
121
|
evaluate(name).methods if local_variables.include?(name)
|
122
122
|
when :@gvar
|
data/lib/irb.rb
CHANGED
data/spec/context_spec.rb
CHANGED
@@ -29,6 +29,12 @@ describe "IRB::Context" do
|
|
29
29
|
eval("y", @context.binding).should == :ok
|
30
30
|
end
|
31
31
|
|
32
|
+
it "initializes with an object and an explicit binding" do
|
33
|
+
context = IRB::Context.new(Object.new, TOPLEVEL_BINDING)
|
34
|
+
eval("class InTopLevel; end", context.binding)
|
35
|
+
lambda { ::InTopLevel }.should.not.raise NameError
|
36
|
+
end
|
37
|
+
|
32
38
|
it "initializes with an 'empty' state" do
|
33
39
|
@context.line.should == 1
|
34
40
|
@context.source.should.be.instance_of IRB::Source
|
@@ -108,7 +114,7 @@ describe "IRB::Context, when evaluating source" do
|
|
108
114
|
it "prints the exception that occurs" do
|
109
115
|
@context.evaluate("DoesNotExist")
|
110
116
|
printed = @context.instance_variable_get(:@printed)
|
111
|
-
printed.should.match /^NameError
|
117
|
+
printed.should.match /^NameError:.+DoesNotExist/
|
112
118
|
end
|
113
119
|
end
|
114
120
|
|