syntax_tree_ext 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97f2ba6521c0048eaaa6f65a4a17b4f34891b0eef53d968374f7e44bf4e75246
4
- data.tar.gz: 27bd10410c6189066f89c6a94e7ce1b92d84a59be1598eba177ed2f0ee617818
3
+ metadata.gz: 0b0bc3412938b71b6b55e193aad641be13db37edbab5677dfe8073477b7204b4
4
+ data.tar.gz: beea90b07e9c1dbe2cc4fb81dd0dff4788debde15556678159a07b80b966e155
5
5
  SHA512:
6
- metadata.gz: bb7aeb9a688f2d789e54087caf16a031b7f1caa8c9f553f5be17b3b086532456914c9c61f391e08860b9fd22496a2de07c3653a7d6430863cbd550321937176d
7
- data.tar.gz: b52f466c32ca64172aaeb0b8ede41f4c93feef922b4f1d36ac24a522a844f21319eac8b025c85fc51e02054bd7464471830f19070bd8c0d5b50435427c482230
6
+ metadata.gz: 39587b98d39f57db669bfef81184d825cf5e3f3e71da224bd4133824e0240e3f914c9173daa2dd6c7a30a27afdaf7d34053e2606778164a602f4d98f58a0ed22
7
+ data.tar.gz: 51182e6fa69cd06987e6dcfe6830a3359982eadff419e7192ab4c6160c075599d3382f34f4e9d20256b8f577577539d30ed3338ab6b2c79019031215a4db9421
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.7.2 (2024-02-17)
4
+
5
+ * Use `Hash#filter` instead of `Hash#reject`
6
+
7
+ ## 0.7.1 (2024-02-11)
8
+
9
+ * Reuse `respond_to_assocs`
10
+
3
11
  ## 0.7.0 (2024-02-10)
4
12
 
5
13
  * Remove `to_hash` extend
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree_ext (0.7.0)
4
+ syntax_tree_ext (0.7.2)
5
5
  syntax_tree
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SyntaxTreeExt
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.2"
5
5
  end
@@ -4,14 +4,6 @@ require_relative "syntax_tree_ext/version"
4
4
 
5
5
  require 'syntax_tree'
6
6
 
7
- if RUBY_VERSION.to_i < 3
8
- class Hash
9
- def except(*keys)
10
- self.reject { |k, _| keys.include?(k) }
11
- end
12
- end
13
- end
14
-
15
7
  module SyntaxTreeExt
16
8
  class Error < StandardError; end
17
9
  # Your code goes here...
@@ -33,7 +25,7 @@ module SyntaxTree
33
25
 
34
26
  def set_parent_node_and_source(source)
35
27
  self.source = source
36
- self.deconstruct_keys([]).except(:location, :comments).values.each do |child_node|
28
+ self.deconstruct_keys([]).filter { |key, _value| ![:location, :comments].include?(key) }.values.each do |child_node|
37
29
  if child_node.is_a?(Array)
38
30
  child_node.each do |child_child_node|
39
31
  next unless child_child_node.is_a?(Node)
@@ -51,7 +43,7 @@ module SyntaxTree
51
43
  end
52
44
 
53
45
  def keys
54
- if is_a?(BareAssocHash) || is_a?(HashLiteral)
46
+ if respond_to_assocs?
55
47
  assocs.map(&:key)
56
48
  else
57
49
  raise MethodNotSupported, "keys is not supported for #{self}"
@@ -59,7 +51,7 @@ module SyntaxTree
59
51
  end
60
52
 
61
53
  def values
62
- if is_a?(BareAssocHash) || is_a?(HashLiteral)
54
+ if respond_to_assocs?
63
55
  assocs.map(&:value)
64
56
  else
65
57
  raise MethodNotSupported, "values is not supported for #{self}"
@@ -67,7 +59,7 @@ module SyntaxTree
67
59
  end
68
60
 
69
61
  def hash_assoc(key)
70
- if is_a?(BareAssocHash) || is_a?(HashLiteral)
62
+ if respond_to_assocs?
71
63
  assocs.find { |assoc_node| assoc_node.key.to_value == key }
72
64
  else
73
65
  raise MethodNotSupported, "hash_assoc is not supported for #{self}"
@@ -75,7 +67,7 @@ module SyntaxTree
75
67
  end
76
68
 
77
69
  def hash_value(key)
78
- if is_a?(BareAssocHash) || is_a?(HashLiteral)
70
+ if respond_to_assocs?
79
71
  assocs.find { |assoc_node| assoc_node.key.to_value == key }&.value
80
72
  else
81
73
  raise MethodNotSupported, "hash_value is not supported for #{self}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_tree_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
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-02-10 00:00:00.000000000 Z
11
+ date: 2024-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syntax_tree