rib 1.5.4 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5eff854fa46370d04aaf74853a185f40736e15d5
4
- data.tar.gz: be5170caaaf53d847c0f04123f5df93bed5f1242
2
+ SHA256:
3
+ metadata.gz: 7f537a283fed2eef2c6e07ede1e4cc027dc28f4a4f3d4c59cee58338b02cad9c
4
+ data.tar.gz: c25ade3869c7319ce557c1ab50d7029126af6d171fc892d0032a259c848efa97
5
5
  SHA512:
6
- metadata.gz: 4c4c343ea687a0b0e6faa6ae43e807c03c00037562868b5319a72996ecaeb10968ac16094262839a864d78912b7af679c0e76eaff446b3d45a48eb14dda1e139
7
- data.tar.gz: df8b8f84111fa7296be539be5fcc0397802507897eec7fe84acef900826fcf2fe30e122c9e5347078f822b2b922cc01bd0ccdcb24e78f5992e8f9ee1efcd2362
6
+ metadata.gz: eba78ab629e758e66963db826cd39a2b9ec7b392c4b451f26ab680ab9924a7d3748f9d1ddd9966f2296f5e5aef0ac30cd389d2449505f55f1662b43a1fb3605e
7
+ data.tar.gz: f35eac4d8ed09a0e6ab1dc21a63ed1aea6fde118f110adf280044cbf3fb39a1ce748a77f558fe4d7115ec7b519428cefb28c11ad31b655794529ad3b89758d56
@@ -1,23 +1,17 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
 
4
- before_install:
5
- - rvm get head
6
- - rvm reload
7
- - rvm use --install $TRAVIS_RUBY_VERSION --binary --latest
8
4
  install: 'gem install bundler; bundle install --retry=3'
9
- script: 'ruby -r bundler/setup -S rake test'
5
+ before_script: unset CI
6
+ script: 'ruby -vr bundler/setup -S rake test'
10
7
 
11
8
  matrix:
12
9
  include:
13
- - rvm: 2.2.5
14
- - rvm: 2.3.2
15
- - rvm: 2.4.1
10
+ - rvm: 2.4
11
+ env: RUBYOPT=--enable-frozen-string-literal
12
+ - rvm: 2.5
13
+ env: RUBYOPT=--enable-frozen-string-literal
16
14
  - rvm: ruby-head
17
- - rvm: jruby-9
15
+ env: RUBYOPT=--enable-frozen-string-literal
16
+ - rvm: jruby
18
17
  env: JRUBY_OPTS=--debug
19
- - rvm: rbx
20
-
21
- allow_failures:
22
- - rvm: 2.4.1
23
- - rvm: rbx
data/CHANGES.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.6.0 -- 2018-06-20
4
+
5
+ * [core/multiline] Support for JRuby 9.2.0.0 is fixed
6
+ * [more/beep] It would now beep every single time when any evaluation took
7
+ longer than the threshold.
8
+ * [more/color] Fix whenever the input is just `next` or `break`
9
+ * [more/bottomup_backtrace] This would no longer format backtrace twice
10
+ * [more/caller] It would now properly use the enabled plugins
11
+ * [extra/autoindent] It would now indent with `ensure` for `begin` and `def`.
12
+ Thanks @MITSUBOSHI https://github.com/godfat/rib/pull/21 and
13
+ @alpaca-tc https://github.com/godfat/rib/pull/17
14
+ * [extra/autoindent] It would now indent with `for`.
15
+ Thanks @MITSUBOSHI https://github.com/godfat/rib/pull/18
16
+ * [extra/autoindent] It would now indent with `()` and `[]`.
17
+ Thanks @MITSUBOSHI https://github.com/godfat/rib/pull/20 and
18
+ https://github.com/godfat/rib/pull/19
19
+ * [extra/byebug] This is now work-in-progress.
20
+
3
21
  ## Rib 1.5.4 -- 2017-10-23
4
22
 
5
23
  * Removed unnecessary method definition for `puts`
data/Gemfile CHANGED
@@ -16,8 +16,3 @@ gem 'coveralls', :require => false if ENV['CI']
16
16
  platforms :ruby do
17
17
  gem 'readline_buffer'
18
18
  end
19
-
20
- platforms :rbx do
21
- gem 'rubysl-singleton' # used in rake
22
- gem 'rubysl-readline' # we need readline extension
23
- end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rib [![Build Status](https://secure.travis-ci.org/godfat/rib.png?branch=master)](http://travis-ci.org/godfat/rib) [![Coverage Status](https://coveralls.io/repos/github/godfat/rib/badge.png)](https://coveralls.io/github/godfat/rib) [![Join the chat at https://gitter.im/godfat/rib](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/godfat/rib)
1
+ # Rib [![Build Status](https://secure.travis-ci.org/godfat/rib.svg?branch=master)](http://travis-ci.org/godfat/rib) [![Coverage Status](https://coveralls.io/repos/github/godfat/rib/badge.svg)](https://coveralls.io/github/godfat/rib) [![Join the chat at https://gitter.im/godfat/rib](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/godfat/rib)
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), Rubinius and JRuby.
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-2017, Lin Jen-Shin (godfat)
482
+ Copyright (c) 2011-2018, 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.
@@ -83,6 +83,10 @@ module Rib; module API
83
83
  end
84
84
  end
85
85
 
86
+ def puts str=''
87
+ super
88
+ end
89
+
86
90
  # Print result using #format_result
87
91
  def print_result result
88
92
  puts(format_result(result))
@@ -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" ].join('|'))
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 ---------------
@@ -24,7 +24,11 @@ module Rib; module Autoindent
24
24
  # rescue E => e
25
25
  # rescue E=> e
26
26
  # rescue E =>e
27
- /^begin$/ => /^(end)\b|^else$|^rescue *((\w+)? *(=> *\w+)?)?$/,
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,100 @@
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
+ module Imp
12
+ def byebug
13
+ return if Rib::Byebug.disabled?
14
+
15
+ ::Byebug::RibProcessor.start
16
+ end
17
+
18
+ def location
19
+ Rib.shell.config[:byebug].location
20
+ end
21
+
22
+ def step times=1
23
+ throw :rib_byebug, [:step, times]
24
+ end
25
+
26
+ def next lines=1
27
+ throw :rib_byebug, [:next, lines]
28
+ end
29
+
30
+ def finish
31
+ throw :rib_byebug, [:finish]
32
+ end
33
+ end
34
+
35
+ Rib.extend(Imp)
36
+ end; end
37
+
38
+ module Byebug
39
+ class RibProcessor < CommandProcessor
40
+ def self.start
41
+ Byebug.start
42
+ Setting[:autolist] = false
43
+ Context.processor = self
44
+ steps = caller.index{ |path| !path.start_with?(__FILE__) }
45
+ Byebug.current_context.step_out(steps + 2, true)
46
+ end
47
+
48
+ def at_line
49
+ resume_rib
50
+ end
51
+
52
+ def at_return(_return_value)
53
+ resume_rib
54
+ end
55
+
56
+ def at_end
57
+ resume_rib
58
+ end
59
+
60
+ def at_breakpoint(breakpoint)
61
+ raise NotImplementedError
62
+ end
63
+
64
+ def location
65
+ context.location
66
+ end
67
+
68
+ private
69
+
70
+ def print_location
71
+ shell = Rib.shell
72
+ shell.puts(shell.format_backtrace([location]).first)
73
+ end
74
+
75
+ def resume_rib
76
+ byebug_binding = frame._binding
77
+
78
+ print_location
79
+
80
+ action, *args = catch(:rib_byebug) do
81
+ allowing_other_threads do
82
+ Rib.anchor byebug_binding, :byebug => self
83
+ end
84
+ end
85
+
86
+ perform(action, args)
87
+ end
88
+
89
+ def perform action, args
90
+ case action
91
+ when :step
92
+ context.step_into(*args, frame.pos)
93
+ when :next
94
+ context.step_over(*args, frame.pos)
95
+ when :finish
96
+ context.step_out(1)
97
+ end
98
+ end
99
+ end
100
+ end
@@ -7,12 +7,11 @@ module Rib; module Beep
7
7
 
8
8
  # --------------- Rib API ---------------
9
9
 
10
- def before_loop
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
- Beep.disable
15
- self
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
- " #{format_backtrace(backtrace).join("\n ")}\n#{message}"
13
+ " #{backtrace.join("\n ")}\n#{message}"
14
14
  end
15
15
 
16
16
  def format_backtrace backtrace
@@ -9,7 +9,11 @@ module Rib; module Caller
9
9
  def caller *filters
10
10
  return if Rib::Caller.disabled?
11
11
 
12
- backtrace = Rib.shell.format_backtrace(super().drop(1))
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
@@ -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), format_backtrace(backtrace)]
23
+ [format_color(err, message), backtrace]
24
24
  end
25
25
 
26
26
  def warn message
@@ -87,7 +87,8 @@ module Rib; module Color
87
87
  backtrace.map{ |b|
88
88
  path, msgs = b.split(':', 2)
89
89
  dir, sep, file = path.rpartition('/')
90
- msg = msgs.sub(/(\d+):/){red{$1}+':'}.sub(/`.+?'/){green{$&}}
90
+ msgs ||= (line - 1).to_s # msgs would be nil when input is next/break
91
+ msg = msgs.sub(/(\d+)(:?)/){red{$1}+$2}.sub(/`.+?'/){green{$&}}
91
92
 
92
93
  "#{dir+sep}#{yellow{file}}:#{msg}"
93
94
  }
@@ -20,14 +20,17 @@ copy :rib do
20
20
  end
21
21
 
22
22
  def new_shell opts={}
23
- shell = Rib::Shell.new(opts)
24
- yield(shell) if block_given?
25
- shell.before_loop
23
+ result = Rib::Shell.new(
24
+ {:binding => Object.new.instance_eval{binding}}.
25
+ merge(opts))
26
+ yield(result) if block_given?
27
+ result.before_loop
26
28
  end
27
29
 
28
30
  def stub_output
29
31
  stub(shell).print(is_a(String)){}
30
32
  stub(shell).puts(is_a(String)){}
33
+ stub(shell).puts{}
31
34
  end
32
35
 
33
36
  def readline?
@@ -51,9 +54,10 @@ copy :rib do
51
54
  Rib.disable_plugins(rest)
52
55
  end
53
56
 
54
- yield
57
+ describe "enabling #{plugins}" do
58
+ block.call
55
59
 
56
- case ENV['TEST_LEVEL']
60
+ case ENV['TEST_LEVEL']
57
61
  when '0'
58
62
  when '1'
59
63
  test_level1(rest, block)
@@ -63,13 +67,18 @@ copy :rib do
63
67
  test_level3(rest, block)
64
68
  else # test_level3 is too slow because of rr (i guess)
65
69
  test_level2(rest, block)
70
+ end
66
71
  end
67
72
  end
68
73
 
69
74
  def test_level1 rest, block
70
75
  rest.each{ |target|
71
76
  target.enable
72
- block.call
77
+
78
+ describe "also enabling #{target}" do
79
+ block.call
80
+ end
81
+
73
82
  target.disable
74
83
  }
75
84
  end
@@ -77,17 +86,31 @@ copy :rib do
77
86
  def test_level2 rest, block
78
87
  rest.combination(2).each{ |targets|
79
88
  Rib.enable_plugins(targets)
80
- block.call
89
+
90
+ describe "also enabling #{targets.join(', ')}" do
91
+ block.call
92
+ end
93
+
81
94
  Rib.disable_plugins(targets)
82
95
  }
83
96
  end
84
97
 
85
98
  def test_level3 rest, block
86
- return block.call if rest.empty?
87
- rest[0].enable
88
- test_level3(rest[1..-1], block)
89
- rest[0].disable
90
- test_level3(rest[1..-1], block)
99
+ if rest.empty?
100
+ block.call
101
+ else
102
+ rest[0].enable
103
+
104
+ describe "also enabling #{rest[0]}" do
105
+ test_level3(rest[1..-1], block)
106
+ end
107
+
108
+ rest[0].disable
109
+
110
+ describe "disabling #{rest[0]}" do
111
+ test_level3(rest[1..-1], block)
112
+ end
113
+ end
91
114
  end
92
115
  end
93
116
  end
@@ -18,7 +18,7 @@ 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(yield){}
21
+ mock(shell).print_result(is_a(Object)){}
22
22
  end
23
23
  shell.loop_once
24
24
  ok
@@ -30,17 +30,15 @@ copy :setup_multiline do
30
30
  input(line)
31
31
  shell.loop_once
32
32
  }
33
- input_done(lines.last, err) do
34
- shell.eval_binding.eval(str)
35
- end
33
+ input_done(lines.last, err)
36
34
  end
37
- end
38
35
 
39
- copy :multiline do
40
36
  before do
41
37
  stub_output
42
38
  end
39
+ end
43
40
 
41
+ copy :multiline do
44
42
  would 'work with no prompt' do
45
43
  shell.config[:prompt] = ''
46
44
  check <<~RUBY
@@ -142,6 +140,12 @@ copy :multiline do
142
140
  RUBY
143
141
  end
144
142
 
143
+ would 'SyntaxError' do
144
+ check <<~RUBY, SyntaxError
145
+ s-y n
146
+ RUBY
147
+ end
148
+
145
149
  would 'begin with SyntaxError' do
146
150
  check <<~RUBY, SyntaxError
147
151
  begin
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.5.4'
3
+ VERSION = '1.6.0'
4
4
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rib 1.5.4 ruby lib
2
+ # stub: rib 1.6.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rib".freeze
6
- s.version = "1.5.4"
6
+ s.version = "1.6.0"
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 = "2017-10-23"
11
+ s.date = "2018-06-20"
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 = [
@@ -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 = "2.6.13".freeze
96
+ s.rubygems_version = "2.7.7".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,
@@ -5,10 +5,9 @@ require 'rib/core/history'
5
5
 
6
6
  describe Rib::History do
7
7
  paste :rib
8
+ paste :setup_history
8
9
 
9
10
  test_for Rib::History do
10
- paste :setup_history
11
-
12
11
  would '#after_loop save history' do
13
12
  inputs = %w[blih blah]
14
13
  shell.history.push(*inputs)
@@ -5,10 +5,9 @@ require 'rib/core/squeeze_history'
5
5
 
6
6
  describe Rib::SqueezeHistory do
7
7
  paste :rib
8
+ paste :setup_history
8
9
 
9
10
  test_for Rib::History, Rib::SqueezeHistory do
10
- paste :setup_history
11
-
12
11
  before do
13
12
  @input = %w[foo bar bar foo bar]
14
13
  end
@@ -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
@@ -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
- new_shell(:started_at => Time.now - delay,
18
- :beep_threshold => threshold, &block)
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 shell
22
- mock(shell).print("\a"){}
24
+ def expect_beep sh
25
+ mock(sh).print("\a"){}
23
26
  end
24
27
 
25
- def unexpect_beep shell
26
- stub(shell).print.with_any_args{ flunk }
28
+ def unexpect_beep sh
29
+ stub(sh).print.with_any_args{ flunk }
27
30
  end
28
31
 
29
32
  describe 'beep' do
@@ -30,9 +30,7 @@ describe Rib::MultilineHistory do
30
30
 
31
31
  result
32
32
  }
33
- input_done(lines.last, err) do
34
- shell.eval_binding.eval(str)
35
- end
33
+ input_done(lines.last, err)
36
34
 
37
35
  history = if lines.size == 1
38
36
  lines.first
@@ -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 <<-RUBY
179
- singleton_class.module_eval do
180
- def main; end
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.5.4
4
+ version: 1.6.0
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: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2018-06-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -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
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  version: '0'
125
126
  requirements: []
126
127
  rubyforge_project:
127
- rubygems_version: 2.6.13
128
+ rubygems_version: 2.7.7
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell