rib 0.1.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -4
- data/CHANGES.md +6 -0
- data/README +107 -113
- data/README.md +107 -113
- data/Rakefile +5 -3
- data/TODO.md +6 -0
- data/bin/rib-all +5 -0
- data/bin/rib-auto +9 -0
- data/bin/rib-min +5 -0
- data/bin/rib-rails +9 -0
- data/bin/rib-ramaze +9 -0
- data/lib/rib.rb +70 -6
- data/lib/rib/all.rb +0 -1
- data/lib/rib/api.rb +60 -64
- data/lib/rib/app/auto.rb +25 -0
- data/lib/rib/app/rails.rb +41 -0
- data/lib/rib/app/ramaze.rb +25 -0
- data/lib/rib/config.rb +3 -0
- data/lib/rib/core.rb +13 -1
- data/lib/rib/core/completion.rb +15 -3
- data/lib/rib/core/history.rb +56 -0
- data/lib/rib/core/multiline.rb +104 -0
- data/lib/rib/core/readline.rb +3 -1
- data/lib/rib/core/squeeze_history.rb +45 -0
- data/lib/rib/core/strip_backtrace.rb +45 -0
- data/lib/rib/core/underscore.rb +17 -8
- data/lib/rib/debug.rb +2 -1
- data/lib/rib/dep/hirb.rb +24 -0
- data/lib/rib/more.rb +4 -3
- data/lib/rib/more/anchor.rb +85 -0
- data/lib/rib/more/color.rb +44 -43
- data/lib/rib/{zore → more}/edit.rb +3 -3
- data/lib/rib/more/multiline_history.rb +24 -12
- data/lib/rib/more/multiline_history_file.rb +7 -3
- data/lib/rib/plugin.rb +2 -4
- data/lib/rib/runner.rb +84 -49
- data/lib/rib/shell.rb +4 -2
- data/lib/rib/test.rb +55 -2
- data/lib/rib/test/multiline.rb +140 -0
- data/lib/rib/version.rb +1 -1
- data/rib.gemspec +54 -22
- data/screenshot.png +0 -0
- data/task/gemgem.rb +3 -1
- data/test/core/{test_history_file.rb → test_history.rb} +29 -19
- data/test/core/test_multiline.rb +22 -0
- data/test/core/test_readline.rb +13 -8
- data/test/{more → core}/test_squeeze_history.rb +24 -18
- data/test/core/test_underscore.rb +32 -21
- data/test/more/test_multiline_history.rb +42 -0
- data/test/test_shell.rb +13 -8
- metadata +72 -27
- data/2011-02-28.md +0 -203
- data/CHANGES +0 -86
- data/TODO +0 -6
- data/lib/rib/core/history_file.rb +0 -38
- data/lib/rib/more/multiline.rb +0 -77
- data/lib/rib/more/squeeze_history.rb +0 -37
- data/lib/rib/more/strip_backtrace.rb +0 -43
- data/lib/rib/zore.rb +0 -3
- data/lib/rib/zore/anchor.rb +0 -69
data/lib/rib/test.rb
CHANGED
@@ -9,12 +9,65 @@ require 'rib'
|
|
9
9
|
|
10
10
|
shared :rib do
|
11
11
|
before do
|
12
|
-
Rib.disable_plugins
|
13
12
|
end
|
14
13
|
|
15
14
|
after do
|
16
15
|
RR.verify
|
17
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_for *plugins, &block
|
19
|
+
require 'rib/all' # exhaustive tests
|
20
|
+
rest = Rib.plugins - plugins
|
21
|
+
Rib.enable_plugins(plugins)
|
22
|
+
Rib.disable_plugins(rest)
|
23
|
+
yield
|
24
|
+
|
25
|
+
case ENV['TEST_LEVEL']
|
26
|
+
when '0'
|
27
|
+
when '1'
|
28
|
+
test_level1(rest, block)
|
29
|
+
when '2'
|
30
|
+
test_level2(rest, block)
|
31
|
+
when '3'
|
32
|
+
test_level3(rest, block)
|
33
|
+
else # test_level3 is too slow because of rr (i guess)
|
34
|
+
test_level2(rest, block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_level1 rest, block
|
39
|
+
rest.each{ |target|
|
40
|
+
target.enable
|
41
|
+
block.call
|
42
|
+
target.disable
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_level2 rest, block
|
47
|
+
rest.combination(2).each{ |targets|
|
48
|
+
Rib.enable_plugins(targets)
|
49
|
+
block.call
|
50
|
+
Rib.disable_plugins(targets)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_level3 rest, block
|
55
|
+
return block.call if rest.empty?
|
56
|
+
rest[0].enable
|
57
|
+
test_level3(rest[1..-1], block)
|
58
|
+
rest[0].disable
|
59
|
+
test_level3(rest[1..-1], block)
|
60
|
+
end
|
61
|
+
|
62
|
+
def readline?
|
63
|
+
Rib.constants.map(&:to_s).include?('Readline') &&
|
64
|
+
Rib::Readline.enabled?
|
65
|
+
end
|
66
|
+
|
67
|
+
def stub_readline
|
68
|
+
stub(::Readline).readline(is_a(String), true){
|
69
|
+
(::Readline::HISTORY << str.chomp)[-1]
|
70
|
+
}
|
18
71
|
end
|
19
72
|
end
|
20
73
|
|
@@ -0,0 +1,140 @@
|
|
1
|
+
|
2
|
+
shared :setup_multiline do
|
3
|
+
def setup_shell
|
4
|
+
@shell = Rib::Shell.new(
|
5
|
+
:binding => Object.new.instance_eval{binding}).before_loop
|
6
|
+
stub(@shell).print
|
7
|
+
stub(@shell).puts
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup_input str
|
11
|
+
if readline?
|
12
|
+
mock(::Readline).readline(is_a(String), true){
|
13
|
+
(::Readline::HISTORY << str.chomp)[-1]
|
14
|
+
}
|
15
|
+
else
|
16
|
+
mock($stdin).gets{ str.chomp }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def input str
|
21
|
+
setup_input(str)
|
22
|
+
mock.proxy(@shell).throw(:rib_multiline)
|
23
|
+
end
|
24
|
+
|
25
|
+
def input_done str, err=nil
|
26
|
+
setup_input(str)
|
27
|
+
if err
|
28
|
+
mock(@shell).print_eval_error(is_a(err))
|
29
|
+
else
|
30
|
+
mock(@shell).print_result(is_a(Object))
|
31
|
+
end
|
32
|
+
@shell.loop_once
|
33
|
+
true.should.eq true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
shared :multiline do
|
38
|
+
before do
|
39
|
+
setup_shell
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'def f' do
|
43
|
+
check <<-RUBY
|
44
|
+
def f
|
45
|
+
1
|
46
|
+
end
|
47
|
+
RUBY
|
48
|
+
end
|
49
|
+
|
50
|
+
should 'class C' do
|
51
|
+
check <<-RUBY
|
52
|
+
class C
|
53
|
+
end
|
54
|
+
RUBY
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'begin' do
|
58
|
+
check <<-RUBY
|
59
|
+
begin
|
60
|
+
end
|
61
|
+
RUBY
|
62
|
+
end
|
63
|
+
|
64
|
+
should 'begin with RuntimeError' do
|
65
|
+
check <<-RUBY, RuntimeError
|
66
|
+
begin
|
67
|
+
raise 'multiline raised an error'
|
68
|
+
end
|
69
|
+
RUBY
|
70
|
+
end
|
71
|
+
|
72
|
+
should 'do end' do
|
73
|
+
check <<-RUBY
|
74
|
+
[].each do
|
75
|
+
end
|
76
|
+
RUBY
|
77
|
+
end
|
78
|
+
|
79
|
+
should 'block brace' do
|
80
|
+
check <<-RUBY
|
81
|
+
[].each{
|
82
|
+
}
|
83
|
+
RUBY
|
84
|
+
end
|
85
|
+
|
86
|
+
should 'hash' do
|
87
|
+
check <<-RUBY
|
88
|
+
{
|
89
|
+
}
|
90
|
+
RUBY
|
91
|
+
end
|
92
|
+
|
93
|
+
should 'hash value' do
|
94
|
+
check <<-RUBY
|
95
|
+
{1 =>
|
96
|
+
2}
|
97
|
+
RUBY
|
98
|
+
end
|
99
|
+
|
100
|
+
should 'array' do
|
101
|
+
check <<-RUBY
|
102
|
+
[
|
103
|
+
]
|
104
|
+
RUBY
|
105
|
+
end
|
106
|
+
|
107
|
+
should 'group' do
|
108
|
+
check <<-RUBY
|
109
|
+
(
|
110
|
+
)
|
111
|
+
RUBY
|
112
|
+
end
|
113
|
+
|
114
|
+
should 'string double quote' do
|
115
|
+
check <<-RUBY
|
116
|
+
"
|
117
|
+
"
|
118
|
+
RUBY
|
119
|
+
end
|
120
|
+
|
121
|
+
should 'string single quote' do
|
122
|
+
check <<-RUBY
|
123
|
+
'
|
124
|
+
'
|
125
|
+
RUBY
|
126
|
+
end
|
127
|
+
|
128
|
+
should 'be hash treated as a block SyntaxError' do
|
129
|
+
check <<-RUBY, SyntaxError
|
130
|
+
puts { :x => 10 }.class
|
131
|
+
RUBY
|
132
|
+
end
|
133
|
+
|
134
|
+
should 'begin with SyntaxError' do
|
135
|
+
check <<-RUBY, SyntaxError
|
136
|
+
begin
|
137
|
+
s-y n
|
138
|
+
RUBY
|
139
|
+
end
|
140
|
+
end
|
data/lib/rib/version.rb
CHANGED
data/rib.gemspec
CHANGED
@@ -2,67 +2,94 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rib}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.9.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [%q{Lin Jen-Shin (godfat)}]
|
9
|
-
s.date = %q{2011-08-
|
10
|
-
s.description = %q{
|
9
|
+
s.date = %q{2011-08-14}
|
10
|
+
s.description = %q{Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
|
11
|
+
|
12
|
+
Rib is based on the design of [ripl][] and the work of [ripl-rc][], some of
|
13
|
+
the features are also inspired by [pry][]. The aim of Rib is to be fully
|
14
|
+
featured and yet very easy to opt-out or opt-in other features. It shall
|
15
|
+
be simple, lightweight and modular so that everyone could customize Rib.
|
16
|
+
|
17
|
+
[ripl]: https://github.com/cldwalker/ripl
|
18
|
+
[ripl-rc]: https://github.com/godfat/ripl-rc
|
19
|
+
[pry]: https://github.com/pry/pry}
|
11
20
|
s.email = [%q{godfat (XD) godfat.org}]
|
12
|
-
s.executables = [
|
21
|
+
s.executables = [
|
22
|
+
%q{rib},
|
23
|
+
%q{rib-all},
|
24
|
+
%q{rib-auto},
|
25
|
+
%q{rib-min},
|
26
|
+
%q{rib-rails},
|
27
|
+
%q{rib-ramaze}]
|
13
28
|
s.extra_rdoc_files = [
|
14
|
-
%q{CHANGES},
|
15
29
|
%q{CONTRIBUTORS},
|
16
30
|
%q{LICENSE},
|
17
|
-
%q{
|
31
|
+
%q{CHANGES.md},
|
32
|
+
%q{TODO.md},
|
33
|
+
%q{CONTRIBUTORS}]
|
18
34
|
s.files = [
|
19
35
|
%q{.gitignore},
|
20
36
|
%q{.gitmodules},
|
21
37
|
%q{.travis.yml},
|
22
|
-
%q{
|
23
|
-
%q{CHANGES},
|
38
|
+
%q{CHANGES.md},
|
24
39
|
%q{CONTRIBUTORS},
|
25
40
|
%q{Gemfile},
|
26
41
|
%q{LICENSE},
|
27
42
|
%q{README},
|
28
43
|
%q{README.md},
|
29
44
|
%q{Rakefile},
|
30
|
-
%q{TODO},
|
45
|
+
%q{TODO.md},
|
31
46
|
%q{bin/rib},
|
47
|
+
%q{bin/rib-all},
|
48
|
+
%q{bin/rib-auto},
|
49
|
+
%q{bin/rib-min},
|
50
|
+
%q{bin/rib-rails},
|
51
|
+
%q{bin/rib-ramaze},
|
32
52
|
%q{lib/rib.rb},
|
33
53
|
%q{lib/rib/all.rb},
|
34
54
|
%q{lib/rib/api.rb},
|
55
|
+
%q{lib/rib/app/auto.rb},
|
56
|
+
%q{lib/rib/app/rails.rb},
|
57
|
+
%q{lib/rib/app/ramaze.rb},
|
58
|
+
%q{lib/rib/config.rb},
|
35
59
|
%q{lib/rib/core.rb},
|
36
60
|
%q{lib/rib/core/completion.rb},
|
37
|
-
%q{lib/rib/core/
|
61
|
+
%q{lib/rib/core/history.rb},
|
62
|
+
%q{lib/rib/core/multiline.rb},
|
38
63
|
%q{lib/rib/core/readline.rb},
|
64
|
+
%q{lib/rib/core/squeeze_history.rb},
|
65
|
+
%q{lib/rib/core/strip_backtrace.rb},
|
39
66
|
%q{lib/rib/core/underscore.rb},
|
40
67
|
%q{lib/rib/debug.rb},
|
68
|
+
%q{lib/rib/dep/hirb.rb},
|
41
69
|
%q{lib/rib/more.rb},
|
70
|
+
%q{lib/rib/more/anchor.rb},
|
42
71
|
%q{lib/rib/more/color.rb},
|
43
|
-
%q{lib/rib/more/
|
72
|
+
%q{lib/rib/more/edit.rb},
|
44
73
|
%q{lib/rib/more/multiline_history.rb},
|
45
74
|
%q{lib/rib/more/multiline_history_file.rb},
|
46
|
-
%q{lib/rib/more/squeeze_history.rb},
|
47
|
-
%q{lib/rib/more/strip_backtrace.rb},
|
48
75
|
%q{lib/rib/plugin.rb},
|
49
76
|
%q{lib/rib/runner.rb},
|
50
77
|
%q{lib/rib/shell.rb},
|
51
78
|
%q{lib/rib/test.rb},
|
79
|
+
%q{lib/rib/test/multiline.rb},
|
52
80
|
%q{lib/rib/version.rb},
|
53
|
-
%q{lib/rib/zore.rb},
|
54
|
-
%q{lib/rib/zore/anchor.rb},
|
55
|
-
%q{lib/rib/zore/edit.rb},
|
56
81
|
%q{rib.gemspec},
|
57
82
|
%q{screenshot.png},
|
58
83
|
%q{task/.gitignore},
|
59
84
|
%q{task/gemgem.rb},
|
60
85
|
%q{test/core/test_completion.rb},
|
61
|
-
%q{test/core/
|
86
|
+
%q{test/core/test_history.rb},
|
87
|
+
%q{test/core/test_multiline.rb},
|
62
88
|
%q{test/core/test_readline.rb},
|
89
|
+
%q{test/core/test_squeeze_history.rb},
|
63
90
|
%q{test/core/test_underscore.rb},
|
64
91
|
%q{test/more/test_color.rb},
|
65
|
-
%q{test/more/
|
92
|
+
%q{test/more/test_multiline_history.rb},
|
66
93
|
%q{test/test_api.rb},
|
67
94
|
%q{test/test_plugin.rb},
|
68
95
|
%q{test/test_shell.rb}]
|
@@ -72,14 +99,16 @@ Gem::Specification.new do |s|
|
|
72
99
|
%q{README}]
|
73
100
|
s.require_paths = [%q{lib}]
|
74
101
|
s.rubygems_version = %q{1.8.7}
|
75
|
-
s.summary = %q{
|
102
|
+
s.summary = %q{Ruby-Interactive-ruBy -- Yet another interactive Ruby shell}
|
76
103
|
s.test_files = [
|
77
104
|
%q{test/core/test_completion.rb},
|
78
|
-
%q{test/core/
|
105
|
+
%q{test/core/test_history.rb},
|
106
|
+
%q{test/core/test_multiline.rb},
|
79
107
|
%q{test/core/test_readline.rb},
|
108
|
+
%q{test/core/test_squeeze_history.rb},
|
80
109
|
%q{test/core/test_underscore.rb},
|
81
110
|
%q{test/more/test_color.rb},
|
82
|
-
%q{test/more/
|
111
|
+
%q{test/more/test_multiline_history.rb},
|
83
112
|
%q{test/test_api.rb},
|
84
113
|
%q{test/test_plugin.rb},
|
85
114
|
%q{test/test_shell.rb}]
|
@@ -88,16 +117,19 @@ Gem::Specification.new do |s|
|
|
88
117
|
s.specification_version = 3
|
89
118
|
|
90
119
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
91
|
-
s.
|
120
|
+
s.add_development_dependency(%q<bond>, [">= 0"])
|
121
|
+
s.add_development_dependency(%q<hirb>, [">= 0"])
|
92
122
|
s.add_development_dependency(%q<bacon>, [">= 0"])
|
93
123
|
s.add_development_dependency(%q<rr>, [">= 0"])
|
94
124
|
else
|
95
125
|
s.add_dependency(%q<bond>, [">= 0"])
|
126
|
+
s.add_dependency(%q<hirb>, [">= 0"])
|
96
127
|
s.add_dependency(%q<bacon>, [">= 0"])
|
97
128
|
s.add_dependency(%q<rr>, [">= 0"])
|
98
129
|
end
|
99
130
|
else
|
100
131
|
s.add_dependency(%q<bond>, [">= 0"])
|
132
|
+
s.add_dependency(%q<hirb>, [">= 0"])
|
101
133
|
s.add_dependency(%q<bacon>, [">= 0"])
|
102
134
|
s.add_dependency(%q<rr>, [">= 0"])
|
103
135
|
end
|
data/screenshot.png
CHANGED
Binary file
|
data/task/gemgem.rb
CHANGED
@@ -19,13 +19,15 @@ module Gemgem
|
|
19
19
|
s.description = description.join
|
20
20
|
s.summary = description.first
|
21
21
|
|
22
|
-
s.extra_rdoc_files = %w[CHANGES
|
22
|
+
s.extra_rdoc_files = %w[CHANGES TODO CONTRIBUTORS LICENSE
|
23
|
+
CHANGES.md TODO.md CONTRIBUTORS].select{ |f|
|
23
24
|
File.exist?(f) }
|
24
25
|
s.rdoc_options = %w[--main README]
|
25
26
|
s.rubygems_version = Gem::VERSION
|
26
27
|
s.date = Time.now.strftime('%Y-%m-%d')
|
27
28
|
s.files = gem_files
|
28
29
|
s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
30
|
+
s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
|
29
31
|
s.require_paths = %w[lib]
|
30
32
|
})
|
31
33
|
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
@@ -1,29 +1,18 @@
|
|
1
1
|
|
2
2
|
require 'rib/test'
|
3
|
-
require 'rib/core/
|
4
|
-
|
5
|
-
describe Rib::HistoryFile do
|
6
|
-
behaves_like :rib
|
7
|
-
|
8
|
-
before do
|
9
|
-
Rib::HistoryFile.enable
|
10
|
-
@history = "/tmp/test_rib_#{rand}"
|
11
|
-
@shell = Rib::Shell.new(:history_file => @history).before_loop
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
FileUtils.rm_f(@history)
|
16
|
-
end
|
3
|
+
require 'rib/core/history'
|
17
4
|
|
5
|
+
shared :history do
|
18
6
|
should '#after_loop save history' do
|
19
7
|
inputs = %w[blih blah]
|
20
|
-
@shell.history.
|
8
|
+
@shell.history.clear
|
9
|
+
@shell.history.push(*inputs)
|
21
10
|
@shell.after_loop
|
22
|
-
File.read(@
|
11
|
+
File.read(@history_file).should.eq "#{inputs.join("\n")}\n"
|
23
12
|
end
|
24
13
|
|
25
14
|
should '#before_loop load previous history' do
|
26
|
-
File.open(@
|
15
|
+
File.open(@history_file, 'w'){ |f| f.write "check\nthe\nmike" }
|
27
16
|
@shell.before_loop
|
28
17
|
@shell.history.to_a.should.eq %w[check the mike]
|
29
18
|
end
|
@@ -36,7 +25,7 @@ describe Rib::HistoryFile do
|
|
36
25
|
should '#read_history be accessible to plugins in #before_loop' do
|
37
26
|
mod = Module.new do
|
38
27
|
def read_history
|
39
|
-
|
28
|
+
config[:history] = ['pong_read_history']
|
40
29
|
end
|
41
30
|
end
|
42
31
|
shell = Rib::Shell.dup
|
@@ -47,7 +36,7 @@ describe Rib::HistoryFile do
|
|
47
36
|
should '#write_history be accessible to plugins in #after_loop' do
|
48
37
|
mod = Module.new do
|
49
38
|
def write_history
|
50
|
-
|
39
|
+
config[:history] = ['pong_write_history']
|
51
40
|
end
|
52
41
|
end
|
53
42
|
shell = Rib::Shell.dup
|
@@ -55,3 +44,24 @@ describe Rib::HistoryFile do
|
|
55
44
|
shell.new.before_loop.after_loop.history.should.eq ['pong_write_history']
|
56
45
|
end
|
57
46
|
end
|
47
|
+
|
48
|
+
describe Rib::History do
|
49
|
+
behaves_like :rib
|
50
|
+
|
51
|
+
before do
|
52
|
+
if readline?
|
53
|
+
::Readline::HISTORY.clear
|
54
|
+
stub_readline
|
55
|
+
end
|
56
|
+
@history_file = "/tmp/test_rib_#{rand}"
|
57
|
+
@shell = Rib::Shell.new(:history_file => @history_file).before_loop
|
58
|
+
end
|
59
|
+
|
60
|
+
after do
|
61
|
+
FileUtils.rm_f(@history_file)
|
62
|
+
end
|
63
|
+
|
64
|
+
test_for Rib::History do
|
65
|
+
behaves_like :history
|
66
|
+
end
|
67
|
+
end
|