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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd7163400e0f5dad62167c657187a19b3b7d86d19aad2f3c2d878190e22a0853
4
- data.tar.gz: 8ec29610159563a21f8d5c70d28e1b76894912c636a6a3c893f86b936781c133
3
+ metadata.gz: 9442e8e2379b44671f01e6b7febcfc1b1ff7ee28d85fe96acf855e03ec451f68
4
+ data.tar.gz: 7dcff69ec142cccb629efb610c13b79c8b1d1f13ff48bdf6dae2aa2c3ebdbde8
5
5
  SHA512:
6
- metadata.gz: cbf8a96d9f0c327db8f7eb8423319eda02f7c92ddf0d08571ce611dc15986642d247115b2ddb2f2e329417b298a609afd37b4d8f1ed6af4721452758288b4512
7
- data.tar.gz: 76faf9432d6f64ea29a309a4238a9de4ce5de213dbf9013e3f38ec9a87154f7cf6155ffda91ec67553d3d342a046bc9f07661b10d8d26bfb2b88203dbd0db169
6
+ metadata.gz: 91a856c21725733c3f42f5ea883de67e8df238dc574ed6cce7ca276d64cd8df4c8c6ab4e679ad55f138d5e6139b2ec45f0d2685effe4bd2a1c0f90e38375732b
7
+ data.tar.gz: 4bac0b1c7b62a24a0f5c20fdeb748b6129e658734beb6aba76c1c3c55b4adcf04aa2dc887d090cba45fdf2fae719bdfbad38e14e72cb6ccaa16b22d471c9a06f
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
+ - ruby-2.3.7
5
+ - ruby-2.4.4
6
+ - ruby-2.5.1
4
7
  - ruby-2.6.0-preview2
5
8
  before_install: gem install bundler -v 1.16.2
@@ -1,12 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comment_collector (0.0.1)
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
@@ -1,9 +1,9 @@
1
+ [![Build Status](https://travis-ci.org/siman-man/comment_collector.svg?branch=master)](https://travis-ci.org/siman-man/comment_collector)
2
+
1
3
  # CommentCollector
2
4
 
3
5
  Get source code comments of Ruby.
4
6
 
5
- require RUBY_VERSION >= '2.6.0'
6
-
7
7
 
8
8
  ## Installation
9
9
 
@@ -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 = '> 2.5.9'
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'
@@ -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(RubyVM::AST.parse(src))
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.type != 'NODE_SCOPE'
78
- first_lineno = parent.first_lineno - 1
79
- first_column = parent.first_column
80
- last_lineno = parent.last_lineno - 1
81
- last_column = parent.last_column
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.compact.each do |child|
93
+ parent.children.select { |n| n.instance_of?(Parser::AST::Node) }.each do |child|
89
94
  traverse(child)
90
95
  end
91
96
  end
@@ -1,3 +1,3 @@
1
1
  class CommentCollector
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  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.1
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-18 00:00:00.000000000 Z
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.5.9
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.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