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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb526faa67bbfaad97480a6e642dc161725c6c444dcb6e6080498fae665173a6
4
- data.tar.gz: 58c89d71946d694826f2409eaf4a49ed88644bf640564e2f3a6c9ab3d8e9c0e1
3
+ metadata.gz: 31185f1544129f656db53521cf32cd171bb8dbfb49a3826bcf9eeddf46928c64
4
+ data.tar.gz: 1a48f904f93867f1242cc6e548e0acb5acf8767ec7e89eb543cd08025e7857f2
5
5
  SHA512:
6
- metadata.gz: 9e101c1374b8ea161ec76217739ce5dbcd93c9e85e3cc147852717634085b97e5bd1aa71a9a6c316a660e9c60f0d16a03d08c26e7b7e65bdbb44886295bfa8dd
7
- data.tar.gz: 6243fb79d8747f0c507ebbd7e3f4efd486b3848ea7b2bf4db5ee4bb48591ee20857bcf5d86f61520c7d17b1d9307dc28a2ac785a64dda83ba1c78ebff90d53b6
6
+ metadata.gz: 921e8d5c6306dbcfa7daafa8271dcadfa9f2707e315a81704e921b1d7111d6c1a1a958e8b3b615c1725c2e2a0a7dffa245a7fbd068383977cc8259f1282cf51b
7
+ data.tar.gz: 8eaa9e728fd9f14a42fc08a729c9e8dc3ac8289257f26f6440fa38c29c7491caefa2611eb10d2a778a0664e8e7c29c6c8be9b3e1a91133c206e0364a61cd62ee
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  "lib/irb/cmd/fork.rb",
34
34
  "lib/irb/cmd/help.rb",
35
35
  "lib/irb/cmd/load.rb",
36
+ "lib/irb/cmd/measure.rb",
36
37
  "lib/irb/cmd/nop.rb",
37
38
  "lib/irb/cmd/pushws.rb",
38
39
  "lib/irb/cmd/subirb.rb",
@@ -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:
@@ -177,9 +177,9 @@ module IRB # :nodoc:
177
177
  args << "&block"
178
178
  args = args.join(", ")
179
179
  line = __LINE__; eval %[
180
- unless self.class.class_variable_defined?(:@@#{cmd_name}_)
181
- self.class.class_variable_set(:@@#{cmd_name}_, true)
182
- def #{cmd_name}_(\#{args})
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
@@ -158,8 +158,18 @@ module IRB # :nodoc:
158
158
  else
159
159
  added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
160
160
  end
161
- IRB.conf[:MEASURE_CALLBACKS] << added if added
162
- added
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)
@@ -83,7 +83,15 @@ module IRB
83
83
  #
84
84
  # See IO#eof? for more information.
85
85
  def eof?
86
- @stdin.eof?
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
@@ -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
- ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
74
- result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
75
- line_num_offset += 1
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?{ |t| tokens[i + 1][1] != t }
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
@@ -11,7 +11,7 @@
11
11
  #
12
12
 
13
13
  module IRB # :nodoc:
14
- VERSION = "1.2.9"
14
+ VERSION = "1.3.0"
15
15
  @RELEASE_VERSION = VERSION
16
- @LAST_UPDATE_DATE = "2020-12-22"
16
+ @LAST_UPDATE_DATE = "2020-12-25"
17
17
  end
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.2.9
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-21 00:00:00.000000000 Z
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