decode 0.18.0 → 0.18.3

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: 07565b4d2600fe3cd6552192f8faae065fbd728e98f51008863326a1b4f7f743
4
- data.tar.gz: a16e3cf053d0ac25c9e0f2e596832dabf44f027edf0ad509ed7eb20559d685e5
3
+ metadata.gz: 63bb6b043b5f4a8700284bae32cfa32f8f8cfa4c043c6c35c26318b2b871a030
4
+ data.tar.gz: 587feec5af84384b4d7108913e97642b8cfc72c163a879e6a9b9cce62f7e4d20
5
5
  SHA512:
6
- metadata.gz: a1e7ccf9434ddd07c98ce94e64741f30af06698b9841935b99ecc0f7e5027aa76a8ce97778bade6cdaf25853f03d7ec8d2372715bd328ada2b844b4daf68c2a5
7
- data.tar.gz: 69d195150f777b3484de296ef8d093e6531856bbc111d3d75e58d806478ecb84506223f5e5372656c06df28e8e1e326817f287dcc680c9055e7286b58fd9a2d2
6
+ metadata.gz: 73c5fbcec520c13af4e820ce36cc21613308d8ea85a4a4db8882017e73ab052d2ffdfe73191815e336eafdb981ffb3f817f287958849208191d5c9c96b89b6c2
7
+ data.tar.gz: b018dbafe4d880259e22e6dacc6ceb4ac6b54647820293a3f3009f5aca6dede7f64c4a51c7ee0b10812c91b8608331a3ea6f43af803a129e69da6fb78de3507b
checksums.yaml.gz.sig CHANGED
Binary file
@@ -40,10 +40,12 @@ module Decode
40
40
  @qualified_name = nil
41
41
  end
42
42
 
43
- def to_s
43
+ def inspect
44
44
  "\#<#{self.class} #{qualified_name}>"
45
45
  end
46
46
 
47
+ alias to_s inspect
48
+
47
49
  # The symbol name.
48
50
  # e.g. `:Decode`.
49
51
  # @attribute [Symbol]
data/lib/decode/index.rb CHANGED
@@ -37,6 +37,12 @@ module Decode
37
37
  @trie = Trie.new
38
38
  end
39
39
 
40
+ def inspect
41
+ "#<#{self.class} #{@definitions.size} definition(s)>"
42
+ end
43
+
44
+ alias to_s inspect
45
+
40
46
  # All supported languages for this index.
41
47
  # @attribute [Languages]
42
48
  attr :languages
@@ -69,6 +69,10 @@ module Decode
69
69
 
70
70
  # A Ruby-specific singleton class.
71
71
  class Singleton < Definition
72
+ def nested_name
73
+ "::class"
74
+ end
75
+
72
76
  # A singleton class is a container for other definitions.
73
77
  # @returns [Boolean]
74
78
  def container?
@@ -82,14 +86,40 @@ module Decode
82
86
  end
83
87
 
84
88
  # The short form of the class.
85
- # e.g. `class << (self)`.
89
+ # e.g. `class << self`.
86
90
  def short_form
87
91
  "class << #{@name}"
88
92
  end
89
93
 
90
94
  # The long form is the same as the short form.
91
95
  alias long_form short_form
96
+
97
+ def path_name
98
+ [:class]
99
+ end
100
+
101
+ # The lexical scope as an array of names.
102
+ # e.g. `[:Decode, :Definition]`
103
+ # @returns [Array]
104
+ def path
105
+ if @path
106
+ # Cached version:
107
+ @path
108
+ else
109
+ @path = [*self.absolute_path, *self.path_name]
110
+ end
111
+ end
112
+
113
+ private
114
+
115
+ def absolute_path
116
+ if @parent
117
+ @parent.path
118
+ else
119
+ @name.to_s.split('::').map(&:to_sym)
120
+ end
121
+ end
92
122
  end
93
123
  end
94
124
  end
95
- end
125
+ end
@@ -119,16 +119,18 @@ module Decode
119
119
  walk_definitions(children, comments, definition, &block)
120
120
  end
121
121
  when :sclass
122
- definition = Singleton.new(
123
- node, node.children[0],
124
- comments: extract_comments_for(node, comments),
125
- parent: parent, language: @language
126
- )
127
-
128
- yield definition
129
-
130
- if children = node.children[1]
131
- walk_definitions(children, comments, definition, &block)
122
+ if name = singleton_name_for(node.children[0])
123
+ definition = Singleton.new(
124
+ node, name,
125
+ comments: extract_comments_for(node, comments),
126
+ parent: parent, language: @language
127
+ )
128
+
129
+ yield definition
130
+
131
+ if children = node.children[1]
132
+ walk_definitions(children, comments, definition, &block)
133
+ end
132
134
  end
133
135
  when :def
134
136
  definition = Method.new(
@@ -229,6 +231,15 @@ module Decode
229
231
  end
230
232
  end
231
233
 
234
+ def singleton_name_for(node)
235
+ case node.type
236
+ when :const
237
+ nested_name_for(node)
238
+ when :self
239
+ :'self'
240
+ end
241
+ end
242
+
232
243
  KIND_ATTRIBUTE = /\A
233
244
  (@(?<kind>attribute)\s+(?<value>.*?))|
234
245
  (@define\s+(?<kind>)\s+(?<value>.*?))
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Decode
22
- VERSION = "0.18.0"
22
+ VERSION = "0.18.3"
23
23
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -36,7 +36,7 @@ cert_chain:
36
36
  RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
37
37
  HiLJ8VOFx6w=
38
38
  -----END CERTIFICATE-----
39
- date: 2022-06-28 00:00:00.000000000 Z
39
+ date: 2022-07-08 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: parser
metadata.gz.sig CHANGED
Binary file