prism_ext 0.2.1 → 0.2.3

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: 5579e7f3f46ecbe569deead151875c5a0b4c55ca6b1694c281c206b63c02a806
4
- data.tar.gz: c8ea4497448ce416a62261bd0fa217a8080fbdfe07ca4cfd6cf6524d288e1789
3
+ metadata.gz: 796c4e8f489be737f684de406b557fd5e558686ce3e8e3ed6570537851ccf4fd
4
+ data.tar.gz: d91ee9f891a1653763b4b03721233eb3c643174f72e486505534d7e93706bddc
5
5
  SHA512:
6
- metadata.gz: c6ec0f9615e24af0e70423988e26b2c5dd92028e4b6efeb7199ca4566c5ec6109c4fccaf7e23c2c0b4e329305dc7ad8a8be3a97be2d2e3a456a9036dc9a03e51
7
- data.tar.gz: 9365bc64d9f4dcb77e09e6a6cab9199b332268c3357117fad1305e69521f5468745aecde543e8d73453f721b32c9539614cbbf8755c6cc0be392ff88c0c6c051
6
+ metadata.gz: 8b5c512f633da3c49c51c0364d7dd2bfeb7ee76cd87863dc54ce46f8ce9b9728b4fda7b2ae6287eea118ba926a7fe69a396a7bcb2d8e08644006bfd3a412e5c5
7
+ data.tar.gz: 0230e47fe757e7bf5d7cec6770d53131145b0b3ac14869e01cab1f55bafa6428d0a6bcb80b29172b4bd3516a3d39435da230ccbf25ee9bbeb61c4727fc2ce17f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.3 (2024-02-17)
4
+
5
+ * Remove `Prism::Node#source` hack
6
+
7
+ ## 0.2.2 (2024-02-11)
8
+
9
+ * Reuse `respond_to_elements?`
10
+
3
11
  ## 0.2.1 (2024-02-11)
4
12
 
5
13
  * Check both `HashNode` and `KeywordHashNode`.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prism_ext (0.2.1)
4
+ prism_ext (0.2.3)
5
5
  prism
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrismExt
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
data/lib/prism_ext.rb CHANGED
@@ -24,29 +24,21 @@ module Prism
24
24
  attr_accessor :parent_node
25
25
 
26
26
  def set_parent_node
27
- self.child_nodes.each do |child_node|
27
+ self.compact_child_nodes.each do |child_node|
28
28
  if child_node.is_a?(Array)
29
29
  child_node.each do |child_child_node|
30
- next unless child_child_node.is_a?(Node)
31
-
32
30
  child_child_node.parent_node = self
33
31
  child_child_node.set_parent_node
34
32
  end
33
+ else
34
+ child_node.parent_node = self
35
+ child_node.set_parent_node
35
36
  end
36
-
37
- next unless child_node.is_a?(Node)
38
-
39
- child_node.parent_node = self
40
- child_node.set_parent_node
41
37
  end
42
38
  end
43
39
 
44
- def source
45
- location.instance_variable_get(:@source).source
46
- end
47
-
48
40
  def keys
49
- if is_a?(HashNode)
41
+ if respond_to_elements?
50
42
  elements.map(&:key)
51
43
  else
52
44
  raise MethodNotSupported, "keys is not supported for #{self}"
@@ -54,7 +46,7 @@ module Prism
54
46
  end
55
47
 
56
48
  def values
57
- if is_a?(HashNode)
49
+ if respond_to_elements?
58
50
  elements.map(&:value)
59
51
  else
60
52
  raise MethodNotSupported, "values is not supported for #{self}"
@@ -62,7 +54,7 @@ module Prism
62
54
  end
63
55
 
64
56
  def hash_element(key)
65
- if is_a?(HashNode)
57
+ if respond_to_elements?
66
58
  elements.find { |element_node| element_node.key.to_value == key }
67
59
  else
68
60
  raise MethodNotSupported, "hash_pair is not supported for #{self}"
@@ -70,7 +62,7 @@ module Prism
70
62
  end
71
63
 
72
64
  def hash_value(key)
73
- if is_a?(HashNode)
65
+ if respond_to_elements?
74
66
  elements.find { |element_node| element_node.key.to_value == key }&.value
75
67
  else
76
68
  raise MethodNotSupported, "hash_value is not supported for #{self}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
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-11 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: prism