rib 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGES.md +9 -0
- data/lib/rib/runner.rb +14 -8
- data/lib/rib/shell.rb +9 -6
- data/lib/rib/test.rb +4 -0
- data/lib/rib/version.rb +1 -1
- data/rib.gemspec +3 -3
- data/test/test_runner.rb +19 -0
- data/test/test_shell.rb +39 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e72a119f6305e6c1e85579ae3e1b22564b6b5b56
|
4
|
+
data.tar.gz: 71f3bedf29f8cf9ae94a3fe9cfcf7317d0ef617c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5733937ed0bbb20cf9372a68e8fb937c1570d9a734e68e5137175237145ccc7f149bf7a3b9fcd5874aa37a3dd3c957a0487567ef6ee9161af88017dce160693
|
7
|
+
data.tar.gz: 31e66ea9bd8c01276b6c8b4a08e3321af27f47ff64f36295f5a85f52777a4ae47aa9194a61e79de96dd6a09aa22bea7706da4b73ae3d51c35f38ba5659f45372
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## Rib 1.2.4 -- 2014-03-13
|
4
|
+
|
5
|
+
* Fixed a regression introduced in 1.2.0. Now `rib all -e 'p 123'` should
|
6
|
+
work properly. Previously -e is ignored after rib apps.
|
7
|
+
* Fixed a long standing Windows issue, where `rib all` did not work because
|
8
|
+
there's no `which` on Windows. Now we fall back to `where`.
|
9
|
+
* Warn on removing main method on `TOPLEVEL_BINDING`. Not sure if this
|
10
|
+
would happen, but at least we could have a warning.
|
11
|
+
|
3
12
|
## Rib 1.2.3 -- 2014-02-08
|
4
13
|
|
5
14
|
* [extra/paging] Properly disable paging if less or ENV['PAGER'] is not
|
data/lib/rib/runner.rb
CHANGED
@@ -66,15 +66,14 @@ module Rib::Runner
|
|
66
66
|
|
67
67
|
def run argv=ARGV
|
68
68
|
(@running_commands ||= []) << Rib.config[:name]
|
69
|
-
unused
|
69
|
+
unused = parse(argv)
|
70
70
|
# if it's running a Rib command, the loop would be inside Rib itself
|
71
71
|
# so here we only parse args for the command
|
72
72
|
return if @running_commands.pop != 'rib'
|
73
|
-
# by
|
73
|
+
# by coming to this line, it means now we're running Rib main loop,
|
74
74
|
# not any other Rib command
|
75
75
|
Rib.warn("Unused arguments: #{unused.inspect}") unless unused.empty?
|
76
76
|
require 'rib/core' if Rib.config.delete(:mimic_irb)
|
77
|
-
Rib.shell.eval_binding.eval(e, __FILE__, __LINE__)
|
78
77
|
loop
|
79
78
|
end
|
80
79
|
|
@@ -97,11 +96,12 @@ module Rib::Runner
|
|
97
96
|
end
|
98
97
|
|
99
98
|
def parse argv
|
100
|
-
unused
|
99
|
+
unused = []
|
101
100
|
until argv.empty?
|
102
101
|
case arg = argv.shift
|
103
102
|
when /^-e=?(.+)?/, /^--eval=?(.+)?/
|
104
|
-
|
103
|
+
Rib.shell.eval_binding.eval(
|
104
|
+
$1 || argv.shift || '', __FILE__, __LINE__)
|
105
105
|
|
106
106
|
when /^-d/, '--debug'
|
107
107
|
$DEBUG = true
|
@@ -141,7 +141,7 @@ module Rib::Runner
|
|
141
141
|
unused << arg
|
142
142
|
end
|
143
143
|
end
|
144
|
-
|
144
|
+
unused
|
145
145
|
end
|
146
146
|
|
147
147
|
def parse_next argv, arg
|
@@ -165,15 +165,21 @@ module Rib::Runner
|
|
165
165
|
|
166
166
|
def load_command command
|
167
167
|
bin = "rib-#{command}"
|
168
|
-
path =
|
168
|
+
path = which_bin(bin)
|
169
169
|
if path == ''
|
170
170
|
Rib.warn(
|
171
171
|
"Can't find #{bin} in $PATH. Please make sure it is installed,",
|
172
|
-
"or is there any typo? You can try this to install it:\n"
|
172
|
+
"or is there any typo? You can try this to install it:\n" ,
|
173
173
|
" gem install #{bin}")
|
174
174
|
else
|
175
175
|
Rib.config[:name] = bin
|
176
176
|
load(path)
|
177
177
|
end
|
178
178
|
end
|
179
|
+
|
180
|
+
def which_bin bin # handle windows here
|
181
|
+
`which #{bin}`.strip
|
182
|
+
rescue Errno::ENOENT # probably a windows platform, try where
|
183
|
+
`where #{bin}`.lines.first.strip
|
184
|
+
end
|
179
185
|
end
|
data/lib/rib/shell.rb
CHANGED
@@ -69,11 +69,14 @@ class Rib::Shell
|
|
69
69
|
# Avoid namespace pollution from rubygems bin stub.
|
70
70
|
# To be specific, version and str.
|
71
71
|
def new_private_binding
|
72
|
-
TOPLEVEL_BINDING.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
TOPLEVEL_BINDING.instance_eval do
|
73
|
+
singleton_class.module_eval do
|
74
|
+
Rib.warn("Removing existing main...") if method_defined?(:main)
|
75
|
+
def main; binding; end # any way to define <main> method?
|
76
|
+
end
|
77
|
+
ret = main
|
78
|
+
singleton_class.send(:remove_method, 'main') # never pollute anything
|
79
|
+
ret
|
80
|
+
end
|
78
81
|
end
|
79
82
|
end
|
data/lib/rib/test.rb
CHANGED
data/lib/rib/version.rb
CHANGED
data/rib.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rib 1.2.
|
2
|
+
# stub: rib 1.2.4 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rib"
|
6
|
-
s.version = "1.2.
|
6
|
+
s.version = "1.2.4"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2014-
|
11
|
+
s.date = "2014-03-13"
|
12
12
|
s.description = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell\n\nRib is based on the design of [ripl][] and the work of [ripl-rc][], some of\nthe features are also inspired by [pry][]. The aim of Rib is to be fully\nfeatured and yet very easy to opt-out or opt-in other features. It shall\nbe simple, lightweight and modular so that everyone could customize Rib.\n\n[ripl]: https://github.com/cldwalker/ripl\n[ripl-rc]: https://github.com/godfat/ripl-rc\n[pry]: https://github.com/pry/pry"
|
13
13
|
s.email = ["godfat (XD) godfat.org"]
|
14
14
|
s.executables = [
|
data/test/test_runner.rb
CHANGED
@@ -32,4 +32,23 @@ describe Rib::Runner do
|
|
32
32
|
output
|
33
33
|
Rib::Runner.run(%w[-e]).should.eq @shell
|
34
34
|
end
|
35
|
+
|
36
|
+
def verify_app_e argv
|
37
|
+
input('a')
|
38
|
+
output('1')
|
39
|
+
conf = {:name => 'rib'}
|
40
|
+
min = 'rib-min'
|
41
|
+
mock(Rib::Runner).which_bin(min){ min }
|
42
|
+
mock(Rib::Runner).load(min){ Rib::Runner.run(argv) }
|
43
|
+
stub(Rib).config{ conf }
|
44
|
+
Rib::Runner.run(argv).should.eq @shell
|
45
|
+
end
|
46
|
+
|
47
|
+
should 'min -e' do
|
48
|
+
verify_app_e(%w[min -ea=1])
|
49
|
+
end
|
50
|
+
|
51
|
+
should '-e min' do
|
52
|
+
verify_app_e(%w[-ea=1 min])
|
53
|
+
end
|
35
54
|
end
|
data/test/test_shell.rb
CHANGED
@@ -7,40 +7,44 @@ describe Rib::Shell do
|
|
7
7
|
|
8
8
|
before do
|
9
9
|
Rib.disable_plugins
|
10
|
-
@shell =
|
10
|
+
@shell = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def shell
|
14
|
+
@shell ||= Rib::Shell.new
|
11
15
|
end
|
12
16
|
|
13
17
|
describe '#loop' do
|
14
18
|
def input str
|
15
|
-
mock(
|
16
|
-
|
19
|
+
mock(shell).get_input{str}
|
20
|
+
shell.loop
|
17
21
|
true.should.eq true
|
18
22
|
end
|
19
23
|
should 'exit' do input('exit' ) end
|
20
24
|
should 'also exit' do input(' exit') end
|
21
|
-
should 'ctrl+d' do mock(
|
22
|
-
should ':q' do
|
23
|
-
should '\q' do
|
25
|
+
should 'ctrl+d' do mock(shell).puts{} ; input(nil) end
|
26
|
+
should ':q' do shell.config[:exit] << ':q'; input(':q') end
|
27
|
+
should '\q' do shell.config[:exit] << '\q'; input('\q') end
|
24
28
|
end
|
25
29
|
|
26
30
|
describe '#loop_once' do
|
27
31
|
def input str=nil
|
28
32
|
if block_given?
|
29
|
-
mock(
|
33
|
+
mock(shell).get_input{ yield }
|
30
34
|
else
|
31
|
-
mock(
|
35
|
+
mock(shell).get_input{ str }
|
32
36
|
end
|
33
|
-
|
37
|
+
shell.loop_once
|
34
38
|
true.should.eq true
|
35
39
|
end
|
36
40
|
|
37
41
|
should 'handles ctrl+c' do
|
38
|
-
mock(
|
42
|
+
mock(shell).handle_interrupt{}
|
39
43
|
input{ raise Interrupt }
|
40
44
|
end
|
41
45
|
|
42
46
|
should 'prints result' do
|
43
|
-
mock(
|
47
|
+
mock(shell).puts('=> "mm"'){}
|
44
48
|
input('"m" * 2')
|
45
49
|
end
|
46
50
|
|
@@ -55,44 +59,56 @@ describe Rib::Shell do
|
|
55
59
|
end
|
56
60
|
|
57
61
|
should 'print error from eval' do
|
58
|
-
mock(
|
62
|
+
mock(shell).puts(match(/RuntimeError/)){}
|
59
63
|
input('raise "blah"')
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
63
67
|
describe '#prompt' do
|
64
68
|
should 'be changeable' do
|
65
|
-
|
66
|
-
|
69
|
+
shell.config[:prompt] = '> '
|
70
|
+
shell.prompt.should.eq '> '
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
74
|
describe '#eval_input' do
|
71
75
|
before do
|
72
|
-
@line =
|
76
|
+
@line = shell.config[:line]
|
73
77
|
end
|
74
78
|
|
75
79
|
should 'line' do
|
76
|
-
|
77
|
-
|
80
|
+
shell.eval_input('10 ** 2')
|
81
|
+
shell.config[:line].should.eq @line + 1
|
78
82
|
end
|
79
83
|
|
80
84
|
should 'print error and increments line' do
|
81
|
-
result, err =
|
85
|
+
result, err = shell.eval_input('{')
|
82
86
|
result.should.eq nil
|
83
87
|
err.should.kind_of?(SyntaxError)
|
84
|
-
|
88
|
+
shell.config[:line].should.eq @line + 1
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|
88
92
|
should 'call after_loop even if in_loop raises' do
|
89
|
-
mock(
|
93
|
+
mock(shell).loop_once{ raise 'boom' }
|
90
94
|
mock(Rib).warn(is_a(String)){}
|
91
|
-
mock(
|
92
|
-
lambda{
|
95
|
+
mock(shell).after_loop{}
|
96
|
+
lambda{shell.loop}.should.raise(RuntimeError)
|
93
97
|
end
|
94
98
|
|
95
99
|
should 'have empty binding' do
|
96
|
-
|
100
|
+
shell.eval_input('local_variables').first.should.empty
|
101
|
+
end
|
102
|
+
|
103
|
+
should 'not pollute main' do
|
104
|
+
shell.eval_input('main').first.should.eq 'rib'
|
105
|
+
end
|
106
|
+
|
107
|
+
should 'warn on removing main' do
|
108
|
+
TOPLEVEL_BINDING.singleton_class.module_eval do
|
109
|
+
def main; end
|
110
|
+
end
|
111
|
+
mock(Rib).warn(is_a(String)){}
|
112
|
+
shell.eval_input('main').first.should.eq 'rib'
|
97
113
|
end
|
98
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
|