intar 2.0 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +29 -0
- data/README +30 -0
- data/bin/intar +16 -13
- data/lib/intar/prompt.rb +4 -1
- data/lib/intar/version.rb +1 -1
- data/lib/intar.rb +9 -6
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f69cab2073de237de8c934b10e796b5a424fde33d92ab2bc41ab1aa612da14b7
|
4
|
+
data.tar.gz: 8095bb85ab4571c089859e0274c5e6df02e971f2d79334b20fceb93699857870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecc99bcf076cd30fa4463e229f5ce6fcc02d4952d360ab683b10693de718da6de06bb6155a09446b40f3b4d671a4755888c3752472aa6482fed3b542f260ef9f
|
7
|
+
data.tar.gz: e0a1b9c484c4062a098b4881020aca84392a87bf99a6ff4f1a53826cf7841e90d13c2659e699ed066181295f537b11f36e349e0b4b4ccc55991ec25ef1e61f8e
|
data/LICENSE
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
= ruby-intar
|
2
|
+
|
3
|
+
Copyright (c) 2020, Bertram Scharpf <software@bertram-scharpf.de>.
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are
|
8
|
+
met:
|
9
|
+
|
10
|
+
* Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
|
13
|
+
* Redistributions in binary form must reproduce the above copyright
|
14
|
+
notice, this list of conditions and the following disclaimer in
|
15
|
+
the documentation and/or other materials provided with the
|
16
|
+
distribution.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
19
|
+
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
20
|
+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
21
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
22
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
23
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
27
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
data/README
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
= ruby-intar -- Interactive Ruby
|
2
|
+
|
3
|
+
A simple Irb replacement
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
== About
|
8
|
+
|
9
|
+
The Intar project was started in times when Irb was a rather
|
10
|
+
unconvenient tool, without colors, difficult to call from
|
11
|
+
inside an application and so on.
|
12
|
+
|
13
|
+
Today, Intar is a tool far less complex than Irb.
|
14
|
+
|
15
|
+
Yet, Intar is more robust. Try this in Irb and in Intar:
|
16
|
+
|
17
|
+
prompt> Thread.new { sleep 3 ; Thread.main.raise "stop" }
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
== Author
|
22
|
+
|
23
|
+
Bertram Scharpf <software@bertram-scharpf.de>
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
== TODO
|
28
|
+
|
29
|
+
Write some more documentation.
|
30
|
+
|
data/bin/intar
CHANGED
@@ -28,9 +28,7 @@ class Intar::Appl < Application
|
|
28
28
|
|
29
29
|
EOT
|
30
30
|
|
31
|
-
attr_writer :show, :prompt, :histmax
|
32
|
-
def histfile= f ; @histfile = nil_if_none f ; end
|
33
|
-
def configfile= f ; @configfile = nil_if_none f ; end
|
31
|
+
attr_writer :show, :prompt, :histmax, :histfile, :configfile
|
34
32
|
attr_bang :quiet, :bw, :catch_exit, :histall
|
35
33
|
|
36
34
|
define_option "p", :prompt=, "STR", "prompt - see source code for % escapes"
|
@@ -51,7 +49,7 @@ class Intar::Appl < Application
|
|
51
49
|
"config file, NONE means none"
|
52
50
|
alias_option "c", "configfile"
|
53
51
|
|
54
|
-
define_option "H", :histfile=, "FILE",
|
52
|
+
define_option "H", :histfile=, "FILE",
|
55
53
|
"history file, NONE means none"
|
56
54
|
alias_option "H", "histfile"
|
57
55
|
|
@@ -75,7 +73,11 @@ class Intar::Appl < Application
|
|
75
73
|
define_option "V", :version, "show version"
|
76
74
|
alias_option "V", "version"
|
77
75
|
|
78
|
-
@params = {
|
76
|
+
@params = {
|
77
|
+
show: 5,
|
78
|
+
shownil: false,
|
79
|
+
histfile: ".intar_history",
|
80
|
+
}
|
79
81
|
class <<self
|
80
82
|
attr_reader :params
|
81
83
|
def set **kwargs
|
@@ -101,12 +103,12 @@ class Intar::Appl < Application
|
|
101
103
|
elsif @show then
|
102
104
|
p[ :show] = Integer @show
|
103
105
|
end
|
104
|
-
p[ :prompt ] = @prompt
|
105
|
-
p[ :color ] = false
|
106
|
-
p[ :catch_exit] = true
|
107
|
-
p[ :histhid ] = false
|
108
|
-
p[ :histfile ] = @histfile
|
109
|
-
p[ :histmax ] = Integer @histmax
|
106
|
+
p[ :prompt ] = @prompt if @prompt
|
107
|
+
p[ :color ] = false if @bw
|
108
|
+
p[ :catch_exit] = true if @catch_exit
|
109
|
+
p[ :histhid ] = false if @histall
|
110
|
+
p[ :histfile ] = nil_if_none @histfile if @histfile
|
111
|
+
p[ :histmax ] = Integer @histmax if @histmax
|
110
112
|
p
|
111
113
|
end
|
112
114
|
|
@@ -120,8 +122,9 @@ class Intar::Appl < Application
|
|
120
122
|
end
|
121
123
|
|
122
124
|
def read_cfg
|
123
|
-
|
124
|
-
|
125
|
+
cf = nil_if_none @configfile
|
126
|
+
return unless cf
|
127
|
+
c = File.expand_path cf, "~"
|
125
128
|
return unless File.exists? c
|
126
129
|
load c
|
127
130
|
rescue Exception
|
data/lib/intar/prompt.rb
CHANGED
data/lib/intar/version.rb
CHANGED
data/lib/intar.rb
CHANGED
@@ -78,7 +78,7 @@ class Intar
|
|
78
78
|
@obj = obj.nil? ? (eval "self", TOPLEVEL_BINDING) : obj
|
79
79
|
@params = DEFAULTS.dup.update params
|
80
80
|
@binding = @obj.intar_binding
|
81
|
-
@n =
|
81
|
+
@n = 1
|
82
82
|
@prompt = Prompt.new
|
83
83
|
end
|
84
84
|
|
@@ -89,8 +89,10 @@ class Intar
|
|
89
89
|
def run
|
90
90
|
prompt_load_history
|
91
91
|
oldset = eval OLDSET, @binding
|
92
|
-
|
92
|
+
loop do
|
93
93
|
begin
|
94
|
+
l = readline
|
95
|
+
l or break
|
94
96
|
@redir = find_redirect l
|
95
97
|
r = if l =~ /\A\\(\w+|.)\s*(.*?)\s*\Z/ then
|
96
98
|
m = get_metacommand $1
|
@@ -112,13 +114,14 @@ class Intar
|
|
112
114
|
switchcolor
|
113
115
|
r = $!
|
114
116
|
rescue Exception
|
115
|
-
|
117
|
+
break if SystemExit === $! and not @params[ :catch_exit]
|
116
118
|
show_exception
|
117
119
|
r = $!
|
118
120
|
else
|
119
121
|
display r
|
120
122
|
end
|
121
123
|
oldset.call r, @n
|
124
|
+
@n += 1
|
122
125
|
end
|
123
126
|
prompt_save_history
|
124
127
|
end
|
@@ -198,7 +201,6 @@ class Intar
|
|
198
201
|
|
199
202
|
def readline
|
200
203
|
r, @previous = @previous, nil
|
201
|
-
r or @n += 1
|
202
204
|
begin
|
203
205
|
cp = cur_prompt r
|
204
206
|
l = @prompt.ask cp
|
@@ -240,6 +242,8 @@ class Intar
|
|
240
242
|
puts i
|
241
243
|
end
|
242
244
|
|
245
|
+
PACKAGE_BACKTRACE = %r/#{File.basename __FILE__, ".rb"}.*:\d+:in/
|
246
|
+
|
243
247
|
def show_exception
|
244
248
|
unless $!.to_s.empty? then
|
245
249
|
switchcolor 31, 1
|
@@ -250,8 +254,7 @@ class Intar
|
|
250
254
|
puts "(#{$!.class})"
|
251
255
|
switchcolor 33
|
252
256
|
$@.each { |b|
|
253
|
-
|
254
|
-
break if r and (b.rest r) =~ /\A:\d+:/
|
257
|
+
break if b =~ PACKAGE_BACKTRACE
|
255
258
|
puts b
|
256
259
|
}
|
257
260
|
switchcolor
|
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.
|
4
|
+
version: '2.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appl
|
@@ -47,6 +47,8 @@ executables:
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- LICENSE
|
51
|
+
- README
|
50
52
|
- bin/intar
|
51
53
|
- lib/intar.rb
|
52
54
|
- lib/intar/prompt.rb
|