syntax_tree_ext 0.4.0 → 0.5.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: 252bb9039575140c0f6880c558a9dc3b19b08e400f673184672a4064584473aa
4
- data.tar.gz: cfe4011f7e28f90f1ce9a30573fde27529f0f92eabc1af79719cd2d5a4405033
3
+ metadata.gz: f9580df1305b4def597a9e270f05b42f5f8bc5704f433c4a0e5356591f0de7e5
4
+ data.tar.gz: b0264ef9b6a63c83918ef57dc38062da7fcf09e688fc756be3f21c15b4e64501
5
5
  SHA512:
6
- metadata.gz: f729e476eb65c5587c4a2bc3fd6026ef9debd27af3b951b4a9a269480fad087c819a337084b401df9cc15e8ea82349879245f427bcbb0d1026c4d55b707d6c59
7
- data.tar.gz: c329ff9f956c7ba8e718ffc8df2f5f05c6bd7c6e556c28828e3da5378db4fcd91f44e7a71a242391e2ff7b53750b57b3133247285e0a78bac10e53747d285876
6
+ metadata.gz: 22f20003979d6dd4ed263098327362f932944e59b5278b7c68ed7261a2465dfbfd14fd617ab04c474358564de0ba44ebc4ce11475dad84fe673842afb679de26
7
+ data.tar.gz: e36f96c71b3359547c1bac1e15e8bcfa4ce724ac82d6f0a8b8750208e546af9bb7bf92a3b38459c40195299429bfebaf8040eddda1fe17b5cb1dcf7a23939553
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.5.0 (2023-06-12)
4
+
5
+ * Add `keys` and `values` for hash
6
+
7
+ ## 0.4.1 (2023-06-11)
8
+
9
+ * Support `const` for `to_value`
10
+
3
11
  ## 0.4.0 (2023-06-08)
4
12
 
5
13
  * Add `Syntax::Node#to_hash`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree_ext (0.4.0)
4
+ syntax_tree_ext (0.5.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.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -38,6 +38,22 @@ module SyntaxTree
38
38
  parent_node.child_nodes[index + 1...]
39
39
  end
40
40
 
41
+ def keys
42
+ if is_a?(BareAssocHash) || is_a?(HashLiteral)
43
+ assocs.map(&:key)
44
+ else
45
+ raise MethodNotSupported, "keys is not supported for #{self}"
46
+ end
47
+ end
48
+
49
+ def values
50
+ if is_a?(BareAssocHash) || is_a?(HashLiteral)
51
+ assocs.map(&:value)
52
+ else
53
+ raise MethodNotSupported, "values is not supported for #{self}"
54
+ end
55
+ end
56
+
41
57
  def to_value
42
58
  case self
43
59
  when SymbolLiteral
@@ -52,7 +68,7 @@ module SyntaxTree
52
68
  value == 'true'
53
69
  when VarRef
54
70
  value.to_value
55
- when Label, TStringContent, Ident
71
+ when Const, Label, TStringContent, Ident
56
72
  value
57
73
  when ArrayLiteral
58
74
  contents.parts.map { |part| part.to_value }
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syntax_tree