comment_collector 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +3 -0
- data/Gemfile.lock +5 -1
- data/README.md +2 -2
- data/comment_collector.gemspec +3 -1
- data/lib/comment_collector.rb +13 -8
- data/lib/comment_collector/version.rb +1 -1
- metadata +19 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9442e8e2379b44671f01e6b7febcfc1b1ff7ee28d85fe96acf855e03ec451f68
|
4
|
+
data.tar.gz: 7dcff69ec142cccb629efb610c13b79c8b1d1f13ff48bdf6dae2aa2c3ebdbde8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91a856c21725733c3f42f5ea883de67e8df238dc574ed6cce7ca276d64cd8df4c8c6ab4e679ad55f138d5e6139b2ec45f0d2685effe4bd2a1c0f90e38375732b
|
7
|
+
data.tar.gz: 4bac0b1c7b62a24a0f5c20fdeb748b6129e658734beb6aba76c1c3c55b4adcf04aa2dc887d090cba45fdf2fae719bdfbad38e14e72cb6ccaa16b22d471c9a06f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
comment_collector (0.0.
|
4
|
+
comment_collector (0.0.2)
|
5
|
+
parser
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
10
|
+
ast (2.4.0)
|
9
11
|
diff-lcs (1.3)
|
12
|
+
parser (2.5.1.0)
|
13
|
+
ast (~> 2.4.0)
|
10
14
|
rake (10.5.0)
|
11
15
|
rspec (3.7.0)
|
12
16
|
rspec-core (~> 3.7.0)
|
data/README.md
CHANGED
data/comment_collector.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = %q{Commenct collector}
|
13
13
|
spec.homepage = 'https://github.com/siman-man/comment_collector'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '
|
15
|
+
spec.required_ruby_version = '>= 2.3.0'
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
|
+
spec.add_dependency 'parser'
|
27
|
+
|
26
28
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
27
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
data/lib/comment_collector.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'parser/current'
|
1
2
|
require 'comment_collector/version'
|
2
3
|
|
3
4
|
class CommentCollector
|
@@ -13,7 +14,7 @@ class CommentCollector
|
|
13
14
|
@end_of_lines = src.lines.map { |l| l.size - 1 } # for 0-index
|
14
15
|
@src = src
|
15
16
|
|
16
|
-
traverse(
|
17
|
+
traverse(Parser::CurrentRuby.parse(src))
|
17
18
|
end
|
18
19
|
|
19
20
|
def comments
|
@@ -27,7 +28,7 @@ class CommentCollector
|
|
27
28
|
|
28
29
|
@src.lines.each_with_index do |line, lineno|
|
29
30
|
sp = @last_of_lines[lineno]
|
30
|
-
l = line[sp
|
31
|
+
l = line[sp..-1]
|
31
32
|
|
32
33
|
break if line.start_with?('__END__')
|
33
34
|
|
@@ -74,18 +75,22 @@ class CommentCollector
|
|
74
75
|
private
|
75
76
|
|
76
77
|
def traverse(parent)
|
77
|
-
if parent.
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
return if parent.nil?
|
79
|
+
|
80
|
+
loc = parent.loc
|
81
|
+
|
82
|
+
unless [:args].include?(parent.type)
|
83
|
+
first_lineno = loc.line - 1
|
84
|
+
first_column = loc.column
|
85
|
+
last_lineno = loc.last_line - 1
|
86
|
+
last_column = loc.last_column
|
82
87
|
|
83
88
|
@last_of_lines[first_lineno] = [@last_of_lines[first_lineno], first_column].max
|
84
89
|
@last_of_lines[last_lineno] = [@last_of_lines[last_lineno], last_column].max
|
85
90
|
@exists_any_node[first_lineno] = @exists_any_node[last_lineno] = true
|
86
91
|
end
|
87
92
|
|
88
|
-
parent.children.
|
93
|
+
parent.children.select { |n| n.instance_of?(Parser::AST::Node) }.each do |child|
|
89
94
|
traverse(child)
|
90
95
|
end
|
91
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comment_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shuichi Tamayose
|
@@ -34,8 +34,22 @@ cert_chain:
|
|
34
34
|
qhBmALr0zPrR292f2IxpPPpA3EGv375Yy0dblIxJ2U0C0p2JafJlIbdzTttaG+nR
|
35
35
|
hYkTSRBLdxDTa7SbFGW40+TWobTOX/itwk9w0F6Zo7Y=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2018-06-
|
37
|
+
date: 2018-06-19 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: parser
|
41
|
+
requirement: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
39
53
|
- !ruby/object:Gem::Dependency
|
40
54
|
name: bundler
|
41
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,9 +123,9 @@ require_paths:
|
|
109
123
|
- lib
|
110
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
125
|
requirements:
|
112
|
-
- - "
|
126
|
+
- - ">="
|
113
127
|
- !ruby/object:Gem::Version
|
114
|
-
version: 2.
|
128
|
+
version: 2.3.0
|
115
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
130
|
requirements:
|
117
131
|
- - ">="
|
@@ -119,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
133
|
version: '0'
|
120
134
|
requirements: []
|
121
135
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.7.
|
136
|
+
rubygems_version: 2.7.6
|
123
137
|
signing_key:
|
124
138
|
specification_version: 4
|
125
139
|
summary: Commenct collector
|
metadata.gz.sig
CHANGED
Binary file
|