decode 0.18.0 → 0.18.1

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: 07565b4d2600fe3cd6552192f8faae065fbd728e98f51008863326a1b4f7f743
4
- data.tar.gz: a16e3cf053d0ac25c9e0f2e596832dabf44f027edf0ad509ed7eb20559d685e5
3
+ metadata.gz: 6161432dca8cff543a44aa7077863081acc65e2c30ae5a71a6cee66c8c0ff1fa
4
+ data.tar.gz: 6881ade662a2414f923631ff5e34a90c4df6adf7501f9b973fad2a74fc231f74
5
5
  SHA512:
6
- metadata.gz: a1e7ccf9434ddd07c98ce94e64741f30af06698b9841935b99ecc0f7e5027aa76a8ce97778bade6cdaf25853f03d7ec8d2372715bd328ada2b844b4daf68c2a5
7
- data.tar.gz: 69d195150f777b3484de296ef8d093e6531856bbc111d3d75e58d806478ecb84506223f5e5372656c06df28e8e1e326817f287dcc680c9055e7286b58fd9a2d2
6
+ metadata.gz: 4f3b92e010e0d756e1462702efaef891f148ac804f2aaf9c3df4cd9f5e8a2fc5957c68fe2a9013bef25643805ff30c9c4501c66d2580d43026f5a4fe025ee277
7
+ data.tar.gz: 4bfbb2545dba5f1921c5a222bbd7fddb895a7fe29418b5280573a26a82814dee387b3377bfe6738d493059735d7a7ae444a51e3b0a8f0106166aa706b9cc2697
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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.1"
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.1
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