intar 2.15 → 2.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README +9 -7
  3. data/bin/intar +1 -0
  4. data/lib/intar/version.rb +1 -1
  5. data/lib/intar.rb +29 -11
  6. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33d3b8a846784d28dd22d4d7b2bc8ae58885e80581457b5de57974db4bb86967
4
- data.tar.gz: 7ce97b2ca8e36d0eb8ba68ce289c36e9de94f7a479c6b4ed24f6529030d621a9
3
+ metadata.gz: 1e871a9a15a8e544e9e88d5cb06bf2b0ec3b38f75ae6a5396aabd02ed72d9d9e
4
+ data.tar.gz: e3955b86060800a5699d7098579ee1474181374012a94bee25109707c7aa126f
5
5
  SHA512:
6
- metadata.gz: ba549858060a566243199d3404a5231e1496ace0fd5f2ffa0336d55b4bf528a355ea78c0294de80027bf243a4d0c0f4c25159caa942f0d9db1fae1a2b10bce22
7
- data.tar.gz: 827d0d193fcdf092e3b5c79b0e67dca0763e1ee46f34cd70f70a0921d117729191017895219eaf2ce93a5e0a2144172f2bbcaeff221314b45a1dd7ae2856b4bf
6
+ metadata.gz: 85fdba632254cdc85eb3cd6ba2789abc842e4301ac491bcede18e1a658d9d8c797e7def229477fd452156a224964959b8e004fd576a50ced30042c1fe5723846
7
+ data.tar.gz: b5a6dfd709c9567ef7f94d317ff7e0ac3babddc9b654e1e85435881299e31296a8b10b46de1e18f992da65fa65c02d91be1da1ee26261fdbbaa891f958ebe6c2
data/README CHANGED
@@ -23,15 +23,17 @@ after this in Irb and in Intar:
23
23
 
24
24
  === Subcommands
25
25
 
26
- obj.method +> enter a sub-Intar
27
- obj.each +> enter multiple sub-Intars
28
- obj.method +>x enter a sub-Intar with variable x
26
+ obj.method do & enter a sub-Intar
27
+ obj.method { & enter a sub-Intar
28
+ obj.each { & enter multiple sub-Intars
29
+ obj.method { |x| & enter a sub-Intar with variable x
30
+ obj.method { |x,y| & enter a sub-Intar with multiple variables
29
31
 
30
- \q exit from the innermost sub-Intar
31
- \q! exit from the innermost sub-Intar loop
32
- \q!! exit from all levels
32
+ \q exit from the innermost sub-Intar
33
+ \q! exit from the innermost sub-Intar loop
34
+ \q!! exit from all levels
33
35
 
34
- \h get a list of all subcommands
36
+ \h get a list of all subcommands
35
37
 
36
38
 
37
39
 
data/bin/intar CHANGED
@@ -4,6 +4,7 @@
4
4
  # intar -- Interactive Ruby evaluation
5
5
  #
6
6
 
7
+ puts TOPLEVEL_BINDING.local_variables.inspect
7
8
  require "intar"
8
9
  require "appl"
9
10
 
data/lib/intar/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  class Intar
6
6
 
7
- VERSION = "2.15".freeze
7
+ VERSION = "2.16".freeze
8
8
 
9
9
  end
10
10
 
data/lib/intar.rb CHANGED
@@ -116,6 +116,7 @@ class Intar
116
116
  handle_history do
117
117
  set_current do
118
118
  execute OLD_INIT
119
+ r = nil
119
120
  loop do
120
121
  l = readline
121
122
  l or break
@@ -150,6 +151,7 @@ class Intar
150
151
  (execute OLD_SET).call r, @n
151
152
  @n += 1
152
153
  end
154
+ r
153
155
  ensure
154
156
  execute OLD_INIT
155
157
  end
@@ -168,19 +170,35 @@ class Intar
168
170
  private
169
171
 
170
172
  def eval_line l
171
- ls = l.sub %r/\s+\+>(\w+)?\s*\z/ do
172
- <<~EOT
173
- \ do |obj|
174
- Intar.open #{$1 ? "self" : "obj"} do |i|
175
- #{"# " unless $1}i.set_var "#$1", obj
176
- i.run
177
- end
178
- rescue Intar::Break
179
- break
173
+ if l =~ %r/\s*(?:\{|\bdo)\s*(?:\|([a-z0-9_,]*)\|)?\s*&\z/ then
174
+ cmd = $`
175
+ argl = $1
176
+ if argl.notempty? then
177
+ s = (argl.split ",").map { |a|
178
+ break unless a =~ /\A[a-z][a-z0-9_]*\z/
179
+ %Q((_i.set_var "#{a}", #{a}))
180
+ }
181
+ if s then
182
+ sets = s.join "; "
183
+ iobj = "self"
180
184
  end
181
- EOT
185
+ else
186
+ argl = iobj = "obj"
187
+ end
188
+ if iobj then
189
+ l = cmd + <<~EOT
190
+ \ do |#{argl}|
191
+ Intar.open #{iobj} do |_i|
192
+ #{sets}
193
+ _i.run
194
+ end
195
+ rescue Intar::Break
196
+ break
197
+ end
198
+ EOT
199
+ end
182
200
  end
183
- @redir.redirect_output do execute ls end
201
+ @redir.redirect_output do execute l end
184
202
  end
185
203
 
186
204
  def handle_history
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intar
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.15'
4
+ version: '2.16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-19 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appl
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements:
90
90
  - Ruby and some small Gems; Readline
91
- rubygems_version: 3.4.20
91
+ rubygems_version: 3.4.22
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Interactive Ruby