intar 2.7 → 2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/intar/version.rb +1 -1
  3. data/lib/intar.rb +30 -9
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ba7f7b2c3052c0627cd7126fedc64e45e443b2652670a6f15b3a408f729d5dd
4
- data.tar.gz: efd64593e9f9e6d4fda22a426f9b5a7c3be1860594a3d31e66d383e033b55110
3
+ metadata.gz: 84d165f1b9d58c19bbd9080263260ccb87c5f583bd05e9ad6045d7dab9a12c70
4
+ data.tar.gz: 5efa92e7ae496464fb5344cdc1c35d94eb5ab1b4812a4b650996738bc16f5659
5
5
  SHA512:
6
- metadata.gz: 1cf5dedde06257a25c4a0080c98f11f8a1735194c32cc279ce871a4d98d56685ee240d1316494c4f825af0f8a5886cbbdaba868912c376df2cb30f604e91911c
7
- data.tar.gz: 831ce595c01ec5fe97832a2699d2a866d0af6bfec61598cf45b217652f0135cec5867fe510a15b50e506f9b475a4ad0a5ffdb8404e2f031098c377b669b9bc8d
6
+ metadata.gz: 6081809067ded417b3231e89810a4a2ae84bfd0146d9e9298f7f5b93e768639a48a9403e817ee78b0f89516fe21565a3b019d422c2466df94ff013c9d0ae7f05
7
+ data.tar.gz: cfe779bd9c642e2703315f12b219f73b5101f3095797968aa03e5fd5fb9657765a1cacbcbb499bb4d1c3bcdaa3d99c58b46d05bd11677b147be66f300890099f
data/lib/intar/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  class Intar
6
6
 
7
- VERSION = "2.7".freeze
7
+ VERSION = "2.9".freeze
8
8
 
9
9
  end
10
10
 
data/lib/intar.rb CHANGED
@@ -94,6 +94,7 @@ class Intar
94
94
  end
95
95
 
96
96
 
97
+ class Clear < Exception ; end
97
98
  class Quit < Exception ; end
98
99
  class Bye < Quit ; end
99
100
  class Break < Bye ; end
@@ -107,19 +108,23 @@ class Intar
107
108
  l = readline
108
109
  l or break
109
110
  @redir = find_redirect l
110
- r = begin
111
- if l =~ /\A\\(\w+|.)\s*(.*?)\s*\Z/ then
112
- send (get_metacommand $1).method, (eval_param $2)
111
+ begin
112
+ if l.slice! /^\\(\w+|.)\s*(.*?)\s*$\n?/ then
113
+ r = send (get_metacommand $1).method, (eval_param $2)
114
+ l.empty? or @previous = l
113
115
  else
114
- l.sub! %r/\s*&\s*\z/, SUB
115
116
  begin
116
- @redir.redirect_output do eval l, @binding, @file end
117
+ r = eval_line l
117
118
  rescue SyntaxError
118
119
  raise if l.end_with? $/
119
120
  @previous = l
120
- next
121
121
  end
122
122
  end
123
+ next if @previous
124
+ display r
125
+ rescue Clear
126
+ @previous = nil
127
+ next
123
128
  rescue Bye
124
129
  raise if @depth.nonzero?
125
130
  break
@@ -127,10 +132,9 @@ class Intar
127
132
  break
128
133
  rescue Exception
129
134
  break if SystemExit === $! and not @params[ :catch_exit]
135
+ r = $!
130
136
  show_exception
131
- $!
132
137
  end
133
- display r
134
138
  oldset.call r, @n
135
139
  @n += 1
136
140
  end
@@ -145,6 +149,11 @@ class Intar
145
149
 
146
150
  private
147
151
 
152
+ def eval_line l
153
+ ls = l.sub %r/\s*&\s*\z/, SUB
154
+ @redir.redirect_output do eval ls, @binding, @file end
155
+ end
156
+
148
157
  def handle_history
149
158
  unless @depth.nonzero? then
150
159
  begin
@@ -370,7 +379,7 @@ class Intar
370
379
  puts "Metacommand: #{names.join ' '}"
371
380
  puts "Summary: #{mc.summary}"
372
381
  puts "Description:"
373
- puts mc.description
382
+ mc.description.each_line { |l| print " " ; puts l }
374
383
  else
375
384
  l = cmds_list.map { |k,v| [v,k] }
376
385
  puts "Metacommands:"
@@ -401,12 +410,24 @@ class Intar
401
410
 
402
411
  metacmd %w(q x quit exit), "Quit Intar", <<~EOT
403
412
  Leave Intar.
413
+
414
+ plain quit current Intar level
415
+ ! quit current loop
416
+ !! quit all levels
404
417
  EOT
405
418
  def cmd_quit x
406
419
  lx = $&.length.nonzero? if x =~ /!*/
407
420
  raise lx ? (lx > 1 ? Bye : Break) : Quit
408
421
  end
409
422
 
423
+ metacmd %w(c clear), "Clear command line", <<~EOT
424
+ Use this if a statement cannot be successfully ended,
425
+ i. e. when there is no other way to leave the dot prompt.
426
+ EOT
427
+ def cmd_clear x
428
+ raise Clear
429
+ end
430
+
410
431
  metacmd %w(cd), "Change directory", <<~EOT
411
432
  Switch to a different working directory.
412
433
  Former directories will be pushed to a stack.
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.7'
4
+ version: '2.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-23 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appl
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements:
76
76
  - Ruby and some small Gems; Readline
77
- rubygems_version: 3.0.8
77
+ rubygems_version: 3.4.17
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Interactive Ruby