parser_node_ext 1.3.0 → 1.3.1

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: 3f58dd28166500b9ae0882d5a629d272f4ad7713538e2f7aeb2a0218c77a359a
4
- data.tar.gz: 3947994cf6a5669d2d37971af8dae83836a429c9715aa2c2e29a7efd3c74863a
3
+ metadata.gz: 50a45e7affbc066c77b4b1ced9b3b9e95f44dda27d545406a81835c3272eada5
4
+ data.tar.gz: 20b65501f3e92ea387a1a3f28ec67627cd3c6ea48228a7988c309730a68d380d
5
5
  SHA512:
6
- metadata.gz: 3e2462943a0c6db7a0e2d95a9ce9e967deb19c5d2a7ce71d44b68c7db5cb74bbf398d2ae487ea0db8145371d4c7ec17910c5889d675d9201b19e81ae7ab041d4
7
- data.tar.gz: f8b0f07ff32914d11bb1a3cc70e1a6b2a19501bdb08d795334c738780fa4cfa016a18e86e3014f80b86953eba7e06e44dcfca4d67680e7bb0e35e52f9402f9e0
6
+ metadata.gz: 69a851d7c5e73797708dd354c5b9f145d6d6c525b234b5be9c2d7c9e79ef690117a1c8c9bdb068a428a0796403d67a91104dd327551c004f42c6168d7e41d92a
7
+ data.tar.gz: 660151c08259100c51194e374c8db31ff66fb2acaf76a9f8c41c594029de8ef775f2a4bdc352718860224c31531fca0e63b6cefdb7e85bc1511e1ce26e86a462
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.3.1 (2024-04-18)
4
+
5
+ * Remove `.key?` method
6
+
3
7
  ## 1.3.0 (2024-04-07)
4
8
 
5
9
  * Add github actions
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parser_node_ext (1.3.0)
4
+ parser_node_ext (1.3.1)
5
5
  parser
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ParserNodeExt
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
@@ -319,21 +319,6 @@ module ParserNodeExt
319
319
  end
320
320
  end
321
321
 
322
- # Check if :hash node contains specified key.
323
- # @example
324
- # node # s(:hash, s(:pair, s(:sym, :foo), s(:sym, :bar)))
325
- # node.key?(:foo) # true
326
- # @param [Symbol, String] key value.
327
- # @return [Boolean] true if specified key exists.
328
- # @raise [MethodNotSupported] if calls on other node.
329
- def key?(key)
330
- if %i[hash hash_pattern].include?(type)
331
- pairs.any? { |pair_node| pair_node.key.to_value == key }
332
- else
333
- raise MethodNotSupported, "key? is not supported for #{self}"
334
- end
335
- end
336
-
337
322
  # Get :hash pair node according to specified key.
338
323
  # @example
339
324
  # node # s(:hash, s(:pair, s(:sym, :foo), s(:sym, :bar)))
@@ -422,20 +407,20 @@ module ParserNodeExt
422
407
  return children.send(method_name, *args, &block)
423
408
  elsif :hash == type && method_name.to_s.end_with?('_pair')
424
409
  key = method_name.to_s[0..-6]
425
- return hash_pair(key.to_sym) if key?(key.to_sym)
426
- return hash_pair(key.to_s) if key?(key.to_s)
410
+ return hash_pair(key.to_sym) if keys.map(&:to_value).include?(key.to_sym)
411
+ return hash_pair(key.to_s) if keys.map(&:to_value).include?(key.to_s)
427
412
 
428
413
  return nil
429
414
  elsif :hash == type && method_name.to_s.end_with?('_value')
430
415
  key = method_name.to_s[0..-7]
431
- return hash_value(key.to_sym) if key?(key.to_sym)
432
- return hash_value(key.to_s) if key?(key.to_s)
416
+ return hash_value(key.to_sym) if keys.map(&:to_value).include?(key.to_sym)
417
+ return hash_value(key.to_s) if keys.map(&:to_value).include?(key.to_s)
433
418
 
434
419
  return nil
435
420
  elsif :hash == type && method_name.to_s.end_with?('_source')
436
421
  key = method_name.to_s[0..-8]
437
- return hash_value(key.to_sym)&.to_source if key?(key.to_sym)
438
- return hash_value(key.to_s)&.to_source if key?(key.to_s)
422
+ return hash_value(key.to_sym)&.to_source if keys.map(&:to_value).include?(key.to_sym)
423
+ return hash_value(key.to_s)&.to_source if keys.map(&:to_value).include?(key.to_s)
439
424
 
440
425
  return ''
441
426
  end
@@ -448,13 +433,13 @@ module ParserNodeExt
448
433
  return true
449
434
  elsif :hash == type && method_name.to_s.end_with?('_pair')
450
435
  key = method_name.to_s[0..-6]
451
- return key?(key.to_sym) || key?(key.to_s)
436
+ return keys.map(&:to_value).include?(key.to_sym) || keys.map(&:to_value).include?(key.to_s)
452
437
  elsif :hash == type && method_name.to_s.end_with?('_value')
453
438
  key = method_name.to_s[0..-7]
454
- return key?(key.to_sym) || key?(key.to_s)
439
+ return keys.map(&:to_value).include?(key.to_sym) || keys.map(&:to_value).include?(key.to_s)
455
440
  elsif :hash == type && method_name.to_s.end_with?('_source')
456
441
  key = method_name.to_s[0..-8]
457
- return key?(key.to_sym) || key?(key.to_s)
442
+ return keys.map(&:to_value).include?(key.to_sym) || keys.map(&:to_value).include?(key.to_s)
458
443
  end
459
444
 
460
445
  super
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser_node_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-07 00:00:00.000000000 Z
11
+ date: 2024-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser