intar 2.14 → 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: dfabe8ba50f5502971175b8ec48582e1c24d68b75cf164ed10b7b1545b8ed1ec
4
- data.tar.gz: 376905c4c3f81b252662f6df9803ad8bd9038475c8ccc5c9adc6f79239f5c3c8
3
+ metadata.gz: 1e871a9a15a8e544e9e88d5cb06bf2b0ec3b38f75ae6a5396aabd02ed72d9d9e
4
+ data.tar.gz: e3955b86060800a5699d7098579ee1474181374012a94bee25109707c7aa126f
5
5
  SHA512:
6
- metadata.gz: 9cf36852e6c4387d6eb85ac8b9dafaced557033bc7be3004eae58ea22529155d08cd7e213d9cfb5a3f630e8ac84b04113e35d39a5f811388c1dcc339b56fc9b0
7
- data.tar.gz: 156c61b56e014f810f45da42a7500a9ce6b5f937b090eb3d2f6e591c786441b0f51ffb0c5c353ba56e7ece4d9205546f6a9fad48d3bda726b6b6970f2e5ac102
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.14".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.14'
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