decode 0.14.0 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/decode/comment/attribute.rb +0 -8
- data/lib/decode/comment/node.rb +4 -4
- data/lib/decode/comment/parameter.rb +0 -4
- data/lib/decode/definition.rb +6 -2
- data/lib/decode/documentation.rb +1 -1
- data/lib/decode/language/reference.rb +1 -0
- data/lib/decode/language/ruby/block.rb +1 -1
- data/lib/decode/language/ruby/method.rb +7 -1
- data/lib/decode/scope.rb +3 -0
- data/lib/decode/segment.rb +1 -1
- data/lib/decode/source.rb +16 -0
- data/lib/decode/trie.rb +1 -1
- data/lib/decode/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b10527900f968f995dfb80150dbe8773f92857f190fe5ae3981af28363473530
|
4
|
+
data.tar.gz: c58a678e66c1416ebc3c7a19dae19789644c937e990343ec4ea3bc565ee991a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5110378a537c6ee3ddb571a9d376af274e45ddf9835b347ac538a858eea5f140610e3cd04fa2e14c9c4c2e46a75f32adc7dbd10c39ac7de438ae2955336e7c
|
7
|
+
data.tar.gz: fd1b0e0bbc3912cd3eedfab8bf0b0e8c2bdcda930783f08305a7de9e92f2629e0b500f727dfd92a52958b283e429636ca8a3b83f1345de98bf59257bd17fc415
|
data/lib/decode/comment/node.rb
CHANGED
@@ -63,11 +63,11 @@ module Decode
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Traverse the tags from this node using {each}.
|
66
|
-
# Invoke `descend.call` to traverse the
|
66
|
+
# Invoke `descend.call(child)` to recursively traverse the specified child.
|
67
67
|
#
|
68
|
-
# @
|
69
|
-
#
|
70
|
-
#
|
68
|
+
# @yields {|node, descend| descend.call}
|
69
|
+
# @parameter node [Node] The current node which is being traversed.
|
70
|
+
# @parameter descend [Proc | Nil] The recursive method for traversing children.
|
71
71
|
def traverse(&block)
|
72
72
|
descend = ->(node){
|
73
73
|
node.traverse(&block)
|
data/lib/decode/definition.rb
CHANGED
@@ -44,12 +44,15 @@ module Decode
|
|
44
44
|
|
45
45
|
# The symbol name.
|
46
46
|
# e.g. `:Decode`.
|
47
|
+
# @attribute [Symbol]
|
47
48
|
attr :name
|
48
49
|
|
49
|
-
# The parent
|
50
|
+
# The parent definition, defining lexical scope.
|
51
|
+
# @attribute [Definition | Nil]
|
50
52
|
attr :parent
|
51
53
|
|
52
54
|
# The language the symbol is defined within.
|
55
|
+
# @attribute [Language::Generic]
|
53
56
|
attr :language
|
54
57
|
|
55
58
|
# The comment lines which directly preceeded the definition.
|
@@ -83,7 +86,8 @@ module Decode
|
|
83
86
|
raise ArgumentError, "Unable to convert #{self} into #{kind}!"
|
84
87
|
end
|
85
88
|
|
86
|
-
# The lexical scope
|
89
|
+
# The lexical scope as an array of names.
|
90
|
+
# e.g. `[:Decode, :Definition]`
|
87
91
|
# @returns [Array]
|
88
92
|
def path
|
89
93
|
if @path
|
data/lib/decode/documentation.rb
CHANGED
@@ -52,9 +52,15 @@ module Decode
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
# The fully qualified name of the block.
|
56
|
+
# e.g. `::Barnyard#foo`.
|
57
|
+
def qualified_form
|
58
|
+
self.qualified_name
|
59
|
+
end
|
60
|
+
|
55
61
|
def convert(kind)
|
56
62
|
case kind
|
57
|
-
when :
|
63
|
+
when :attribute
|
58
64
|
Attribute.new(@node, @name,
|
59
65
|
comments: @comments, parent: @parent, language: @language
|
60
66
|
)
|
data/lib/decode/scope.rb
CHANGED
@@ -23,10 +23,13 @@ require_relative 'definition'
|
|
23
23
|
module Decode
|
24
24
|
# An abstract namespace for nesting definitions.
|
25
25
|
class Scope < Definition
|
26
|
+
# @returns [String] The name of the scope.
|
26
27
|
def short_form
|
27
28
|
@name
|
28
29
|
end
|
29
30
|
|
31
|
+
# Scopes are always containers.
|
32
|
+
# @returns [Boolean] Always `true`.
|
30
33
|
def container?
|
31
34
|
true
|
32
35
|
end
|
data/lib/decode/segment.rb
CHANGED
data/lib/decode/source.rb
CHANGED
@@ -21,20 +21,32 @@
|
|
21
21
|
require_relative 'language'
|
22
22
|
|
23
23
|
module Decode
|
24
|
+
# Represents a source file in a specific language.
|
24
25
|
class Source
|
25
26
|
def initialize(path, language)
|
26
27
|
@path = path
|
27
28
|
@language = language
|
28
29
|
end
|
29
30
|
|
31
|
+
# The path of the source file.
|
32
|
+
# @attribute [String] A file-system path.
|
30
33
|
attr :path
|
31
34
|
|
35
|
+
# The language of the source file.
|
36
|
+
# @attribute [Language::Generic]
|
32
37
|
attr :language
|
33
38
|
|
39
|
+
# Open the source file for reading.
|
40
|
+
# @yields {|file| ...} The opened {File} instance.
|
41
|
+
# @parameter file [File]
|
34
42
|
def open(&block)
|
35
43
|
File.open(@path, &block)
|
36
44
|
end
|
37
45
|
|
46
|
+
# Open the source file and read all definitions.
|
47
|
+
# @yields {|definition| ...} All definitions from the source file.
|
48
|
+
# @parameter definition [Definition]
|
49
|
+
# @returns [Enumerator(Definition)] If no block given.
|
38
50
|
def definitions(&block)
|
39
51
|
return to_enum(:definitions) unless block_given?
|
40
52
|
|
@@ -43,6 +55,10 @@ module Decode
|
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
58
|
+
# Open the source file and read all segments.
|
59
|
+
# @yields {|segment| ...} All segments from the source file.
|
60
|
+
# @parameter segment [Segment]
|
61
|
+
# @returns [Enumerator(Segment)] If no block given.
|
46
62
|
def segments(&block)
|
47
63
|
return to_enum(:segments) unless block_given?
|
48
64
|
|
data/lib/decode/trie.rb
CHANGED
data/lib/decode/version.rb
CHANGED