decode 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bake/decode/index.rb +27 -0
- data/lib/decode/index.rb +8 -7
- data/lib/decode/language/ruby/reference.rb +7 -5
- data/lib/decode/language.rb +15 -2
- data/lib/decode/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07f79e45df5df94f23f1f47cc1a25d750da2d23b35223fec16424cfcb29151b9
|
4
|
+
data.tar.gz: e95e753098856a90efa1c0c92abae58f7b47f8105549aa4fd40e8d6cda1b0e18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0538b3e5f1bc385726957c7ae3e1227706e007ffedf14b3d49794551804403d7f97762b070d6bccba75690dea05d366212826584c80dfada4617902f7a6f4f74'
|
7
|
+
data.tar.gz: 66bc9443f5615e2e64ab8d4bc294940642cc89f34f22914d9232099b0cff5d453c36a744aec024954c9f9d57582cd4a8d50588851abeee7de5d7ed811557b0e3
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# Process the given source root and report on comment coverage.
|
3
|
+
# @param root [String] The root path to index.
|
4
|
+
def coverage(root)
|
5
|
+
require 'build/files/glob'
|
6
|
+
require 'decode/index'
|
7
|
+
|
8
|
+
paths = Build::Files::Path.expand(root).glob("**/*")
|
9
|
+
|
10
|
+
index = Decode::Index.new
|
11
|
+
index.update(paths)
|
12
|
+
|
13
|
+
total = 0
|
14
|
+
documented = 0
|
15
|
+
|
16
|
+
index.definitions.each do |name, definition|
|
17
|
+
total += 1
|
18
|
+
|
19
|
+
if comments = definition.comments
|
20
|
+
documented += 1
|
21
|
+
else
|
22
|
+
$stderr.puts "#{name}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
$stderr.puts "#{documented}/#{total} definitions have documentation."
|
27
|
+
end
|
data/lib/decode/index.rb
CHANGED
@@ -52,14 +52,15 @@ module Decode
|
|
52
52
|
# @param paths [Array(String)] The source file paths.
|
53
53
|
def update(paths)
|
54
54
|
paths.each do |path|
|
55
|
-
source = Source.
|
56
|
-
|
57
|
-
|
58
|
-
source.definitions do |symbol|
|
59
|
-
# $stderr.puts "Adding #{symbol.qualified_name} to #{symbol.lexical_path.join(' -> ')}"
|
55
|
+
if source = Source.for?(path)
|
56
|
+
@sources[path] = source
|
60
57
|
|
61
|
-
|
62
|
-
|
58
|
+
source.definitions do |symbol|
|
59
|
+
# $stderr.puts "Adding #{symbol.qualified_name} to #{symbol.lexical_path.join(' -> ')}"
|
60
|
+
|
61
|
+
@definitions[symbol.qualified_name] = symbol
|
62
|
+
@trie.insert(symbol.path, symbol)
|
63
|
+
end
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
@@ -24,21 +24,23 @@ module Decode
|
|
24
24
|
# An Ruby-specific reference which can be resolved to zero or more definitions.
|
25
25
|
class Reference
|
26
26
|
# Initialize the reference.
|
27
|
-
# @param
|
28
|
-
def initialize(
|
29
|
-
@
|
27
|
+
# @param text [String] The text text of the reference.
|
28
|
+
def initialize(text)
|
29
|
+
@text = text
|
30
30
|
|
31
31
|
@lexical_path = nil
|
32
32
|
@path = nil
|
33
33
|
end
|
34
34
|
|
35
|
+
attr :text
|
36
|
+
|
35
37
|
# Whether the reference starts at the base of the lexical tree.
|
36
38
|
def absolute?
|
37
|
-
@
|
39
|
+
@text.start_with?('::')
|
38
40
|
end
|
39
41
|
|
40
42
|
def lexical_path
|
41
|
-
@lexical_path ||= @
|
43
|
+
@lexical_path ||= @text.scan(/(::|\.|#|:)?([^:.#]+)/)
|
42
44
|
end
|
43
45
|
|
44
46
|
def best(definitions)
|
data/lib/decode/language.rb
CHANGED
@@ -24,10 +24,23 @@ module Decode
|
|
24
24
|
# Language specific parsers and definitions.
|
25
25
|
module Language
|
26
26
|
def self.detect(path)
|
27
|
-
case
|
28
|
-
when
|
27
|
+
case path
|
28
|
+
when /\.(rb|ru)\z/
|
29
29
|
return Language::Ruby
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
REFERENCE = /\A(?<language>\.[a-z]+)?\s+(?<text>.*?)\z/
|
34
|
+
|
35
|
+
# A language agnostic reference:
|
36
|
+
# e.g. `.rb MyModule::MyClass`
|
37
|
+
#
|
38
|
+
def self.reference(string, language = nil)
|
39
|
+
if match = REFERENCE.match(string)
|
40
|
+
language = self.detect(match[:language]) || language
|
41
|
+
|
42
|
+
return language.reference(match[:text])
|
43
|
+
end
|
44
|
+
end
|
32
45
|
end
|
33
46
|
end
|
data/lib/decode/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rspec"
|
121
121
|
- README.md
|
122
|
+
- bake/decode/index.rb
|
122
123
|
- decode.gemspec
|
123
124
|
- gems.rb
|
124
125
|
- guides/extract-symbols/extract.rb
|