adjutant 0.1.2 → 0.1.4
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 +4 -4
- data/lib/adjutant/file_parser.rb +10 -10
- data/lib/adjutant/line.rb +3 -5
- data/lib/adjutant/version.rb +1 -1
- data/spec/adjutant/file_parser_spec.rb +12 -3
- data/spec/adjutant/line_spec.rb +0 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ade5ef06a52ba977c6cdf02258e8b39b47336d
|
4
|
+
data.tar.gz: 4baaed035761d72a020831da9c6b80f002c83116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb8cd05f8e2b38c6d795938764a0fdb7c6dfcc10ba727dc613658c60bc170a344fa6567fb22b27385c003b8ec113646e1a596cef51cbf8d875b2df3b5e9d4c4e
|
7
|
+
data.tar.gz: 0373d16b91be83dd143fe230a080942f3fee186c5871577e1c78b744cca8b6843d5cd880ebece289bd66aec268d67c39e8282f3967aa274d82c3f4b933a12655
|
data/lib/adjutant/file_parser.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
1
3
|
module Adjutant
|
2
4
|
class FileParser
|
3
5
|
|
@@ -7,30 +9,27 @@ module Adjutant
|
|
7
9
|
@text = file[:patch]
|
8
10
|
@comment = Comment.new("")
|
9
11
|
@comments = []
|
12
|
+
@previous_was_usefull = false
|
10
13
|
end
|
11
14
|
|
12
15
|
def detect_comments
|
13
|
-
usefull = false
|
14
16
|
lines_pushed.each_with_index do |line, index|
|
15
17
|
line = Line.new(line)
|
16
|
-
|
17
|
-
if line.usefull? || usefull
|
18
|
-
usefull = true
|
18
|
+
if line.usefull? || @previous_was_usefull
|
19
19
|
parse_line(line, index)
|
20
20
|
else
|
21
|
-
push_comment
|
22
|
-
usefull = false
|
23
|
-
|
24
|
-
next
|
21
|
+
push_comment and next
|
25
22
|
end
|
26
23
|
end
|
27
|
-
|
24
|
+
|
25
|
+
push_comment if @previous_was_usefull
|
28
26
|
@comments
|
29
27
|
end
|
30
28
|
|
31
29
|
def push_comment
|
32
|
-
@comments << @comment.print
|
30
|
+
@comments << @comment.print unless comment.text.nil?
|
33
31
|
@comment.reset
|
32
|
+
@previous_was_usefull = false
|
34
33
|
end
|
35
34
|
|
36
35
|
def parse_line(line, index)
|
@@ -38,6 +37,7 @@ module Adjutant
|
|
38
37
|
push_comment
|
39
38
|
else
|
40
39
|
@comment.add line.usefull_text, index
|
40
|
+
@previous_was_usefull = true
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/lib/adjutant/line.rb
CHANGED
@@ -4,7 +4,7 @@ module Adjutant
|
|
4
4
|
USERNAME_SIGN = "@"
|
5
5
|
TODO_LINE = "TODO:"
|
6
6
|
|
7
|
-
def usefull?()
|
7
|
+
def usefull?() contain_comment? && point_of_interes? end
|
8
8
|
|
9
9
|
def contain_comment?() line.scan(/\+\s*#{COMMENT_SIGN}/).any? end
|
10
10
|
|
@@ -12,10 +12,8 @@ module Adjutant
|
|
12
12
|
def contain_username?() line.scan(/(#{USERNAME_SIGN}\w+)/).any? end
|
13
13
|
def contain_todo?() line.scan(/#{TODO_LINE}/).any? end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
17
|
-
def end_of_comment?() contain_comment?() ? empty_comment? : true end
|
18
|
-
def empty_comment?() line.scan(/\+\s*#{COMMENT_SIGN}\s*(\S+)/).empty? end
|
15
|
+
def end_of_comment?() contain_comment?() ? empty_comment? : true end
|
16
|
+
def empty_comment?() line.scan(/\+\s*#{COMMENT_SIGN}\s*(\S+)/).empty? end
|
19
17
|
|
20
18
|
def usefull_text
|
21
19
|
matched = line.scan(/\+\s*#\s*/).first
|
data/lib/adjutant/version.rb
CHANGED
@@ -3,15 +3,20 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Adjutant::FileParser do
|
4
4
|
|
5
5
|
let(:file) do
|
6
|
-
{ :patch
|
6
|
+
{ :patch=> "@@ -0,0 +1,14 @@\n+# @Baltazore is trying to check first line comment\n+def super_method(such_args)\n+ \"Doge tutorial\"\n+end\n+# useless comment\n+\"hello world\"\n+# @baltazore, Let's check multiline comments,\n+# them really rocks\n+#\n+\n+# TODO:\n+# - [ ] This Github flavoured markdown\n+# - [ ] such nice\n+# - [ ] very exciting" }
|
7
7
|
end
|
8
8
|
|
9
9
|
let(:lines) do
|
10
10
|
[
|
11
11
|
"+# @Baltazore is trying to check first line comment",
|
12
12
|
"+def super_method(such_args)",
|
13
|
+
"+ \"Doge tutorial\"",
|
14
|
+
"+end",
|
15
|
+
"+# useless comment",
|
16
|
+
"+\"hello world\"",
|
13
17
|
"+# @baltazore, Let's check multiline comments,",
|
14
18
|
"+# them really rocks",
|
19
|
+
"+#",
|
15
20
|
"+",
|
16
21
|
"+# TODO:",
|
17
22
|
"+# - [ ] This Github flavoured markdown",
|
@@ -23,13 +28,17 @@ RSpec.describe Adjutant::FileParser do
|
|
23
28
|
let(:comments) do
|
24
29
|
[
|
25
30
|
[ "@Baltazore is trying to check first line comment", 1 ],
|
26
|
-
[ "@baltazore, Let's check multiline comments,\\nthem really rocks",
|
27
|
-
[ "TODO:\\n- [ ] This Github flavoured markdown\\n- [ ] such nice\\n- [ ] very exciting",
|
31
|
+
[ "@baltazore, Let's check multiline comments,\\nthem really rocks", 7],
|
32
|
+
[ "TODO:\\n- [ ] This Github flavoured markdown\\n- [ ] such nice\\n- [ ] very exciting", 11 ]
|
28
33
|
]
|
29
34
|
end
|
30
35
|
let(:file_parser) { Adjutant::FileParser.new(file) }
|
31
36
|
|
32
37
|
describe '#detect_comments' do
|
38
|
+
it 'fineds only 3 comments here' do
|
39
|
+
expect(file_parser.detect_comments.count).to eq(3)
|
40
|
+
end
|
41
|
+
|
33
42
|
context '#lines_pushed' do
|
34
43
|
it 'returns all lines that has been pushed in commit' do
|
35
44
|
file_parser.lines_pushed.each_with_index do |line, index|
|
data/spec/adjutant/line_spec.rb
CHANGED
@@ -57,17 +57,6 @@ RSpec.describe Adjutant::Line do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
context '#new_added?' do
|
61
|
-
it 'returns true if line is new added' do
|
62
|
-
expect(Adjutant::Line.new(comment).new_added?).to eq(true)
|
63
|
-
expect(Adjutant::Line.new(todo).new_added?).to eq(true)
|
64
|
-
expect(Adjutant::Line.new(empty).new_added?).to eq(true)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns false in other cases' do
|
68
|
-
expect(Adjutant::Line.new(useless).new_added?).to eq(false)
|
69
|
-
end
|
70
|
-
end
|
71
60
|
end
|
72
61
|
|
73
62
|
describe '#usefull_text' do
|