syntax_tree_ext 0.5.0 → 0.6.0

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: f9580df1305b4def597a9e270f05b42f5f8bc5704f433c4a0e5356591f0de7e5
4
- data.tar.gz: b0264ef9b6a63c83918ef57dc38062da7fcf09e688fc756be3f21c15b4e64501
3
+ metadata.gz: ce3e3738a614af69fd2ca73be682d1516281057cacbf1995445b07bab29f3020
4
+ data.tar.gz: f47da333553dcbf262cf53ae2685d999fda7a9a8800498b84b783ae0344e9365
5
5
  SHA512:
6
- metadata.gz: 22f20003979d6dd4ed263098327362f932944e59b5278b7c68ed7261a2465dfbfd14fd617ab04c474358564de0ba44ebc4ce11475dad84fe673842afb679de26
7
- data.tar.gz: e36f96c71b3359547c1bac1e15e8bcfa4ce724ac82d6f0a8b8750208e546af9bb7bf92a3b38459c40195299429bfebaf8040eddda1fe17b5cb1dcf7a23939553
6
+ metadata.gz: dc2e4c15334228eccb81faa35fc93b3f068a5d0951e03f7e8ecaa352e0a76940b6af46fd2bdf6aa32d039d74515cd070aed220d61743b97ab0fa245967656e49
7
+ data.tar.gz: 9c454a2b46e308630496ae20baca6adcadd5a7f70b2b9401068f3b3e9cd9a516412145c5a593543759f45e1aae540bf13365a97609643a4848baabf03beb6098
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.6.0 (2024-06-12)
4
+
5
+ * Add `hash_assoc` and `hash_value` for hash
6
+
3
7
  ## 0.5.0 (2023-06-12)
4
8
 
5
9
  * Add `keys` and `values` for hash
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree_ext (0.5.0)
4
+ syntax_tree_ext (0.6.0)
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.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
@@ -54,6 +54,22 @@ module SyntaxTree
54
54
  end
55
55
  end
56
56
 
57
+ def hash_assoc(key)
58
+ if is_a?(BareAssocHash) || is_a?(HashLiteral)
59
+ assocs.find { |assoc_node| assoc_node.key.to_value == key }
60
+ else
61
+ raise MethodNotSupported, "hash_assoc is not supported for #{self}"
62
+ end
63
+ end
64
+
65
+ def hash_value(key)
66
+ if is_a?(BareAssocHash) || is_a?(HashLiteral)
67
+ assocs.find { |assoc_node| assoc_node.key.to_value == key }&.value
68
+ else
69
+ raise MethodNotSupported, "hash_value is not supported for #{self}"
70
+ end
71
+ end
72
+
57
73
  def to_value
58
74
  case self
59
75
  when SymbolLiteral
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_tree_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang