rdoc_rubocop 0.1.2 → 0.1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13ec1f1f83f72d7d0d3a52826863bde165b9591a6c2de4c65e3e0d8e1d171304
|
4
|
+
data.tar.gz: 3d7d930cfe7fdbd1be58116536bb25a4977ce37f3fb13bfea7d36286b2a04da1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e715471260f29ed62a3def4673bc4060bf043965c572393c52db3d7e6d34861a34d3d74ebf5d41c2e66724d66c6b85759ad221077f6818865bce3c3fc1157b
|
7
|
+
data.tar.gz: 948ba86f073bd6c9205540116e96026f9c59a5591d4f1381f7ef2a8335e70800df426346615c772bdc3b72a177477db707ac2b9666d66ce43f79e7a09936748d
|
@@ -12,22 +12,42 @@ module RDocRuboCop
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def extract
|
15
|
-
@comments =
|
16
|
-
comment_tokens.
|
17
|
-
slice_when { |token_before, token_after| token_after.lineno - token_before.lineno > 1 }.
|
18
|
-
map { |comment_tokens| Comment.new(comment_tokens, @source_file) }
|
15
|
+
@comments = extract_comments
|
19
16
|
end
|
20
17
|
|
21
18
|
private
|
22
19
|
|
23
|
-
def
|
24
|
-
|
20
|
+
def extract_comments
|
21
|
+
chunk = []
|
22
|
+
comments = []
|
23
|
+
|
24
|
+
tokens.each do |tokens_in_line|
|
25
|
+
token = tokens_in_line.pop
|
26
|
+
|
27
|
+
if token.comment?
|
28
|
+
if tokens_in_line.all?(&:sp?)
|
29
|
+
chunk << token
|
30
|
+
else
|
31
|
+
comments << Comment.new(chunk, @source_file) if chunk.any?
|
32
|
+
chunk = [token]
|
33
|
+
end
|
34
|
+
else
|
35
|
+
if chunk.any?
|
36
|
+
comments << Comment.new(chunk, @source_file)
|
37
|
+
chunk = []
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
comments << Comment.new(chunk, @source_file) if chunk.any?
|
42
|
+
|
43
|
+
comments
|
25
44
|
end
|
26
45
|
|
27
46
|
def tokens
|
28
47
|
Ripper.
|
29
48
|
lex(@source_file.source).
|
30
|
-
map { |token| Token.build(*token) }
|
49
|
+
map { |token| Token.build(*token) }.
|
50
|
+
slice_when { |token_before, token_after| token_before.lineno != token_after.lineno }
|
31
51
|
end
|
32
52
|
end
|
33
53
|
end
|
data/lib/rdoc_rubocop/token.rb
CHANGED
@@ -26,8 +26,12 @@ module RDocRuboCop
|
|
26
26
|
@locate[1]
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
%i(on_sp on_comment).each do |type|
|
30
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
31
|
+
def #{type.to_s.sub(/^on_/, "")}? # def sp?
|
32
|
+
type == :#{type} # type == :on_sp
|
33
|
+
end # end
|
34
|
+
RUBY
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/rdoc_rubocop/version.rb
CHANGED