rib 1.5.2 → 1.5.3

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
2
  SHA1:
3
- metadata.gz: ddd655c34f6696f9ee88606efcf30acbd726ad54
4
- data.tar.gz: 46ad8ec8b715f478c0677a1a49c0190473df42df
3
+ metadata.gz: 8941437990b160e6b6a8c135d7ab7034511bb488
4
+ data.tar.gz: 269903601d0ea5f052153e4dc0ad921d15c7b111
5
5
  SHA512:
6
- metadata.gz: ba6586bba0c20fb2cfdb1a731d67824a1f43f9fe1d240b7764ab8de50394e0c4c595799cad527cdd80ecc1201203c4f3acd286736aac2e87dda1c71659b6363e
7
- data.tar.gz: '080e885ebd7e6a8e5be217e985ff5efa40631b4847a15b887aea158f43ef1b1a66d43b96538d36abb642f69537045f2704b71899b37eb43ffa2bfd005caff6ca'
6
+ metadata.gz: 101ab01ecca0dfc75ab09412b58d199e64a2641c92f2c1bc1b6a42f260d364ef81e409e2f34738d9fd10ac53999d241100e23282f7ee01776d7191b0d22165a4
7
+ data.tar.gz: e3298bcdcec51701c6fb2e4c15cdbc924830679f9e71744c2c9b1c23bac71817f9ba14c50962ffc190188657a0983ce65d349bad6187dbec0d9d6c1aa0156922
@@ -13,9 +13,11 @@ matrix:
13
13
  - rvm: 2.2.5
14
14
  - rvm: 2.3.2
15
15
  - rvm: 2.4.1
16
+ - rvm: ruby-head
16
17
  - rvm: jruby-9
17
18
  env: JRUBY_OPTS=--debug
18
19
  - rvm: rbx
19
20
 
20
21
  allow_failures:
21
- - rvm: rbx
22
+ - rvm: 2.4.1
23
+ - rvm: rbx
data/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.5.3 -- 2017-08-05
4
+
5
+ * Now we set trap only when the shell starts, and restore the old trap
6
+ after the shell stops. This should fix some problems using anchor inside
7
+ RSpec or Unicorn. They would no longer interfere with them.
8
+ * [core/multiline] Now we support backslash. See:
9
+ [Using backslash line continuation character results in syntax error](https://github.com/godfat/rib/issues/15)
10
+
3
11
  ## Rib 1.5.2 -- 2017-05-01
4
12
 
5
13
  * We now `require 'rib/version'` from the beginning, avoid loading error
@@ -81,7 +81,11 @@ module Rib; module Multiline
81
81
  def loop_eval input
82
82
  return super if Multiline.disabled?
83
83
  multiline_buffer << input
84
- super(multiline_buffer.join("\n"))
84
+ if input =~ /\\\z/
85
+ throw :rib_multiline
86
+ else
87
+ super(multiline_buffer.join("\n"))
88
+ end
85
89
  end
86
90
 
87
91
  def print_eval_error err
@@ -4,7 +4,6 @@ require 'rib/api'
4
4
 
5
5
  module Rib; class Shell
6
6
  include API
7
- trap('INT'){ raise Interrupt }
8
7
 
9
8
  def self.use mod
10
9
  include mod
@@ -47,6 +46,7 @@ module Rib; class Shell
47
46
  # Loops shell until user exits
48
47
  def loop
49
48
  before_loop
49
+ set_trap
50
50
  start
51
51
  in_loop
52
52
  stop
@@ -55,7 +55,7 @@ module Rib; class Shell
55
55
  Rib.warn("Error while running loop:\n #{format_error(e)}")
56
56
  raise
57
57
  ensure
58
-
58
+ release_trap
59
59
  after_loop
60
60
  end
61
61
 
@@ -78,6 +78,14 @@ module Rib; class Shell
78
78
  protected
79
79
  attr_writer :config
80
80
 
81
+ def set_trap
82
+ @trap_proc = trap('INT'){ raise Interrupt }
83
+ end
84
+
85
+ def release_trap
86
+ trap('INT', &@trap_proc) if @trap_proc.kind_of?(Proc)
87
+ end
88
+
81
89
  private
82
90
  # Avoid namespace pollution from rubygems bin stub.
83
91
  # To be specific, version and str.
@@ -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(is_a(Object)){}
21
+ mock(shell).print_result(yield){}
22
22
  end
23
23
  shell.loop_once
24
24
  ok
@@ -30,7 +30,9 @@ copy :setup_multiline do
30
30
  input(line)
31
31
  shell.loop_once
32
32
  }
33
- input_done(lines.last, err)
33
+ input_done(lines.last, err) do
34
+ shell.eval_binding.eval(str)
35
+ end
34
36
  end
35
37
  end
36
38
 
@@ -41,7 +43,7 @@ copy :multiline do
41
43
 
42
44
  would 'work with no prompt' do
43
45
  shell.config[:prompt] = ''
44
- check <<-RUBY
46
+ check <<~RUBY
45
47
  def f
46
48
  0
47
49
  end
@@ -49,7 +51,7 @@ copy :multiline do
49
51
  end
50
52
 
51
53
  would 'def f' do
52
- check <<-RUBY
54
+ check <<~RUBY
53
55
  def f
54
56
  1
55
57
  end
@@ -57,21 +59,21 @@ copy :multiline do
57
59
  end
58
60
 
59
61
  would 'class C' do
60
- check <<-RUBY
62
+ check <<~RUBY
61
63
  class C
62
64
  end
63
65
  RUBY
64
66
  end
65
67
 
66
68
  would 'begin' do
67
- check <<-RUBY
69
+ check <<~RUBY
68
70
  begin
69
71
  end
70
72
  RUBY
71
73
  end
72
74
 
73
75
  would 'begin with RuntimeError' do
74
- check <<-RUBY, RuntimeError
76
+ check <<~RUBY, RuntimeError
75
77
  begin
76
78
  raise 'multiline raised an error'
77
79
  end
@@ -79,120 +81,127 @@ copy :multiline do
79
81
  end
80
82
 
81
83
  would 'do end' do
82
- check <<-RUBY
84
+ check <<~RUBY
83
85
  [].each do
84
86
  end
85
87
  RUBY
86
88
  end
87
89
 
88
90
  would 'block brace' do
89
- check <<-RUBY
91
+ check <<~RUBY
90
92
  [].each{
91
93
  }
92
94
  RUBY
93
95
  end
94
96
 
95
97
  would 'hash' do
96
- check <<-RUBY
98
+ check <<~RUBY
97
99
  {
98
100
  }
99
101
  RUBY
100
102
  end
101
103
 
102
104
  would 'hash value' do
103
- check <<-RUBY
105
+ check <<~RUBY
104
106
  {1 =>
105
107
  2}
106
108
  RUBY
107
109
  end
108
110
 
109
111
  would 'array' do
110
- check <<-RUBY
112
+ check <<~RUBY
111
113
  [
112
114
  ]
113
115
  RUBY
114
116
  end
115
117
 
116
118
  would 'group' do
117
- check <<-RUBY
119
+ check <<~RUBY
118
120
  (
119
121
  )
120
122
  RUBY
121
123
  end
122
124
 
123
125
  would 'string double quote' do
124
- check <<-RUBY
126
+ check <<~RUBY
125
127
  "
126
128
  "
127
129
  RUBY
128
130
  end
129
131
 
130
132
  would 'string single quote' do
131
- check <<-RUBY
133
+ check <<~RUBY
132
134
  '
133
135
  '
134
136
  RUBY
135
137
  end
136
138
 
137
139
  would 'be hash treated as a block SyntaxError' do
138
- check <<-RUBY, SyntaxError
140
+ check <<~RUBY, SyntaxError
139
141
  puts { :x => 10 }.class
140
142
  RUBY
141
143
  end
142
144
 
143
145
  would 'begin with SyntaxError' do
144
- check <<-RUBY, SyntaxError
146
+ check <<~RUBY, SyntaxError
145
147
  begin
146
148
  s-y n
147
149
  RUBY
148
150
  end
149
151
 
150
152
  would 'binary operator +' do
151
- check <<-RUBY
153
+ check <<~RUBY
152
154
  1/1.to_i +
153
155
  1
154
156
  RUBY
155
157
  end
156
158
 
157
159
  would 'binary operator -' do
158
- check <<-RUBY
160
+ check <<~RUBY
159
161
  1*1.to_i -
160
162
  1
161
163
  RUBY
162
164
  end
163
165
 
164
166
  would 'binary operator *' do
165
- check <<-RUBY
167
+ check <<~RUBY
166
168
  1-1.to_i *
167
169
  1
168
170
  RUBY
169
171
  end
170
172
 
171
173
  would 'binary operator /' do
172
- check <<-RUBY
174
+ check <<~RUBY
173
175
  1+1.to_i /
174
176
  1
175
177
  RUBY
176
178
  end
177
179
 
178
180
  would 'binary operator |' do
179
- check <<-RUBY
181
+ check <<~RUBY
180
182
  1+1.to_i |
181
183
  1
182
184
  RUBY
183
185
  end
184
186
 
185
187
  would 'binary operator &' do
186
- check <<-RUBY
188
+ check <<~RUBY
187
189
  1+1.to_i &
188
190
  1
189
191
  RUBY
190
192
  end
191
193
 
192
194
  would 'binary operator ^' do
193
- check <<-RUBY
195
+ check <<~RUBY
194
196
  1+1.to_i ^
195
197
  1
196
198
  RUBY
197
199
  end
200
+
201
+ would 'backslash at the end' do
202
+ check <<~RUBY
203
+ 'nice ' \\
204
+ 'shell'
205
+ RUBY
206
+ end
198
207
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.5.2'
3
+ VERSION = '1.5.3'
4
4
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rib 1.5.2 ruby lib
2
+ # stub: rib 1.5.3 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rib".freeze
6
- s.version = "1.5.2"
6
+ s.version = "1.5.3"
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-05-01"
11
+ s.date = "2017-08-05"
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 = [
@@ -92,7 +92,7 @@ Gem::Specification.new do |s|
92
92
  "test/test_shell.rb".freeze]
93
93
  s.homepage = "https://github.com/godfat/rib".freeze
94
94
  s.licenses = ["Apache-2.0".freeze]
95
- s.rubygems_version = "2.6.10".freeze
95
+ s.rubygems_version = "2.6.12".freeze
96
96
  s.summary = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell".freeze
97
97
  s.test_files = [
98
98
  "test/core/test_completion.rb".freeze,
@@ -30,7 +30,9 @@ describe Rib::MultilineHistory do
30
30
 
31
31
  result
32
32
  }
33
- input_done(lines.last, err)
33
+ input_done(lines.last, err) do
34
+ shell.eval_binding.eval(str)
35
+ end
34
36
 
35
37
  history = if lines.size == 1
36
38
  lines.first
@@ -6,8 +6,8 @@ describe Rib::Shell do
6
6
  paste :rib
7
7
 
8
8
  describe '#loop' do
9
- def input str
10
- mock(shell).get_input{str}
9
+ def input str=Rib::Skip
10
+ mock(shell).get_input{if block_given? then yield else str end}
11
11
  shell.loop
12
12
  ok
13
13
  end
@@ -25,6 +25,29 @@ describe Rib::Shell do
25
25
 
26
26
  input('@shell.stop; throw :rib_exit')
27
27
  end
28
+
29
+ describe 'trap' do
30
+ before do
31
+ @token = Class.new(Exception)
32
+ @old_trap = trap('INT'){ raise @token }
33
+ mock(shell).handle_interrupt{ mock(shell).get_input{'exit'} }
34
+ end
35
+
36
+ after do
37
+ trap('INT', &@old_trap)
38
+ end
39
+
40
+ def interrupt
41
+ Process.kill('SIGINT', Process.pid)
42
+ sleep
43
+ end
44
+
45
+ would 'fence and restore ctrl+c interruption' do
46
+ input{ interrupt }
47
+
48
+ expect.raise(@token){ interrupt }
49
+ end
50
+ end
28
51
  end
29
52
 
30
53
  describe '#loop_once' do
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.2
4
+ version: 1.5.3
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-05-01 00:00:00.000000000 Z
11
+ date: 2017-08-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.6.10
127
+ rubygems_version: 2.6.12
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell