rib 1.5.4 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitlab-ci.yml +40 -0
- data/.gitmodules +1 -1
- data/CHANGES.md +30 -0
- data/Gemfile +0 -5
- data/README.md +30 -13
- data/lib/rib/api.rb +4 -0
- data/lib/rib/app/rack.rb +1 -1
- data/lib/rib/core/multiline.rb +6 -4
- data/lib/rib/extra/autoindent.rb +8 -2
- data/lib/rib/extra/byebug.rb +109 -0
- data/lib/rib/more/beep.rb +4 -5
- data/lib/rib/more/bottomup_backtrace.rb +1 -1
- data/lib/rib/more/caller.rb +5 -1
- data/lib/rib/more/color.rb +6 -2
- data/lib/rib/test/multiline.rb +28 -8
- data/lib/rib/test.rb +37 -12
- data/lib/rib/version.rb +1 -1
- data/rib.gemspec +6 -5
- data/task/README.md +2 -2
- data/task/gemgem.rb +3 -1
- data/test/core/test_history.rb +1 -2
- data/test/core/test_squeeze_history.rb +1 -2
- data/test/extra/test_autoindent.rb +69 -8
- data/test/more/test_beep.rb +13 -10
- data/test/more/test_multiline_history.rb +3 -3
- data/test/test_shell.rb +18 -12
- metadata +8 -8
- data/.travis.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62dad317e197fde4c11688f03c450205b2e47a7536175b9ec4fbd74bf1ba40e5
|
4
|
+
data.tar.gz: 59b8c6ac55c4fd1a95d640710e01930d8d68a636e61c86a5c2d63f0546c25123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc4de9174c2a49db81d42ea3c91361c6f4a88435e9f169127914c94921fb7f3ddbc27673c8f5e7f70d31fbd25a163147e3dfe48c31bdeee34fcca0df38451a1a
|
7
|
+
data.tar.gz: b74d9fa8f2c8a63c92a44378e0db0a0848fd2275223fad29c885c48d67beb9b201fc24f25c639ee276e74337d195bf4e80fcc53dcf07fe42b6fc595df3cd5f3b
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
stages:
|
3
|
+
- test
|
4
|
+
|
5
|
+
.test:
|
6
|
+
stage: test
|
7
|
+
image: ruby:${RUBY_VERSION}-bullseye
|
8
|
+
variables:
|
9
|
+
GIT_DEPTH: "1"
|
10
|
+
GIT_SUBMODULE_STRATEGY: recursive
|
11
|
+
GIT_SUBMODULE_PATHS: task
|
12
|
+
RUBYOPT: --enable-frozen-string-literal
|
13
|
+
before_script:
|
14
|
+
- bundle install --retry=3
|
15
|
+
- unset CI # Coverage doesn't work well with frozen literal
|
16
|
+
script:
|
17
|
+
- ruby -vr bundler/setup -S rake test
|
18
|
+
|
19
|
+
ruby:3.0:
|
20
|
+
extends:
|
21
|
+
- .test
|
22
|
+
variables:
|
23
|
+
RUBY_VERSION: '3.0'
|
24
|
+
|
25
|
+
ruby:3.1:
|
26
|
+
extends:
|
27
|
+
- .test
|
28
|
+
variables:
|
29
|
+
RUBY_VERSION: '3.1'
|
30
|
+
|
31
|
+
ruby:3.2:
|
32
|
+
extends:
|
33
|
+
- .test
|
34
|
+
variables:
|
35
|
+
RUBY_VERSION: '3.2'
|
36
|
+
|
37
|
+
jruby:latest:
|
38
|
+
extends:
|
39
|
+
- .test
|
40
|
+
image: jruby:latest
|
data/.gitmodules
CHANGED
data/CHANGES.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## Rib 1.6.1 -- 2022-12-30
|
4
|
+
|
5
|
+
### Bugs fixed
|
6
|
+
|
7
|
+
* Fixed `rib rack` for constant resolution.
|
8
|
+
|
9
|
+
### Enhancement
|
10
|
+
|
11
|
+
* [more/color] Instead of using `$1` and `$2`, use `Regexp.last_match`.
|
12
|
+
It should be the same for MRI, but seems to be working better for JRuby.
|
13
|
+
Perhaps `$1` and `$2` is not thread local on JRuby?
|
14
|
+
|
15
|
+
## Rib 1.6.0 -- 2018-06-20
|
16
|
+
|
17
|
+
* [core/multiline] Support for JRuby 9.2.0.0 is fixed
|
18
|
+
* [more/beep] It would now beep every single time when any evaluation took
|
19
|
+
longer than the threshold.
|
20
|
+
* [more/color] Fix whenever the input is just `next` or `break`
|
21
|
+
* [more/bottomup_backtrace] This would no longer format backtrace twice
|
22
|
+
* [more/caller] It would now properly use the enabled plugins
|
23
|
+
* [extra/autoindent] It would now indent with `ensure` for `begin` and `def`.
|
24
|
+
Thanks @MITSUBOSHI https://github.com/godfat/rib/pull/21 and
|
25
|
+
@alpaca-tc https://github.com/godfat/rib/pull/17
|
26
|
+
* [extra/autoindent] It would now indent with `for`.
|
27
|
+
Thanks @MITSUBOSHI https://github.com/godfat/rib/pull/18
|
28
|
+
* [extra/autoindent] It would now indent with `()` and `[]`.
|
29
|
+
Thanks @MITSUBOSHI https://github.com/godfat/rib/pull/20 and
|
30
|
+
https://github.com/godfat/rib/pull/19
|
31
|
+
* [extra/byebug] This is now work-in-progress.
|
32
|
+
|
3
33
|
## Rib 1.5.4 -- 2017-10-23
|
4
34
|
|
5
35
|
* Removed unnecessary method definition for `puts`
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Rib [![
|
1
|
+
# Rib [![Pipeline status](https://gitlab.com/godfat/rib/badges/master/pipeline.svg)](https://gitlab.com/godfat/rib/-/pipelines)
|
2
2
|
|
3
3
|
by Lin Jen-Shin ([godfat](http://godfat.org))
|
4
4
|
|
@@ -24,7 +24,7 @@ be simple, lightweight and modular so that everyone could customize Rib.
|
|
24
24
|
|
25
25
|
## REQUIREMENTS:
|
26
26
|
|
27
|
-
* Tested with MRI (official CRuby)
|
27
|
+
* Tested with MRI (official CRuby) and JRuby.
|
28
28
|
* All gem dependencies are optional, but it's highly recommended to use
|
29
29
|
Rib with [bond][] for tab completion.
|
30
30
|
|
@@ -132,6 +132,31 @@ file. To see a list of overridable API, please read [api.rb][]
|
|
132
132
|
|
133
133
|
[api.rb]: https://github.com/godfat/rib/blob/master/lib/rib/api.rb
|
134
134
|
|
135
|
+
#### Disable enabled plugins
|
136
|
+
|
137
|
+
While it's convenient to just `require 'rib/all'`, you might not want to use
|
138
|
+
all the plugins. No worries, you don't have to list everything in order to
|
139
|
+
not use something. For example, you might not get used to `bottomup_backtrace`
|
140
|
+
and don't want to use it. You could put this in your config:
|
141
|
+
|
142
|
+
``` ruby
|
143
|
+
require 'rib/all'
|
144
|
+
|
145
|
+
Rib::BottomupBacktrace.disable
|
146
|
+
```
|
147
|
+
|
148
|
+
This could disable `bottomup_backtrace` so you get regular top-down backtrace
|
149
|
+
with all other plugins. This is particularly useful whenever there's a bug
|
150
|
+
in one of the plugins, and you might need to disable some plugins in order to
|
151
|
+
debug. You could always enable it again with:
|
152
|
+
|
153
|
+
``` ruby
|
154
|
+
Rib::BottomupBacktrace.enable
|
155
|
+
```
|
156
|
+
|
157
|
+
You could do this any time, in the config, or in the shell session. No need to
|
158
|
+
restart anything, because it takes effect immediately.
|
159
|
+
|
135
160
|
#### Rib home and history file
|
136
161
|
|
137
162
|
Rib home is used to store a config file and a history file, which is
|
@@ -313,15 +338,6 @@ or having conflicted semantics.
|
|
313
338
|
|
314
339
|
Which would print the result with hirb.
|
315
340
|
|
316
|
-
* `require 'rib/extra/debugger'` This plugin is depending on:
|
317
|
-
|
318
|
-
1. [debugger][]
|
319
|
-
|
320
|
-
Which introduces `Rib.debug`, which would do similar things as
|
321
|
-
`Rib.anchor` but only more powerful. However, this is not well
|
322
|
-
tested and might not work well. Please let me know if you have
|
323
|
-
any issue using it, thanks!
|
324
|
-
|
325
341
|
* `require 'rib/extra/paging'` This plugin is depending on `less` and `tput`.
|
326
342
|
|
327
343
|
Which would pass the result to `less` (or `$PAGER` if set) if
|
@@ -332,7 +348,6 @@ or having conflicted semantics.
|
|
332
348
|
|
333
349
|
[readline_buffer]: https://github.com/godfat/readline_buffer
|
334
350
|
[hirb]: https://github.com/cldwalker/hirb
|
335
|
-
[debugger]: https://github.com/cldwalker/debugger
|
336
351
|
|
337
352
|
### As a debugging/interacting tool
|
338
353
|
|
@@ -454,15 +469,17 @@ simple, simpler than rib-rails.
|
|
454
469
|
* ayaya (@ayamomiji)
|
455
470
|
* Lin Jen-Shin (@godfat)
|
456
471
|
* Mr. Big Cat (@miaout17)
|
472
|
+
* @alpaca-tc
|
457
473
|
* @bootleq
|
458
474
|
* @lulalala
|
475
|
+
* @MITSUBOSH
|
459
476
|
* @tka
|
460
477
|
|
461
478
|
## LICENSE:
|
462
479
|
|
463
480
|
Apache License 2.0 (Apache-2.0)
|
464
481
|
|
465
|
-
Copyright (c) 2011-
|
482
|
+
Copyright (c) 2011-2022, Lin Jen-Shin (godfat)
|
466
483
|
|
467
484
|
Licensed under the Apache License, Version 2.0 (the "License");
|
468
485
|
you may not use this file except in compliance with the License.
|
data/lib/rib/api.rb
CHANGED
data/lib/rib/app/rack.rb
CHANGED
@@ -12,7 +12,7 @@ module Rib; module Rack
|
|
12
12
|
def load_rack
|
13
13
|
require 'rack'
|
14
14
|
Rib.abort("Error: Cannot find config.ru") unless rack?
|
15
|
-
app, _ = Rack::Builder.parse_file(configru_path)
|
15
|
+
app, _ = ::Rack::Builder.parse_file(configru_path)
|
16
16
|
self.app = app
|
17
17
|
Rib.shell.eval_binding.eval('def app; Rib::Rack.app; end')
|
18
18
|
Rib.say("Access your app via :app method")
|
data/lib/rib/core/multiline.rb
CHANGED
@@ -59,11 +59,13 @@ module Rib; module Multiline
|
|
59
59
|
[ # string or regexp
|
60
60
|
"unterminated \\w+ meets end of file",
|
61
61
|
# jruby
|
62
|
-
"syntax error, unexpected"
|
63
|
-
" t(UPLUS|UMINUS|STAR|REGEXP_BEG|AMPER)",
|
64
|
-
"syntax error, unexpected end-of-file",
|
62
|
+
"syntax error, unexpected end\\-of\\-file",
|
65
63
|
# jruby 9.0.4.0
|
66
|
-
"formal argument must be local variable"
|
64
|
+
"formal argument must be local variable",
|
65
|
+
# jruby 9.2.0.0
|
66
|
+
"syntax error, unexpected (#{RUBY20_IO.join('|')})",
|
67
|
+
"syntax error, unexpected '\\W'"
|
68
|
+
].join('|'))
|
67
69
|
end
|
68
70
|
|
69
71
|
# --------------- Rib API ---------------
|
data/lib/rib/extra/autoindent.rb
CHANGED
@@ -24,7 +24,11 @@ module Rib; module Autoindent
|
|
24
24
|
# rescue E => e
|
25
25
|
# rescue E=> e
|
26
26
|
# rescue E =>e
|
27
|
-
|
27
|
+
# ensure
|
28
|
+
/^begin$/ =>
|
29
|
+
/^(end)\b|^else$|^rescue *((\w+)? *(=> *\w+)?)?$|^ensure$/,
|
30
|
+
/^def\b/ =>
|
31
|
+
/^(end)\b|^else$|^rescue *((\w+)? *(=> *\w+)?)?$|^ensure$/,
|
28
32
|
# elsif Expression
|
29
33
|
# consider cases:
|
30
34
|
# elsif(true)
|
@@ -34,10 +38,10 @@ module Rib; module Autoindent
|
|
34
38
|
/^if\b/ => /^(end)\b|^else$|^elsif\b/,
|
35
39
|
/^unless\b/ => /^(end)\b|^else$|^elsif\b/,
|
36
40
|
/^case\b/ => /^(end)\b|^else$|when\b/ ,
|
37
|
-
/^def\b/ => /^(end)\b/ ,
|
38
41
|
/^class\b/ => /^(end)\b/ ,
|
39
42
|
/^module\b/ => /^(end)\b/ ,
|
40
43
|
/^while\b/ => /^(end)\b/ ,
|
44
|
+
/^for\b/ => /^(end)\b/ ,
|
41
45
|
/^until\b/ => /^(end)\b/ ,
|
42
46
|
# consider cases:
|
43
47
|
# 'do
|
@@ -52,6 +56,8 @@ module Rib; module Autoindent
|
|
52
56
|
# begin
|
53
57
|
/do( *\|.*\|)?$/ => /^(end)\b/ ,
|
54
58
|
/\{( *\|.*\|)?$/ => /^(\})\B/ ,
|
59
|
+
/\($/ => /^(\))\B/ ,
|
60
|
+
/\[$/ => /^(\])\B/ ,
|
55
61
|
# those are too hard to deal with, so we use syntax error to double check
|
56
62
|
# what about this then?
|
57
63
|
# v = if true
|
@@ -0,0 +1,109 @@
|
|
1
|
+
|
2
|
+
require 'rib/more/anchor'
|
3
|
+
require 'byebug/core'
|
4
|
+
|
5
|
+
# This is based on lib/byebug/processors/pry_processor.rb
|
6
|
+
|
7
|
+
module Rib; module Byebug
|
8
|
+
extend Plugin
|
9
|
+
Shell.use(self)
|
10
|
+
|
11
|
+
def before_loop
|
12
|
+
return super if Rib::Byebug.disabled?
|
13
|
+
|
14
|
+
super
|
15
|
+
# ::Byebug::RibProcessor.start
|
16
|
+
end
|
17
|
+
|
18
|
+
module Imp
|
19
|
+
def byebug
|
20
|
+
return if Rib::Byebug.disabled?
|
21
|
+
|
22
|
+
::Byebug::RibProcessor.start
|
23
|
+
end
|
24
|
+
|
25
|
+
def location
|
26
|
+
Rib.shell.config[:byebug].location
|
27
|
+
end
|
28
|
+
|
29
|
+
def step times=1
|
30
|
+
throw :rib_byebug, [:step, times]
|
31
|
+
end
|
32
|
+
|
33
|
+
def next lines=1
|
34
|
+
throw :rib_byebug, [:next, lines]
|
35
|
+
end
|
36
|
+
|
37
|
+
def finish
|
38
|
+
throw :rib_byebug, [:finish]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Rib.extend(Imp)
|
43
|
+
end; end
|
44
|
+
|
45
|
+
module Byebug
|
46
|
+
class RibProcessor < CommandProcessor
|
47
|
+
def self.start
|
48
|
+
Byebug.start
|
49
|
+
Setting[:autolist] = false
|
50
|
+
Context.processor = self
|
51
|
+
steps = caller.index{ |path| !path.start_with?(__FILE__) }
|
52
|
+
Byebug.current_context.step_out(steps + 2, true)
|
53
|
+
end
|
54
|
+
|
55
|
+
def at_line
|
56
|
+
resume_rib
|
57
|
+
end
|
58
|
+
|
59
|
+
def at_return(_return_value)
|
60
|
+
resume_rib
|
61
|
+
end
|
62
|
+
|
63
|
+
def at_end
|
64
|
+
resume_rib
|
65
|
+
end
|
66
|
+
|
67
|
+
def at_breakpoint(breakpoint)
|
68
|
+
raise NotImplementedError
|
69
|
+
end
|
70
|
+
|
71
|
+
def location
|
72
|
+
context.location
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def print_location
|
78
|
+
shell = Rib.shell
|
79
|
+
shell.puts(shell.format_backtrace([location]).first)
|
80
|
+
end
|
81
|
+
|
82
|
+
def resume_rib
|
83
|
+
return if Rib.shell.running?
|
84
|
+
|
85
|
+
byebug_binding = frame._binding
|
86
|
+
|
87
|
+
print_location
|
88
|
+
|
89
|
+
action, *args = catch(:rib_byebug) do
|
90
|
+
allowing_other_threads do
|
91
|
+
Rib.anchor byebug_binding, :byebug => self
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
perform(action, args)
|
96
|
+
end
|
97
|
+
|
98
|
+
def perform action, args
|
99
|
+
case action
|
100
|
+
when :step
|
101
|
+
context.step_into(*args, frame.pos)
|
102
|
+
when :next
|
103
|
+
context.step_over(*args, frame.pos)
|
104
|
+
when :finish
|
105
|
+
context.step_out(1)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/rib/more/beep.rb
CHANGED
@@ -7,12 +7,11 @@ module Rib; module Beep
|
|
7
7
|
|
8
8
|
# --------------- Rib API ---------------
|
9
9
|
|
10
|
-
def
|
11
|
-
super
|
12
|
-
return self if Beep.disabled?
|
10
|
+
def loop_once
|
11
|
+
return super if Beep.disabled?
|
13
12
|
beep if started_at && (Time.now - started_at) > beep_threshold
|
14
|
-
|
15
|
-
|
13
|
+
config[:started_at] = Time.now
|
14
|
+
super
|
16
15
|
end
|
17
16
|
|
18
17
|
private
|
@@ -10,7 +10,7 @@ module Rib; module BottomupBacktrace
|
|
10
10
|
def format_error err
|
11
11
|
return super if BottomupBacktrace.disabled?
|
12
12
|
message, backtrace = get_error(err)
|
13
|
-
" #{
|
13
|
+
" #{backtrace.join("\n ")}\n#{message}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def format_backtrace backtrace
|
data/lib/rib/more/caller.rb
CHANGED
@@ -9,7 +9,11 @@ module Rib; module Caller
|
|
9
9
|
def caller *filters
|
10
10
|
return if Rib::Caller.disabled?
|
11
11
|
|
12
|
-
|
12
|
+
display_backtrace(super().drop(1), *filters)
|
13
|
+
end
|
14
|
+
|
15
|
+
def display_backtrace raw_backtrace, *filters
|
16
|
+
backtrace = Rib.shell.format_backtrace(raw_backtrace)
|
13
17
|
|
14
18
|
lib = %r{\brib-#{Rib::VERSION}/lib/rib/}
|
15
19
|
if backtrace.first =~ lib
|
data/lib/rib/more/color.rb
CHANGED
@@ -20,7 +20,7 @@ module Rib; module Color
|
|
20
20
|
def get_error err
|
21
21
|
return super if Color.disabled?
|
22
22
|
message, backtrace = super
|
23
|
-
[format_color(err, message),
|
23
|
+
[format_color(err, message), backtrace]
|
24
24
|
end
|
25
25
|
|
26
26
|
def warn message
|
@@ -87,7 +87,11 @@ module Rib; module Color
|
|
87
87
|
backtrace.map{ |b|
|
88
88
|
path, msgs = b.split(':', 2)
|
89
89
|
dir, sep, file = path.rpartition('/')
|
90
|
-
|
90
|
+
msgs ||= (line - 1).to_s # msgs would be nil when input is next/break
|
91
|
+
msg = msgs.sub(/(\d+)(:?)/) do
|
92
|
+
m = Regexp.last_match
|
93
|
+
"#{red{m[1]}}#{m[2]}"
|
94
|
+
end.sub(/`.+?'/){green{Regexp.last_match[0]}}
|
91
95
|
|
92
96
|
"#{dir+sep}#{yellow{file}}:#{msg}"
|
93
97
|
}
|
data/lib/rib/test/multiline.rb
CHANGED
@@ -18,29 +18,29 @@ copy :setup_multiline do
|
|
18
18
|
if err
|
19
19
|
mock(shell).print_eval_error(is_a(err)){}
|
20
20
|
else
|
21
|
-
mock(shell).print_result(
|
21
|
+
mock(shell).print_result(is_a(Object)){}
|
22
22
|
end
|
23
23
|
shell.loop_once
|
24
24
|
ok
|
25
25
|
end
|
26
26
|
|
27
27
|
def check str, err=nil
|
28
|
+
yield if block_given?
|
29
|
+
|
28
30
|
lines = str.split("\n")
|
29
31
|
lines[0...-1].each{ |line|
|
30
32
|
input(line)
|
31
33
|
shell.loop_once
|
32
34
|
}
|
33
|
-
input_done(lines.last, err)
|
34
|
-
shell.eval_binding.eval(str)
|
35
|
-
end
|
35
|
+
input_done(lines.last, err)
|
36
36
|
end
|
37
|
-
end
|
38
37
|
|
39
|
-
copy :multiline do
|
40
38
|
before do
|
41
39
|
stub_output
|
42
40
|
end
|
41
|
+
end
|
43
42
|
|
43
|
+
copy :multiline do
|
44
44
|
would 'work with no prompt' do
|
45
45
|
shell.config[:prompt] = ''
|
46
46
|
check <<~RUBY
|
@@ -137,9 +137,23 @@ copy :multiline do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
would 'be hash treated as a block SyntaxError' do
|
140
|
-
|
140
|
+
code = <<~RUBY
|
141
141
|
puts { :x => 10 }.class
|
142
142
|
RUBY
|
143
|
+
|
144
|
+
if RUBY_VERSION >= '3.0.0'
|
145
|
+
check code do
|
146
|
+
stub(shell.config[:binding_object]).puts{}
|
147
|
+
end
|
148
|
+
else
|
149
|
+
check code, SyntaxError
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
would 'SyntaxError' do
|
154
|
+
check <<~RUBY, SyntaxError
|
155
|
+
s-y n
|
156
|
+
RUBY
|
143
157
|
end
|
144
158
|
|
145
159
|
would 'begin with SyntaxError' do
|
@@ -171,10 +185,16 @@ copy :multiline do
|
|
171
185
|
end
|
172
186
|
|
173
187
|
would 'binary operator /' do
|
174
|
-
|
188
|
+
code = <<~RUBY
|
175
189
|
1+1.to_i /
|
176
190
|
1
|
177
191
|
RUBY
|
192
|
+
|
193
|
+
if RUBY_VERSION >= '3.0.0'
|
194
|
+
check code.lines.first, SyntaxError
|
195
|
+
else
|
196
|
+
check code
|
197
|
+
end
|
178
198
|
end
|
179
199
|
|
180
200
|
would 'binary operator |' do
|
data/lib/rib/test.rb
CHANGED
@@ -20,14 +20,19 @@ copy :rib do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def new_shell opts={}
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
binding_object = Object.new
|
24
|
+
result = Rib::Shell.new(
|
25
|
+
{:binding => binding_object.instance_eval{binding},
|
26
|
+
:binding_object => binding_object}.
|
27
|
+
merge(opts))
|
28
|
+
yield(result) if block_given?
|
29
|
+
result.before_loop
|
26
30
|
end
|
27
31
|
|
28
32
|
def stub_output
|
29
33
|
stub(shell).print(is_a(String)){}
|
30
34
|
stub(shell).puts(is_a(String)){}
|
35
|
+
stub(shell).puts{}
|
31
36
|
end
|
32
37
|
|
33
38
|
def readline?
|
@@ -51,9 +56,10 @@ copy :rib do
|
|
51
56
|
Rib.disable_plugins(rest)
|
52
57
|
end
|
53
58
|
|
54
|
-
|
59
|
+
describe "enabling #{plugins}" do
|
60
|
+
block.call
|
55
61
|
|
56
|
-
|
62
|
+
case ENV['TEST_LEVEL']
|
57
63
|
when '0'
|
58
64
|
when '1'
|
59
65
|
test_level1(rest, block)
|
@@ -63,13 +69,18 @@ copy :rib do
|
|
63
69
|
test_level3(rest, block)
|
64
70
|
else # test_level3 is too slow because of rr (i guess)
|
65
71
|
test_level2(rest, block)
|
72
|
+
end
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
69
76
|
def test_level1 rest, block
|
70
77
|
rest.each{ |target|
|
71
78
|
target.enable
|
72
|
-
|
79
|
+
|
80
|
+
describe "also enabling #{target}" do
|
81
|
+
block.call
|
82
|
+
end
|
83
|
+
|
73
84
|
target.disable
|
74
85
|
}
|
75
86
|
end
|
@@ -77,17 +88,31 @@ copy :rib do
|
|
77
88
|
def test_level2 rest, block
|
78
89
|
rest.combination(2).each{ |targets|
|
79
90
|
Rib.enable_plugins(targets)
|
80
|
-
|
91
|
+
|
92
|
+
describe "also enabling #{targets.join(', ')}" do
|
93
|
+
block.call
|
94
|
+
end
|
95
|
+
|
81
96
|
Rib.disable_plugins(targets)
|
82
97
|
}
|
83
98
|
end
|
84
99
|
|
85
100
|
def test_level3 rest, block
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
101
|
+
if rest.empty?
|
102
|
+
block.call
|
103
|
+
else
|
104
|
+
rest[0].enable
|
105
|
+
|
106
|
+
describe "also enabling #{rest[0]}" do
|
107
|
+
test_level3(rest[1..-1], block)
|
108
|
+
end
|
109
|
+
|
110
|
+
rest[0].disable
|
111
|
+
|
112
|
+
describe "disabling #{rest[0]}" do
|
113
|
+
test_level3(rest[1..-1], block)
|
114
|
+
end
|
115
|
+
end
|
91
116
|
end
|
92
117
|
end
|
93
118
|
end
|
data/lib/rib/version.rb
CHANGED
data/rib.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rib 1.
|
2
|
+
# stub: rib 1.6.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rib".freeze
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.6.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Lin Jen-Shin (godfat)".freeze]
|
11
|
-
s.date = "
|
11
|
+
s.date = "2022-12-30"
|
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".freeze
|
13
13
|
s.email = ["godfat (XD) godfat.org".freeze]
|
14
14
|
s.executables = [
|
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
"rib-rails".freeze]
|
21
21
|
s.files = [
|
22
22
|
".gitignore".freeze,
|
23
|
+
".gitlab-ci.yml".freeze,
|
23
24
|
".gitmodules".freeze,
|
24
|
-
".travis.yml".freeze,
|
25
25
|
"CHANGES.md".freeze,
|
26
26
|
"Gemfile".freeze,
|
27
27
|
"LICENSE".freeze,
|
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
"lib/rib/core/strip_backtrace.rb".freeze,
|
52
52
|
"lib/rib/debug.rb".freeze,
|
53
53
|
"lib/rib/extra/autoindent.rb".freeze,
|
54
|
+
"lib/rib/extra/byebug.rb".freeze,
|
54
55
|
"lib/rib/extra/hirb.rb".freeze,
|
55
56
|
"lib/rib/extra/paging.rb".freeze,
|
56
57
|
"lib/rib/extra/spring.rb".freeze,
|
@@ -92,7 +93,7 @@ Gem::Specification.new do |s|
|
|
92
93
|
"test/test_shell.rb".freeze]
|
93
94
|
s.homepage = "https://github.com/godfat/rib".freeze
|
94
95
|
s.licenses = ["Apache-2.0".freeze]
|
95
|
-
s.rubygems_version = "
|
96
|
+
s.rubygems_version = "3.4.1".freeze
|
96
97
|
s.summary = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell".freeze
|
97
98
|
s.test_files = [
|
98
99
|
"test/core/test_completion.rb".freeze,
|
data/task/README.md
CHANGED
@@ -13,7 +13,7 @@ Provided tasks:
|
|
13
13
|
|
14
14
|
## REQUIREMENTS:
|
15
15
|
|
16
|
-
* Tested with MRI (official CRuby)
|
16
|
+
* Tested with MRI (official CRuby) and JRuby.
|
17
17
|
|
18
18
|
## INSTALLATION:
|
19
19
|
|
@@ -39,7 +39,7 @@ end
|
|
39
39
|
|
40
40
|
Apache License 2.0 (Apache-2.0)
|
41
41
|
|
42
|
-
Copyright (c) 2011-
|
42
|
+
Copyright (c) 2011-2021, Lin Jen-Shin (godfat)
|
43
43
|
|
44
44
|
Licensed under the Apache License, Version 2.0 (the "License");
|
45
45
|
you may not use this file except in compliance with the License.
|
data/task/gemgem.rb
CHANGED
@@ -42,6 +42,7 @@ module Gemgem
|
|
42
42
|
|
43
43
|
def gem_install
|
44
44
|
require 'rubygems/commands/install_command'
|
45
|
+
require 'rubygems/package'
|
45
46
|
# read ~/.gemrc
|
46
47
|
Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
|
47
48
|
Gem::Command.extra_args = Gem.configuration[:gem]
|
@@ -51,7 +52,8 @@ module Gemgem
|
|
51
52
|
cmd.handle_options([])
|
52
53
|
|
53
54
|
# install
|
54
|
-
|
55
|
+
gem_package = Gem::Package.new(gem_path)
|
56
|
+
install = Gem::Installer.new(gem_package, cmd.options)
|
55
57
|
install.install
|
56
58
|
puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)}\e[0m"
|
57
59
|
end
|
data/test/core/test_history.rb
CHANGED
@@ -39,7 +39,7 @@ describe Rib::Autoindent do
|
|
39
39
|
expect(@indent.stack_size).eq size
|
40
40
|
end
|
41
41
|
|
42
|
-
would 'begin rescue else end' do
|
42
|
+
would 'begin rescue else ensure end' do
|
43
43
|
ri('begin' , 1)
|
44
44
|
ri( '1' , 1)
|
45
45
|
le('rescue' , 1)
|
@@ -53,6 +53,30 @@ describe Rib::Autoindent do
|
|
53
53
|
le('rescue E=> e' , 1)
|
54
54
|
le('rescue E =>e ' , 1)
|
55
55
|
le('else' , 1)
|
56
|
+
ri( '1' , 1)
|
57
|
+
le('ensure' , 1)
|
58
|
+
ri( '1' , 1)
|
59
|
+
le('end while nil' , 0)
|
60
|
+
end
|
61
|
+
|
62
|
+
would 'def rescue else ensure end' do
|
63
|
+
ri('def f a' , 1)
|
64
|
+
ri( 'if a' , 2)
|
65
|
+
le( 'end' , 1)
|
66
|
+
le('rescue' , 1)
|
67
|
+
ri( '1' , 1)
|
68
|
+
le('rescue=>e' , 1)
|
69
|
+
le('rescue => e' , 1)
|
70
|
+
le('rescue =>e' , 1)
|
71
|
+
le('rescue E=>e ' , 1)
|
72
|
+
le('rescue E' , 1)
|
73
|
+
le('rescue E => e ', 1)
|
74
|
+
le('rescue E=> e' , 1)
|
75
|
+
le('rescue E =>e ' , 1)
|
76
|
+
le('else' , 1)
|
77
|
+
ri( '1' , 1)
|
78
|
+
le('ensure' , 1)
|
79
|
+
ri( '1' , 1)
|
56
80
|
le('end while nil' , 0)
|
57
81
|
end
|
58
82
|
|
@@ -96,13 +120,6 @@ describe Rib::Autoindent do
|
|
96
120
|
le('end' , 0)
|
97
121
|
end
|
98
122
|
|
99
|
-
would 'def end' do
|
100
|
-
ri('def f a' , 1)
|
101
|
-
ri( 'if a' , 2)
|
102
|
-
le( 'end' , 1)
|
103
|
-
le('end' , 0)
|
104
|
-
end
|
105
|
-
|
106
123
|
would 'class Object end' do
|
107
124
|
ri('class Object' , 1)
|
108
125
|
ri( 'if true' , 2)
|
@@ -125,6 +142,13 @@ describe Rib::Autoindent do
|
|
125
142
|
le('end' , 0)
|
126
143
|
end
|
127
144
|
|
145
|
+
would 'for end' do
|
146
|
+
ri('for x in 1..2' , 1)
|
147
|
+
ri( 'if true' , 2)
|
148
|
+
le( 'end' , 1)
|
149
|
+
le('end' , 0)
|
150
|
+
end
|
151
|
+
|
128
152
|
would 'until end' do
|
129
153
|
ri('until true' , 1)
|
130
154
|
ri( 'if true' , 2)
|
@@ -142,4 +166,41 @@ describe Rib::Autoindent do
|
|
142
166
|
le( 'end' , 1)
|
143
167
|
le('end' , 0)
|
144
168
|
end
|
169
|
+
|
170
|
+
would '{}' do
|
171
|
+
ri('{' , 1)
|
172
|
+
ri( ':a => :b' , 1)
|
173
|
+
le('}' , 0)
|
174
|
+
end
|
175
|
+
|
176
|
+
would '[].each{}' do
|
177
|
+
ri('[].each{' , 1)
|
178
|
+
ri( '0' , 1)
|
179
|
+
ri( '[].each {' , 2)
|
180
|
+
le( '}' , 1)
|
181
|
+
le('}' , 0)
|
182
|
+
end
|
183
|
+
|
184
|
+
would '()' do
|
185
|
+
ri('(' , 1)
|
186
|
+
ri( '0' , 1)
|
187
|
+
le(')' , 0)
|
188
|
+
end
|
189
|
+
|
190
|
+
would '{}.dig()' do
|
191
|
+
ri('{}.dig(' , 1)
|
192
|
+
ri( '0,' , 1)
|
193
|
+
ri( '1' , 1)
|
194
|
+
le(')' , 0)
|
195
|
+
end
|
196
|
+
|
197
|
+
would '[]' do
|
198
|
+
ri('[' , 1)
|
199
|
+
ri( '0,' , 1)
|
200
|
+
ri( '1,' , 1)
|
201
|
+
ri( '[' , 2)
|
202
|
+
ri( '2' , 2)
|
203
|
+
le( ']' , 1)
|
204
|
+
le(']' , 0)
|
205
|
+
end
|
145
206
|
end
|
data/test/more/test_beep.rb
CHANGED
@@ -9,21 +9,24 @@ describe Rib::Beep do
|
|
9
9
|
Rib::Beep.enable
|
10
10
|
end
|
11
11
|
|
12
|
-
after do
|
13
|
-
expect(Rib::Beep).disabled?
|
14
|
-
end
|
15
|
-
|
16
12
|
def verify delay, threshold=nil, &block
|
17
|
-
|
18
|
-
|
13
|
+
shell(:started_at => Time.now - delay,
|
14
|
+
:beep_threshold => threshold, &block)
|
15
|
+
|
16
|
+
stub_output
|
17
|
+
mock(shell).get_input{}
|
18
|
+
|
19
|
+
shell.loop
|
20
|
+
|
21
|
+
ok
|
19
22
|
end
|
20
23
|
|
21
|
-
def expect_beep
|
22
|
-
mock(
|
24
|
+
def expect_beep sh
|
25
|
+
mock(sh).print("\a"){}
|
23
26
|
end
|
24
27
|
|
25
|
-
def unexpect_beep
|
26
|
-
stub(
|
28
|
+
def unexpect_beep sh
|
29
|
+
stub(sh).print.with_any_args{ flunk }
|
27
30
|
end
|
28
31
|
|
29
32
|
describe 'beep' do
|
@@ -9,6 +9,7 @@ describe Rib::MultilineHistory do
|
|
9
9
|
|
10
10
|
def check str, err=nil
|
11
11
|
shell.history.clear
|
12
|
+
yield if block_given?
|
12
13
|
with_history(str, err)
|
13
14
|
|
14
15
|
@shell = nil
|
@@ -16,6 +17,7 @@ describe Rib::MultilineHistory do
|
|
16
17
|
|
17
18
|
shell.history.clear
|
18
19
|
shell.history << 'old history'
|
20
|
+
yield if block_given?
|
19
21
|
with_history(str, err, 'old history')
|
20
22
|
end
|
21
23
|
|
@@ -30,9 +32,7 @@ describe Rib::MultilineHistory do
|
|
30
32
|
|
31
33
|
result
|
32
34
|
}
|
33
|
-
input_done(lines.last, err)
|
34
|
-
shell.eval_binding.eval(str)
|
35
|
-
end
|
35
|
+
input_done(lines.last, err)
|
36
36
|
|
37
37
|
history = if lines.size == 1
|
38
38
|
lines.first
|
data/test/test_shell.rb
CHANGED
@@ -75,6 +75,14 @@ describe Rib::Shell do
|
|
75
75
|
input('"m" * 2')
|
76
76
|
end
|
77
77
|
|
78
|
+
%w[next break].each do |keyword|
|
79
|
+
would "handle #{keyword}" do
|
80
|
+
mock(shell).puts(matching(/^SyntaxError:/)){}
|
81
|
+
|
82
|
+
input(keyword)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
78
86
|
would 'error in print_result' do
|
79
87
|
mock(Rib).warn(matching(/Error while printing result.*BOOM/m)){}
|
80
88
|
|
@@ -167,26 +175,24 @@ describe Rib::Shell do
|
|
167
175
|
end
|
168
176
|
|
169
177
|
would 'have empty binding' do
|
170
|
-
expect(shell.eval_input('local_variables').first).empty?
|
178
|
+
expect(shell(:binding => nil).eval_input('local_variables').first).empty?
|
171
179
|
end
|
172
180
|
|
173
181
|
would 'not pollute main' do
|
174
|
-
expect(shell.eval_input('main').first).eq 'rib'
|
182
|
+
expect(shell(:binding => nil).eval_input('main').first).eq 'rib'
|
183
|
+
end
|
184
|
+
|
185
|
+
would 'be main' do
|
186
|
+
expect(shell(:binding => nil).eval_input('self.inspect').first).eq 'main'
|
175
187
|
end
|
176
188
|
|
177
189
|
would 'warn on removing main' do
|
178
|
-
TOPLEVEL_BINDING.eval
|
179
|
-
|
180
|
-
|
181
|
-
end
|
182
|
-
RUBY
|
190
|
+
mock(TOPLEVEL_BINDING.eval('singleton_class')).method_defined?(:main) do
|
191
|
+
true
|
192
|
+
end
|
183
193
|
|
184
194
|
mock(Rib).warn(is_a(String)){}
|
185
195
|
|
186
|
-
expect(shell.eval_input('main').first).eq 'rib'
|
187
|
-
end
|
188
|
-
|
189
|
-
would 'be main' do
|
190
|
-
expect(shell.eval_input('self.inspect').first).eq 'main'
|
196
|
+
expect(shell(:binding => nil).eval_input('main').first).eq 'rib'
|
191
197
|
end
|
192
198
|
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.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
|
@@ -34,8 +34,8 @@ extensions: []
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- ".gitignore"
|
37
|
+
- ".gitlab-ci.yml"
|
37
38
|
- ".gitmodules"
|
38
|
-
- ".travis.yml"
|
39
39
|
- CHANGES.md
|
40
40
|
- Gemfile
|
41
41
|
- LICENSE
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/rib/core/strip_backtrace.rb
|
66
66
|
- lib/rib/debug.rb
|
67
67
|
- lib/rib/extra/autoindent.rb
|
68
|
+
- lib/rib/extra/byebug.rb
|
68
69
|
- lib/rib/extra/hirb.rb
|
69
70
|
- lib/rib/extra/paging.rb
|
70
71
|
- lib/rib/extra/spring.rb
|
@@ -108,7 +109,7 @@ homepage: https://github.com/godfat/rib
|
|
108
109
|
licenses:
|
109
110
|
- Apache-2.0
|
110
111
|
metadata: {}
|
111
|
-
post_install_message:
|
112
|
+
post_install_message:
|
112
113
|
rdoc_options: []
|
113
114
|
require_paths:
|
114
115
|
- lib
|
@@ -123,9 +124,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
|
-
|
127
|
-
|
128
|
-
signing_key:
|
127
|
+
rubygems_version: 3.4.1
|
128
|
+
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
|
131
131
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
|
4
|
-
before_install:
|
5
|
-
- rvm get head
|
6
|
-
- rvm reload
|
7
|
-
- rvm use --install $TRAVIS_RUBY_VERSION --binary --latest
|
8
|
-
install: 'gem install bundler; bundle install --retry=3'
|
9
|
-
script: 'ruby -r bundler/setup -S rake test'
|
10
|
-
|
11
|
-
matrix:
|
12
|
-
include:
|
13
|
-
- rvm: 2.2.5
|
14
|
-
- rvm: 2.3.2
|
15
|
-
- rvm: 2.4.1
|
16
|
-
- rvm: ruby-head
|
17
|
-
- rvm: jruby-9
|
18
|
-
env: JRUBY_OPTS=--debug
|
19
|
-
- rvm: rbx
|
20
|
-
|
21
|
-
allow_failures:
|
22
|
-
- rvm: 2.4.1
|
23
|
-
- rvm: rbx
|