dietrb 0.4.7 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +11 -5
- data/Rakefile +13 -9
- data/TODO +1 -0
- data/bin/dietrb +49 -35
- data/dietrb.gemspec +21 -11
- data/lib/irb.rb +0 -3
- data/lib/irb/completion.rb +1 -1
- data/lib/irb/context.rb +21 -58
- data/lib/irb/driver.rb +61 -0
- data/lib/irb/driver/readline.rb +26 -0
- data/lib/irb/driver/socket.rb +44 -0
- data/lib/irb/driver/tty.rb +58 -0
- data/lib/irb/ext/completion.rb +13 -12
- data/lib/irb/ext/history.rb +53 -58
- data/lib/irb/formatter.rb +3 -1
- data/lib/irb/version.rb +2 -2
- data/spec/context_spec.rb +29 -107
- data/spec/driver/readline_spec.rb +70 -0
- data/spec/driver/tty_spec.rb +70 -0
- data/spec/driver_spec.rb +65 -0
- data/spec/{colorize_spec.rb → ext/colorize_spec.rb} +1 -1
- data/spec/{completion_spec.rb → ext/completion_spec.rb} +12 -8
- data/spec/{history_spec.rb → ext/history_spec.rb} +42 -45
- data/spec/formatter_spec.rb +5 -3
- data/spec/regression/context_spec.rb +1 -1
- data/spec/source_spec.rb +25 -29
- data/spec/spec_helper.rb +69 -5
- metadata +21 -24
@@ -11,6 +11,6 @@ describe "IRB::Context, when evaluating source" do
|
|
11
11
|
|
12
12
|
it "does not assign the result to the `_' variable in one go, so it doesn't show up in a syntax error" do
|
13
13
|
@context.evaluate("'banana;")
|
14
|
-
@context.printed.
|
14
|
+
@context.printed.should_not include("_ = ('banana;)")
|
15
15
|
end
|
16
16
|
end
|
data/spec/source_spec.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
require File.expand_path('../spec_helper', __FILE__)
|
2
2
|
|
3
|
-
class Should
|
4
|
-
alias have be
|
5
|
-
end
|
6
|
-
|
7
3
|
describe "IRB::Source" do
|
8
4
|
before do
|
9
5
|
@source = IRB::Source.new
|
@@ -51,7 +47,7 @@ describe "IRB::Source" do
|
|
51
47
|
["def foo", "p :ok", "end"],
|
52
48
|
["class A; def", "foo(x); p x", "end; end"]
|
53
49
|
].each do |buffer|
|
54
|
-
IRB::Source.new(buffer).should
|
50
|
+
IRB::Source.new(buffer).code_block?.should == true
|
55
51
|
end
|
56
52
|
end
|
57
53
|
|
@@ -60,16 +56,16 @@ describe "IRB::Source" do
|
|
60
56
|
["def foo", "p :ok"],
|
61
57
|
["class A; def", "foo(x); p x", "end"]
|
62
58
|
].each do |buffer|
|
63
|
-
IRB::Source.new(buffer).should
|
59
|
+
IRB::Source.new(buffer).code_block?.should == false
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
63
|
it "returns whether or not the accumulated source contains a syntax error" do
|
68
|
-
@source.should
|
64
|
+
@source.syntax_error?.should == false
|
69
65
|
@source << "def foo"
|
70
|
-
@source.should
|
66
|
+
@source.syntax_error?.should == false
|
71
67
|
@source << " def;"
|
72
|
-
@source.should
|
68
|
+
@source.syntax_error?.should == true
|
73
69
|
end
|
74
70
|
|
75
71
|
it "returns the current code block indentation level" do
|
@@ -102,7 +98,7 @@ describe "IRB::Source" do
|
|
102
98
|
@source << "end"
|
103
99
|
@source.level
|
104
100
|
new_reflection = @source.reflect
|
105
|
-
new_reflection.
|
101
|
+
new_reflection.should_not == reflection
|
106
102
|
@source.code_block?
|
107
103
|
@source.reflect.should == new_reflection
|
108
104
|
|
@@ -111,7 +107,7 @@ describe "IRB::Source" do
|
|
111
107
|
@source.pop
|
112
108
|
@source.level
|
113
109
|
new_reflection = @source.reflect
|
114
|
-
new_reflection.
|
110
|
+
new_reflection.should_not == reflection
|
115
111
|
@source.syntax_error?
|
116
112
|
@source.reflect.should == new_reflection
|
117
113
|
end
|
@@ -123,32 +119,32 @@ describe "IRB::Source::Reflector" do
|
|
123
119
|
end
|
124
120
|
|
125
121
|
it "returns whether or not the source is a valid code block" do
|
126
|
-
reflect("def foo").should
|
127
|
-
reflect("def foo; p :ok").should
|
128
|
-
reflect("def foo; p :ok; end").should
|
122
|
+
reflect("def foo").code_block?.should == false
|
123
|
+
reflect("def foo; p :ok").code_block?.should == false
|
124
|
+
reflect("def foo; p :ok; end").code_block?.should == true
|
129
125
|
|
130
|
-
reflect("if true").should
|
131
|
-
reflect("p :ok if true").should
|
126
|
+
reflect("if true").code_block?.should == false
|
127
|
+
reflect("p :ok if true").code_block?.should == true
|
132
128
|
end
|
133
129
|
|
134
130
|
it "returns whether or not the current session should be terminated" do
|
135
|
-
reflect("exit").should
|
136
|
-
reflect("quit").should
|
137
|
-
reflect("def foo; end; exit").should
|
138
|
-
reflect("def foo; end; quit").should
|
131
|
+
reflect("exit").terminate?.should == true
|
132
|
+
reflect("quit").terminate?.should == true
|
133
|
+
reflect("def foo; end; exit").terminate?.should == true
|
134
|
+
reflect("def foo; end; quit").terminate?.should == true
|
139
135
|
|
140
|
-
reflect("def foo; exit; end").should
|
141
|
-
reflect("def foo; quit; end").should
|
136
|
+
reflect("def foo; exit; end").terminate?.should == false
|
137
|
+
reflect("def foo; quit; end").terminate?.should == false
|
142
138
|
end
|
143
139
|
|
144
140
|
it "returns whether or not the source contains a syntax error, except a code block not ending" do
|
145
|
-
reflect("def;").should
|
146
|
-
reflect("def;").should
|
147
|
-
reflect("def foo").should
|
148
|
-
reflect("class A; }").should
|
149
|
-
reflect("class A; {" ).should
|
150
|
-
reflect("class A def foo").should
|
151
|
-
reflect("class A; def foo" ).should
|
141
|
+
reflect("def;").syntax_error?.should == true
|
142
|
+
reflect("def;").syntax_error?.should == true
|
143
|
+
reflect("def foo").syntax_error?.should == false
|
144
|
+
reflect("class A; }").syntax_error?.should == true
|
145
|
+
reflect("class A; {" ).syntax_error?.should == false
|
146
|
+
reflect("class A def foo").syntax_error?.should == true
|
147
|
+
reflect("class A; def foo" ).syntax_error?.should == false
|
152
148
|
end
|
153
149
|
|
154
150
|
it "returns the actual syntax error message if one occurs" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,75 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
1
|
+
unless defined?(MSpec)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'mspec'
|
4
|
+
end
|
5
5
|
|
6
6
|
ENV['SPECCING'] = 'true'
|
7
7
|
|
8
|
-
|
8
|
+
root = File.expand_path('../../', __FILE__)
|
9
|
+
if File.basename(root) == 'spec'
|
10
|
+
# running from the MacRuby repo
|
11
|
+
ROOT = File.expand_path('../../../', __FILE__)
|
12
|
+
else
|
13
|
+
ROOT = root
|
14
|
+
end
|
9
15
|
$:.unshift File.join(ROOT, 'lib')
|
10
16
|
|
11
17
|
require 'irb'
|
18
|
+
|
19
|
+
module InputStubMixin
|
20
|
+
def stub_input(*input)
|
21
|
+
@input = input
|
22
|
+
end
|
23
|
+
|
24
|
+
def readline(prompt)
|
25
|
+
# print prompt
|
26
|
+
@input.shift
|
27
|
+
end
|
28
|
+
|
29
|
+
def gets
|
30
|
+
@input.shift
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class InputStub
|
35
|
+
include InputStubMixin
|
36
|
+
end
|
37
|
+
|
38
|
+
module OutputStubMixin
|
39
|
+
def printed
|
40
|
+
@printed ||= ''
|
41
|
+
end
|
42
|
+
|
43
|
+
def write(string)
|
44
|
+
printed << string
|
45
|
+
end
|
46
|
+
|
47
|
+
def print(string)
|
48
|
+
printed << string
|
49
|
+
end
|
50
|
+
|
51
|
+
def puts(*args)
|
52
|
+
print "#{args.join("\n")}\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
def clear_printed!
|
56
|
+
@printed = ''
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class OutputStub
|
61
|
+
include OutputStubMixin
|
62
|
+
end
|
63
|
+
|
64
|
+
class StubDriver
|
65
|
+
attr_reader :context
|
66
|
+
attr_writer :output
|
67
|
+
|
68
|
+
def initialize(context = nil)
|
69
|
+
@context = context
|
70
|
+
end
|
71
|
+
|
72
|
+
def output
|
73
|
+
@output || $stdout
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dietrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 7
|
10
|
-
version: 0.4.7
|
4
|
+
version: 0.5.0
|
11
5
|
platform: ruby
|
12
6
|
authors:
|
13
7
|
- Eloy Duran
|
@@ -15,7 +9,7 @@ autorequire:
|
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
11
|
|
18
|
-
date: 2010-07-
|
12
|
+
date: 2010-07-24 00:00:00 +02:00
|
19
13
|
default_executable: dietrb
|
20
14
|
dependencies: []
|
21
15
|
|
@@ -40,6 +34,10 @@ files:
|
|
40
34
|
- lib/irb/completion.rb
|
41
35
|
- lib/irb/context.rb
|
42
36
|
- lib/irb/deprecated.rb
|
37
|
+
- lib/irb/driver.rb
|
38
|
+
- lib/irb/driver/readline.rb
|
39
|
+
- lib/irb/driver/socket.rb
|
40
|
+
- lib/irb/driver/tty.rb
|
43
41
|
- lib/irb/ext/colorize.rb
|
44
42
|
- lib/irb/ext/completion.rb
|
45
43
|
- lib/irb/ext/history.rb
|
@@ -47,11 +45,14 @@ files:
|
|
47
45
|
- lib/irb/formatter.rb
|
48
46
|
- lib/irb/source.rb
|
49
47
|
- lib/irb/version.rb
|
50
|
-
- spec/colorize_spec.rb
|
51
|
-
- spec/completion_spec.rb
|
52
48
|
- spec/context_spec.rb
|
49
|
+
- spec/driver/readline_spec.rb
|
50
|
+
- spec/driver/tty_spec.rb
|
51
|
+
- spec/driver_spec.rb
|
52
|
+
- spec/ext/colorize_spec.rb
|
53
|
+
- spec/ext/completion_spec.rb
|
54
|
+
- spec/ext/history_spec.rb
|
53
55
|
- spec/formatter_spec.rb
|
54
|
-
- spec/history_spec.rb
|
55
56
|
- spec/regression/context_spec.rb
|
56
57
|
- spec/source_spec.rb
|
57
58
|
- spec/spec_helper.rb
|
@@ -65,37 +66,33 @@ rdoc_options:
|
|
65
66
|
require_paths:
|
66
67
|
- lib
|
67
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
69
|
requirements:
|
70
70
|
- - ~>
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
hash: 29
|
73
|
-
segments:
|
74
|
-
- 1
|
75
|
-
- 9
|
76
72
|
version: "1.9"
|
73
|
+
version:
|
77
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
75
|
requirements:
|
80
76
|
- - ">="
|
81
77
|
- !ruby/object:Gem::Version
|
82
|
-
hash: 3
|
83
|
-
segments:
|
84
|
-
- 0
|
85
78
|
version: "0"
|
79
|
+
version:
|
86
80
|
requirements: []
|
87
81
|
|
88
82
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.3.
|
83
|
+
rubygems_version: 1.3.5
|
90
84
|
signing_key:
|
91
85
|
specification_version: 3
|
92
86
|
summary: IRB on a diet, for MacRuby / Ruby 1.9
|
93
87
|
test_files:
|
94
|
-
- spec/colorize_spec.rb
|
95
|
-
- spec/completion_spec.rb
|
96
88
|
- spec/context_spec.rb
|
89
|
+
- spec/driver/readline_spec.rb
|
90
|
+
- spec/driver/tty_spec.rb
|
91
|
+
- spec/driver_spec.rb
|
92
|
+
- spec/ext/colorize_spec.rb
|
93
|
+
- spec/ext/completion_spec.rb
|
94
|
+
- spec/ext/history_spec.rb
|
97
95
|
- spec/formatter_spec.rb
|
98
|
-
- spec/history_spec.rb
|
99
96
|
- spec/regression/context_spec.rb
|
100
97
|
- spec/source_spec.rb
|
101
98
|
- spec/spec_helper.rb
|