irb 1.2.9 → 1.3.0
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 +4 -4
- data/irb.gemspec +1 -0
- data/lib/irb/cmd/measure.rb +34 -0
- data/lib/irb/extend-command.rb +3 -3
- data/lib/irb/init.rb +12 -2
- data/lib/irb/input-method.rb +9 -1
- data/lib/irb/ruby-lex.rb +10 -5
- data/lib/irb/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31185f1544129f656db53521cf32cd171bb8dbfb49a3826bcf9eeddf46928c64
|
4
|
+
data.tar.gz: 1a48f904f93867f1242cc6e548e0acb5acf8767ec7e89eb543cd08025e7857f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 921e8d5c6306dbcfa7daafa8271dcadfa9f2707e315a81704e921b1d7111d6c1a1a958e8b3b615c1725c2e2a0a7dffa245a7fbd068383977cc8259f1282cf51b
|
7
|
+
data.tar.gz: 8eaa9e728fd9f14a42fc08a729c9e8dc3ac8289257f26f6440fa38c29c7491caefa2611eb10d2a778a0664e8e7c29c6c8be9b3e1a91133c206e0364a61cd62ee
|
data/irb.gemspec
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative "nop"
|
2
|
+
|
3
|
+
# :stopdoc:
|
4
|
+
module IRB
|
5
|
+
module ExtendCommand
|
6
|
+
class Measure < Nop
|
7
|
+
def initialize(*args)
|
8
|
+
super(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute(type = nil, arg = nil)
|
12
|
+
case type
|
13
|
+
when :off
|
14
|
+
IRB.conf[:MEASURE] = nil
|
15
|
+
IRB.unset_measure_callback(arg)
|
16
|
+
when :list
|
17
|
+
IRB.conf[:MEASURE_CALLBACKS].each do |type_name, _, arg_val|
|
18
|
+
puts "- #{type_name}" + (arg_val ? "(#{arg_val.inspect})" : '')
|
19
|
+
end
|
20
|
+
when :on
|
21
|
+
IRB.conf[:MEASURE] = true
|
22
|
+
added = IRB.set_measure_callback(type, arg)
|
23
|
+
puts "#{added[0]} is added." if added
|
24
|
+
else
|
25
|
+
IRB.conf[:MEASURE] = true
|
26
|
+
added = IRB.set_measure_callback(type, arg)
|
27
|
+
puts "#{added[0]} is added." if added
|
28
|
+
end
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
# :startdoc:
|
data/lib/irb/extend-command.rb
CHANGED
@@ -177,9 +177,9 @@ module IRB # :nodoc:
|
|
177
177
|
args << "&block"
|
178
178
|
args = args.join(", ")
|
179
179
|
line = __LINE__; eval %[
|
180
|
-
unless
|
181
|
-
|
182
|
-
def
|
180
|
+
unless singleton_class.class_variable_defined?(:@@#{cmd_name}_)
|
181
|
+
singleton_class.class_variable_set(:@@#{cmd_name}_, true)
|
182
|
+
def self.#{cmd_name}_(\#{args})
|
183
183
|
ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
|
184
184
|
end
|
185
185
|
end
|
data/lib/irb/init.rb
CHANGED
@@ -158,8 +158,18 @@ module IRB # :nodoc:
|
|
158
158
|
else
|
159
159
|
added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
|
160
160
|
end
|
161
|
-
|
162
|
-
|
161
|
+
if added
|
162
|
+
found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
|
163
|
+
if found
|
164
|
+
# already added
|
165
|
+
nil
|
166
|
+
else
|
167
|
+
IRB.conf[:MEASURE_CALLBACKS] << added if added
|
168
|
+
added
|
169
|
+
end
|
170
|
+
else
|
171
|
+
nil
|
172
|
+
end
|
163
173
|
end
|
164
174
|
|
165
175
|
def IRB.unset_measure_callback(type = nil)
|
data/lib/irb/input-method.rb
CHANGED
@@ -83,7 +83,15 @@ module IRB
|
|
83
83
|
#
|
84
84
|
# See IO#eof? for more information.
|
85
85
|
def eof?
|
86
|
-
@stdin.
|
86
|
+
rs, = IO.select([@stdin], [], [], 0.00001)
|
87
|
+
if rs and rs[0]
|
88
|
+
c = @stdin.getc
|
89
|
+
result = c.nil? ? true : false
|
90
|
+
@stdin.ungetc(c) unless c.nil?
|
91
|
+
result
|
92
|
+
else # buffer is empty
|
93
|
+
false
|
94
|
+
end
|
87
95
|
end
|
88
96
|
|
89
97
|
# Whether this input method is still readable when there is no more data to
|
data/lib/irb/ruby-lex.rb
CHANGED
@@ -66,14 +66,19 @@ class RubyLex
|
|
66
66
|
unprocessed_tokens = []
|
67
67
|
line_num_offset = 0
|
68
68
|
tokens.each do |t|
|
69
|
-
code << t[2]
|
70
69
|
partial_tokens << t
|
71
70
|
unprocessed_tokens << t
|
72
71
|
if t[2].include?("\n")
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
t_str = t[2]
|
73
|
+
t_str.each_line("\n") do |s|
|
74
|
+
code << s << "\n"
|
75
|
+
ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
|
76
|
+
result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
|
77
|
+
line_num_offset += 1
|
78
|
+
end
|
76
79
|
unprocessed_tokens = []
|
80
|
+
else
|
81
|
+
code << t[2]
|
77
82
|
end
|
78
83
|
end
|
79
84
|
unless unprocessed_tokens.empty?
|
@@ -552,7 +557,7 @@ class RubyLex
|
|
552
557
|
end_type << :on_regexp_end
|
553
558
|
when :on_symbeg
|
554
559
|
acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw}
|
555
|
-
if (i + 1) < tokens.size and acceptable_single_tokens.all?{ |
|
560
|
+
if (i + 1) < tokens.size and acceptable_single_tokens.all?{ |st| tokens[i + 1][1] != st }
|
556
561
|
start_token << t
|
557
562
|
end_type << :on_tstring_end
|
558
563
|
end
|
data/lib/irb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reline
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/irb/cmd/fork.rb
|
77
77
|
- lib/irb/cmd/help.rb
|
78
78
|
- lib/irb/cmd/load.rb
|
79
|
+
- lib/irb/cmd/measure.rb
|
79
80
|
- lib/irb/cmd/nop.rb
|
80
81
|
- lib/irb/cmd/pushws.rb
|
81
82
|
- lib/irb/cmd/subirb.rb
|