parser_node_ext 0.6.1 → 0.7.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: 0c010eedee012b007e7dd9d4ad497a418baff0fd7ff6cbd90e28900f2910ab61
4
- data.tar.gz: 69a8789262a112d6761a47230cfa7dabac548e7250dbcbc71eecd9aa11faf3d3
3
+ metadata.gz: '09b9c1f0df70d2a83780b534cb42635c55b0dfb68165b40fa07247f251d6e344'
4
+ data.tar.gz: 0ef177a30d4fdacf17d9c36dfcf9e42b4ea7e94142422c9d064dc1cd41a8674d
5
5
  SHA512:
6
- metadata.gz: 4aaab8fec5b8b0c4ac5df1cd4a56acb4e0331bd13988cab00e52bd9e0c08e103a4bfa9a976bff84699dec1310f9a01f891a4222b750d1836c26171ccc5913a0d
7
- data.tar.gz: 86bd7ed9bd852983e2ec19d3c795edae960f20670c325557549e2abe69e0086f05c6510a33d550e8f480d87ae64d652cc88bcd5debddcfb221f0a7b79cbaa254
6
+ metadata.gz: 5825839d2153c0d21fc96ba7ee3e6b2c30490966255bb6331cac40224ceb31a426ef86c36cfb3c8ad93d69f14e4a6eb096b582bb731ad69dda0c25467a9acda8
7
+ data.tar.gz: b664575b41717991f2fc7c2a562990c876fa2239cb3d982a1ce9dea9d2bb7316bab755a6c1e3b5e380c39a2b5ccc53fe0d62c38fa3c3c019cf5f52cc724ced75
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.7.0 (2023-01-28)
4
+
5
+ * Support `elements` for `array` node
6
+ * Support `forward_args`
7
+
3
8
  ## 0.6.1 (2023-01-21)
4
9
 
5
10
  * Fix typo
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parser_node_ext (0.6.1)
4
+ parser_node_ext (0.7.0)
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 = "0.6.1"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -119,9 +119,11 @@ module ParserNodeExt
119
119
  def arguments
120
120
  case type
121
121
  when :def, :block
122
- children[1].children
122
+ children[1].type == :args ? children[1].children : [children[1]]
123
123
  when :defs
124
- children[2].children
124
+ children[2].type == :args ? children[2].children : [children[2]]
125
+ when :block
126
+ children[1].children
125
127
  when :send, :csend
126
128
  children[2..-1]
127
129
  when :defined?
@@ -159,6 +161,9 @@ module ParserNodeExt
159
161
  end
160
162
  end
161
163
 
164
+ # Get when statements of case node.
165
+ # @return [Array<Parser::AST::Node>] when statements of case node.
166
+ # @raise [MethodNotSupported] if calls on other node.
162
167
  def when_statements
163
168
  if :case == type
164
169
  children[1...-1]
@@ -167,10 +172,24 @@ module ParserNodeExt
167
172
  end
168
173
  end
169
174
 
175
+ # Get else statement of case node.
176
+ # @return [Parser::AST::Node] else statement of case node.
177
+ # @raise [MethodNotSupported] if calls on other node.
170
178
  def else_statement
171
179
  children[-1]
172
180
  end
173
181
 
182
+ # Get elements of array node.
183
+ # @return [Array<Parser::AST::Node>] elements of array node.
184
+ # @raise [MethodNotSupported] if calls on other node.
185
+ def elements
186
+ if :array == type
187
+ children
188
+ else
189
+ raise MethodNotSupported, "elements is not supported for #{self}"
190
+ end
191
+ end
192
+
174
193
  # Get pairs of :hash node.
175
194
  # @example
176
195
  # node # s(:hash, s(:pair, s(:sym, :foo), s(:sym, :bar)), s(:pair, s(:str, "foo"), s(:str, "bar")))
@@ -5,6 +5,7 @@ module ParserNodeExt
5
5
  def arguments: () -> Array[Parser::AST::Node]
6
6
  def body: () -> Array[Parser::AST::Node]
7
7
  def caller: () -> Parser::AST::Node
8
+ def elements: () -> Array[Parser::AST::Node]
8
9
  def else_statement: () -> Parser::AST::Node
9
10
  def expression: () -> Parser::AST::Node
10
11
  def if_statement: () -> Parser::AST::Node
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: 0.6.1
4
+ version: 0.7.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-01-21 00:00:00.000000000 Z
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser