code-ruby 5.0.2 → 5.0.3

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: c4bdf7818204168e932c860d6ac99481497d3e6dcb1d399d706c3e25cbde8c23
4
- data.tar.gz: 84317c48bc4a88b73601a2cd34859a43010878f275cf8a742143d17ab65c1e91
3
+ metadata.gz: 6c19839210f13057cf11e83849e691bfa59fc63720891af5feef70afebe4d15a
4
+ data.tar.gz: 9f3376a950170b7208b062a3f29a1642da5e80169dbed83c3bcab099ebc3ad7c
5
5
  SHA512:
6
- metadata.gz: 9ee54fc10b1a53ec0b5f7ce220a5643953d89297f1e52e08bf302a02e655f9628367ca7876002afa86e54b4311963b90093cf8174c28865173e299a16ac6d7cb
7
- data.tar.gz: c02a963e61530d8ff83732eec4796b26c4f72b6106bb7bc53bf7fb4ce5a297ab5f92d271b316f098bf44e3845faf1ff6a2f5e3e42a748fbce292ca226d458e51
6
+ metadata.gz: ed16c6eddc5904d2fb8b95074f5ae1c2a445f1e1602efab82ac536348749ec7b3f6cfa907d88997b0b6ec9d7c72f886ad441734656f2d1edd7aaf3b4d64dbfc7
7
+ data.tar.gz: b214393a66a7d700b7be24b3fab4b8555be1e870f45dcf9b0b034c2bff67b62e4c5cae068f0539e490d4bfc37e32ddd94742653ddcb2bc88bcf4fcfd302480ed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.2
1
+ 5.0.3
data/bin/code CHANGED
@@ -46,8 +46,8 @@ def timeout
46
46
  @timeout ||= @parsed_timeout
47
47
  end
48
48
 
49
- def with_timeout(&block)
50
- Timeout.timeout(timeout, &block)
49
+ def with_timeout(&)
50
+ Timeout.timeout(timeout, &)
51
51
  rescue Timeout::Error
52
52
  raise Code::Error, "timeout"
53
53
  end
@@ -297,7 +297,7 @@ class Code
297
297
 
298
298
  if code_operator.to_s == "="
299
299
  code_context = args.fetch(:context)
300
- code_context.code_set(self, code_value)
300
+ code_context.code_assign(self, code_value)
301
301
  elsif setter_operator?(code_operator)
302
302
  code_dynamic_functions.code_set(code_operator.to_s.chop, code_value)
303
303
  return code_value
@@ -441,8 +441,8 @@ class Code
441
441
  keys.to_h { |key| [key, hash.fetch(key)] }
442
442
  end
443
443
 
444
- def sig(args, &block)
445
- Type::Sig.sig(args, object: self, &block)
444
+ def sig(args, &)
445
+ Type::Sig.sig(args, object: self, &)
446
446
 
447
447
  Object::Nothing.new
448
448
  end
@@ -59,7 +59,7 @@ class Code
59
59
  {}
60
60
  end
61
61
 
62
- def initialize(*args, **_kargs, &_block)
62
+ def initialize(*args, **_kargs, &)
63
63
  self.raw =
64
64
  (args.first.is_an?(Object) ? args.first.truthy? : !!args.first)
65
65
  end
@@ -76,7 +76,7 @@ class Code
76
76
  {}
77
77
  end
78
78
 
79
- def initialize(*args, **_kargs, &_block)
79
+ def initialize(*args, **_kargs, &)
80
80
  self.raw =
81
81
  if args.first.is_a?(Class)
82
82
  args.first.raw
@@ -124,8 +124,8 @@ class Code
124
124
  end
125
125
  end
126
126
 
127
- def code_call(*arguments, **_globals)
128
- raw.code_new(*arguments)
127
+ def code_call(*, **_globals)
128
+ raw.code_new(*)
129
129
  end
130
130
 
131
131
  def code_extend(function)
@@ -42,7 +42,7 @@ class Code
42
42
  {}
43
43
  end
44
44
 
45
- def initialize(*args, **_kargs, &_block)
45
+ def initialize(*args, **_kargs, &)
46
46
  self.raw =
47
47
  (args.first.is_a?(Node::Code) ? args.first : Node::Code.new(::Code.parse(args.first.to_s)))
48
48
  end
@@ -34,7 +34,7 @@ class Code
34
34
 
35
35
  attr_accessor :parent
36
36
 
37
- def initialize(*args, **_kargs, &_block)
37
+ def initialize(*args, **_kargs, &)
38
38
  super(args.first)
39
39
  @parent = args.second if args.second.is_a?(Dictionary)
40
40
  end
@@ -63,6 +63,19 @@ class Code
63
63
  end
64
64
  end
65
65
 
66
+ def code_assign(identifier, value)
67
+ code_identifier = identifier.to_code
68
+ context = self
69
+
70
+ context = context.parent while context.parent? && context.code_has_key?(code_identifier).falsy?
71
+
72
+ if context.code_has_key?(code_identifier).falsy?
73
+ context = self
74
+ end
75
+
76
+ context.code_set(code_identifier, value)
77
+ end
78
+
66
79
  def merge(other)
67
80
  Context.new(raw.merge(other.raw), parent || other.parent)
68
81
  end
@@ -7164,7 +7164,7 @@ class Code
7164
7164
  )
7165
7165
  end
7166
7166
 
7167
- def initialize(*args, **_kargs, &_block)
7167
+ def initialize(*args, **_kargs, &)
7168
7168
  ::Time.zone ||= DEFAULT_ZONE
7169
7169
 
7170
7170
  first = args.first
@@ -921,7 +921,7 @@ class Code
921
921
  {}
922
922
  end
923
923
 
924
- def initialize(*args, **_kargs, &_block)
924
+ def initialize(*args, **_kargs, &)
925
925
  self.raw =
926
926
  if args.first.class.in?(NUMBER_CLASSES)
927
927
  if args.second.class.in?(NUMBER_CLASSES)
@@ -1634,7 +1634,7 @@ class Code
1634
1634
  to: :code_size
1635
1635
  )
1636
1636
 
1637
- def initialize(*args, **kargs, &_block)
1637
+ def initialize(*args, **kargs, &)
1638
1638
  self.raw =
1639
1639
  args
1640
1640
  .map do |arg|
@@ -2681,8 +2681,8 @@ class Code
2681
2681
  e.code_value
2682
2682
  end
2683
2683
 
2684
- def code_update(*arguments, **globals)
2685
- code_merge!(*arguments, **globals)
2684
+ def code_update(*, **globals)
2685
+ code_merge!(*, **globals)
2686
2686
  end
2687
2687
 
2688
2688
  def code_replace(dictionary)
@@ -27,7 +27,7 @@ class Code
27
27
  {}
28
28
  end
29
29
 
30
- def initialize(*args, **_kargs, &_block)
30
+ def initialize(*args, **_kargs, &)
31
31
  self.raw =
32
32
  if args.first.is_an?(::ActiveSupport::Duration)
33
33
  args.first
@@ -256,7 +256,7 @@ class Code
256
256
  wbr
257
257
  ].freeze
258
258
 
259
- def initialize(*args, **_kargs, &_block)
259
+ def initialize(*args, **_kargs, &)
260
260
  self.raw =
261
261
  if args.first.is_an?(Html)
262
262
  args.first.raw
@@ -1017,7 +1017,7 @@ class Code
1017
1017
  {}
1018
1018
  end
1019
1019
 
1020
- def initialize(*args, **_kargs, &_block)
1020
+ def initialize(*args, **_kargs, &)
1021
1021
  self.raw =
1022
1022
  if args.first.class.in?(NUMBER_CLASSES)
1023
1023
  if args.second.class.in?(NUMBER_CLASSES)
@@ -2698,7 +2698,7 @@ class Code
2698
2698
  to: :code_size
2699
2699
  )
2700
2700
 
2701
- def initialize(*args, **_kargs, &_block)
2701
+ def initialize(*args, **_kargs, &)
2702
2702
  self.raw =
2703
2703
  if args.first.is_a?(List)
2704
2704
  args.first.raw.map(&:to_code)
@@ -40,7 +40,7 @@ class Code
40
40
  {}
41
41
  end
42
42
 
43
- def initialize(*_args, **_kargs, &_block)
43
+ def initialize(*_args, **_kargs, &)
44
44
  self.raw = nil
45
45
  end
46
46
 
@@ -241,7 +241,7 @@ class Code
241
241
 
242
242
  attr_reader :code_left, :code_right, :code_options, :code_exclude_end
243
243
 
244
- def initialize(*args, **kargs, &_block)
244
+ def initialize(*args, **kargs, &)
245
245
  if args.first.is_a?(Range)
246
246
  @code_left = args.first.code_left
247
247
  @code_right = args.first.code_right
@@ -101,7 +101,7 @@ class Code
101
101
  {}
102
102
  end
103
103
 
104
- def initialize(*args, **kargs, &_block)
104
+ def initialize(*args, **kargs, &)
105
105
  raise Error, "Regex.new: pattern is required" if args.empty?
106
106
  raise Error, "Regex.new: expected 1-2 arguments" if args.size > 2
107
107
 
@@ -195,30 +195,30 @@ class Code
195
195
 
196
196
  def code_options
197
197
  Dictionary.new(
198
- OPTION_FLAGS.transform_values { |flag| (raw.options & flag) == flag }
198
+ OPTION_FLAGS.transform_values { |flag| raw.options.allbits?(flag) }
199
199
  )
200
200
  end
201
201
 
202
202
  def code_ignore_case?
203
- Boolean.new((raw.options & ::Regexp::IGNORECASE) == ::Regexp::IGNORECASE)
203
+ Boolean.new(raw.options.allbits?(::Regexp::IGNORECASE))
204
204
  end
205
205
 
206
206
  def code_extended?
207
- Boolean.new((raw.options & ::Regexp::EXTENDED) == ::Regexp::EXTENDED)
207
+ Boolean.new(raw.options.allbits?(::Regexp::EXTENDED))
208
208
  end
209
209
 
210
210
  def code_multiple_lines?
211
- Boolean.new((raw.options & ::Regexp::MULTILINE) == ::Regexp::MULTILINE)
211
+ Boolean.new(raw.options.allbits?(::Regexp::MULTILINE))
212
212
  end
213
213
 
214
214
  def code_fixed_encoding?
215
215
  Boolean.new(
216
- (raw.options & ::Regexp::FIXEDENCODING) == ::Regexp::FIXEDENCODING
216
+ raw.options.allbits?(::Regexp::FIXEDENCODING)
217
217
  )
218
218
  end
219
219
 
220
220
  def code_no_encoding?
221
- Boolean.new((raw.options & ::Regexp::NOENCODING) == ::Regexp::NOENCODING)
221
+ Boolean.new(raw.options.allbits?(::Regexp::NOENCODING))
222
222
  end
223
223
 
224
224
  def code_to_string
@@ -228,7 +228,6 @@ class Code
228
228
  def code_inspect
229
229
  String.new(raw.inspect)
230
230
  end
231
-
232
231
  end
233
232
  end
234
233
  end
@@ -571,7 +571,7 @@ class Code
571
571
  {}
572
572
  end
573
573
 
574
- def initialize(*args, **_kargs, &_block)
574
+ def initialize(*args, **_kargs, &)
575
575
  self.raw =
576
576
  if args.first.is_an?(Class)
577
577
  args.first.raw.name
@@ -7282,7 +7282,7 @@ class Code
7282
7282
  )
7283
7283
  end
7284
7284
 
7285
- def initialize(*args, **_kargs, &_block)
7285
+ def initialize(*args, **_kargs, &)
7286
7286
  ::Time.zone ||= DEFAULT_ZONE
7287
7287
 
7288
7288
  first = args.first
@@ -50,7 +50,7 @@ class Code
50
50
  {}
51
51
  end
52
52
 
53
- def initialize(*args, **_kargs, &_block)
53
+ def initialize(*args, **_kargs, &)
54
54
  self.raw = ::URI.parse(args.first.to_s)
55
55
  rescue ::URI::InvalidURIError
56
56
  self.raw = ::URI.parse("")
data/lib/code/object.rb CHANGED
@@ -562,8 +562,8 @@ class Code
562
562
  Type::Or.new(self, other)
563
563
  end
564
564
 
565
- def self.code_new(*args)
566
- new(*args)
565
+ def self.code_new(*)
566
+ new(*)
567
567
  end
568
568
 
569
569
  def self.functions
@@ -620,8 +620,8 @@ class Code
620
620
  self.class.name
621
621
  end
622
622
 
623
- def code_new(*args)
624
- self.class.code_new(*args)
623
+ def code_new(*)
624
+ self.class.code_new(*)
625
625
  end
626
626
  end
627
627
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié