syntax_tree_ext 0.6.4 → 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: 6983ce67c837c77fb232bcb11b8319e1f358126b746fdceb9bb586c01eaad408
4
- data.tar.gz: 9cda7bf847292a641816b4ff5d6b2167e3717b9534aa0c1eaa16565ef6022204
3
+ metadata.gz: 97f2ba6521c0048eaaa6f65a4a17b4f34891b0eef53d968374f7e44bf4e75246
4
+ data.tar.gz: 27bd10410c6189066f89c6a94e7ce1b92d84a59be1598eba177ed2f0ee617818
5
5
  SHA512:
6
- metadata.gz: 1d504bd7d7f7609bd7bd26726bf2e4dfd1035ee9a16462430e32251225a867894a46d6422c0021e469a317fb2dd6b900d700fc43238bb22c6fde456e83e4cad4
7
- data.tar.gz: 85c22b4a59294845ff959cc40f0667475405fde09e4a53fcc39331320f557dff2c037dc713b2bd4be8b8601023fc96e8c885a83770f22e008973bbf61f48f68e
6
+ metadata.gz: bb7aeb9a688f2d789e54087caf16a031b7f1caa8c9f553f5be17b3b086532456914c9c61f391e08860b9fd22496a2de07c3653a7d6430863cbd550321937176d
7
+ data.tar.gz: b52f466c32ca64172aaeb0b8ede41f4c93feef922b4f1d36ac24a522a844f21319eac8b025c85fc51e02054bd7464471830f19070bd8c0d5b50435427c482230
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.7.0 (2024-02-10)
4
+
5
+ * Remove `to_hash` extend
6
+ * Remove `siblings` method
7
+ * Hack `SyntaxTree.parse` instead of `SyntaxTree::Parser.parse`
8
+
3
9
  ## 0.6.4 (2023-08-17)
4
10
 
5
11
  * `to_value` supports for empty array
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree_ext (0.6.4)
4
+ syntax_tree_ext (0.7.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.6.4"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -18,11 +18,11 @@ module SyntaxTreeExt
18
18
  end
19
19
 
20
20
  module SyntaxTree
21
- class Parser
21
+ class << self
22
22
  alias_method :original_parse, :parse
23
23
 
24
- def parse
25
- node = original_parse
24
+ def parse(source)
25
+ node = original_parse(source)
26
26
  node.set_parent_node_and_source(source)
27
27
  node
28
28
  end
@@ -50,17 +50,6 @@ module SyntaxTree
50
50
  end
51
51
  end
52
52
 
53
- def siblings
54
- child_nodes = parent_node.deconstruct_keys([]).except(:location, :comments).values
55
- if child_nodes.is_a?(Array) && child_nodes.size == 1 && child_nodes.first.is_a?(Array)
56
- index = child_nodes.first.index(self)
57
- return child_nodes.first[index + 1...]
58
- end
59
-
60
- index = child_nodes.index(self)
61
- child_nodes[index + 1...]
62
- end
63
-
64
53
  def keys
65
54
  if is_a?(BareAssocHash) || is_a?(HashLiteral)
66
55
  assocs.map(&:key)
@@ -120,27 +109,6 @@ module SyntaxTree
120
109
  source[location.start_char...location.end_char]
121
110
  end
122
111
 
123
- # Convert node to a hash, so that it can be converted to a json.
124
- def to_hash
125
- result = { node_type: self.class.name.split('::').last }
126
- unless deconstruct_keys([]).empty?
127
- deconstruct_keys([]).each do |key, value|
128
- result[key] =
129
- case value
130
- when Array
131
- value.map { |v| v.respond_to?(:to_hash) ? v.to_hash : v }
132
- when SyntaxTree::Node, SyntaxTree::Location
133
- value.to_hash
134
- else
135
- value
136
- end
137
- end
138
- else
139
- result[:children] = children.map { |c| c.respond_to?(:to_hash) ? c.to_hash : c }
140
- end
141
- result
142
- end
143
-
144
112
  # Respond key value and source for hash node
145
113
  def method_missing(method_name, *args, &block)
146
114
  return super unless respond_to_assocs?
@@ -187,17 +155,4 @@ module SyntaxTree
187
155
  assoc_key.end_with?(':') ? assoc_key == "#{key}:" : assoc_key == key
188
156
  end
189
157
  end
190
-
191
- class Location
192
- def to_hash
193
- {
194
- start_line: start_line,
195
- start_char: start_char,
196
- start_column: start_column,
197
- end_line: end_line,
198
- end_char: end_char,
199
- end_column: end_column,
200
- }
201
- end
202
- end
203
158
  end
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.6.4
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-08-17 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syntax_tree
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  requirements: []
64
- rubygems_version: 3.4.18
64
+ rubygems_version: 3.5.3
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: extend syntax_tree