rdoc_rubocop 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc7dd7e8471a9d59a7668685147fb01cca5e276e5d11bf2ac53db9be878ac69e
4
- data.tar.gz: 8ba0104b9af90e5ef95795e41c7ca47bc668e7eaf933db7eaea50ff6ba2ced16
3
+ metadata.gz: 13ec1f1f83f72d7d0d3a52826863bde165b9591a6c2de4c65e3e0d8e1d171304
4
+ data.tar.gz: 3d7d930cfe7fdbd1be58116536bb25a4977ce37f3fb13bfea7d36286b2a04da1
5
5
  SHA512:
6
- metadata.gz: 581b246e948d31063d973ff5c3ef8bf767fc1be7859815b4a7c90317d55239177cabf20df7ab8d3c916a966d61e32c1144babcb52d6b4731d7b6bff7f12c404c
7
- data.tar.gz: d7e5fb782c2282cd52063d5fa685bfea0ff5c801e584f096320d330be125676f4f76ca7cf8caa606ce176feb0a2cfba2e851b4e63044083f825fec3d8fe5e43e
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 comment_tokens
24
- tokens.select(&:on_comment?)
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
@@ -10,7 +10,7 @@ module RDocRuboCop
10
10
  SPACE_CHAR * indent_after_comment
11
11
  end
12
12
 
13
- def on_comment?
13
+ def comment?
14
14
  true
15
15
  end
16
16
 
@@ -26,8 +26,12 @@ module RDocRuboCop
26
26
  @locate[1]
27
27
  end
28
28
 
29
- def on_comment?
30
- false
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
@@ -1,3 +1,3 @@
1
1
  module RDocRuboCop
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loose Coupling