danger-todoist 0.2.0 → 0.3.0
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/CHANGELOG.md +4 -0
- data/README.md +19 -3
- data/lib/danger_plugin.rb +1 -0
- data/lib/todoist/diff_todo_finder.rb +1 -4
- data/lib/todoist/gem_version.rb +1 -1
- data/lib/todoist/plugin.rb +20 -3
- data/lib/todoist/todo.rb +4 -0
- data/spec/todoist_spec.rb +10 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c36d110785f3189707375cac0476f44b4acd8ec
|
4
|
+
data.tar.gz: 7612717fc4b352dc74d77c8e675046cb30dd79dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163b2adc591716885f98dcdbcd868b81c20d4bbcaedde0d0e55096bcea8f975168ff5a8b167a3624660fab15e71aaa5e15c5fffa9e605e88bd586f014bf73396
|
7
|
+
data.tar.gz: 202815e4b3142852421f26b183ac10c9ef1de906b918ff1f44c74173430ccc62c1a4630f09415d54cfe1e530e54c21332619bf07f60f7338cc2fc9c53246f8a5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,14 +15,21 @@ A description of danger-todoist.
|
|
15
15
|
|
16
16
|
### todoist
|
17
17
|
|
18
|
-
|
18
|
+
This is a danger plugin to detect any TODO/FIXME entries left in the code.
|
19
|
+
|
20
|
+
<blockquote>Ensure, by warning, there are no TODOS left in the modified code
|
19
21
|
<pre>
|
20
22
|
todoist.warn_for_todos</pre>
|
21
23
|
</blockquote>
|
22
24
|
|
23
|
-
<blockquote>
|
25
|
+
<blockquote>Ensure, by failing the build, no TODOS left in the modified code
|
24
26
|
<pre>
|
25
|
-
|
27
|
+
todoist.fail_for_todos</pre>
|
28
|
+
</blockquote>
|
29
|
+
|
30
|
+
<blockquote>Set custom warning message for warning
|
31
|
+
<pre>
|
32
|
+
todoist.message = "Please fix all TODOS"
|
26
33
|
todoist.warn_for_todos</pre>
|
27
34
|
</blockquote>
|
28
35
|
|
@@ -32,6 +39,11 @@ todoist.warn_for_todos
|
|
32
39
|
todoist.print_todos_table</pre>
|
33
40
|
</blockquote>
|
34
41
|
|
42
|
+
<blockquote>Do anything with the todos. Todos have `text` and `file` properties
|
43
|
+
<pre>
|
44
|
+
todoist.todos.each { |todo| puts todo.text }</pre>
|
45
|
+
</blockquote>
|
46
|
+
|
35
47
|
#### Attributes
|
36
48
|
|
37
49
|
`message` - Message to be shown
|
@@ -40,8 +52,12 @@ todoist.print_todos_table</pre>
|
|
40
52
|
|
41
53
|
`warn_for_todos` - Adds a warning if there are todos found in the modified code
|
42
54
|
|
55
|
+
`fail_for_todos` - Adds an error if there are todos found in the modified code
|
56
|
+
|
43
57
|
`print_todos_table` - Adds a list of offending files to the danger comment
|
44
58
|
|
59
|
+
`todos` - Returns the list of todos in the current diff set
|
60
|
+
|
45
61
|
## Development
|
46
62
|
|
47
63
|
1. Clone this repo
|
data/lib/danger_plugin.rb
CHANGED
@@ -18,13 +18,10 @@ module Danger
|
|
18
18
|
next if matches.empty?
|
19
19
|
|
20
20
|
matches.each do |match|
|
21
|
-
todos << Todo.new(diff.path, match.first.strip)
|
21
|
+
todos << Danger::Todo.new(diff.path, match.first.strip)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
todos
|
25
25
|
end
|
26
|
-
|
27
|
-
class Todo < Struct.new(:file, :text)
|
28
|
-
end
|
29
26
|
end
|
30
27
|
end
|
data/lib/todoist/gem_version.rb
CHANGED
data/lib/todoist/plugin.rb
CHANGED
@@ -20,6 +20,10 @@ module Danger
|
|
20
20
|
# todoist.warn_for_todos
|
21
21
|
# todoist.print_todos_table
|
22
22
|
#
|
23
|
+
# @example Do anything with the todos. Todos have `text` and `file` properties
|
24
|
+
#
|
25
|
+
# todoist.todos.each { |todo| puts todo.text }
|
26
|
+
#
|
23
27
|
# @see hanneskaeufler/danger-todoist
|
24
28
|
# @tags todos, fixme
|
25
29
|
#
|
@@ -58,7 +62,7 @@ module Danger
|
|
58
62
|
# @return [void]
|
59
63
|
#
|
60
64
|
def print_todos_table
|
61
|
-
|
65
|
+
find_todos if @todos.nil?
|
62
66
|
return if @todos.empty?
|
63
67
|
|
64
68
|
markdown("#### Todos left in files")
|
@@ -69,15 +73,28 @@ module Danger
|
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
76
|
+
#
|
77
|
+
# Returns the list of todos in the current diff set
|
78
|
+
#
|
79
|
+
# @return [Array of todos]
|
80
|
+
#
|
81
|
+
def todos
|
82
|
+
find_todos if @todos.nil?
|
83
|
+
@todos
|
84
|
+
end
|
85
|
+
|
72
86
|
private
|
73
87
|
|
74
88
|
def call_method_for_todos(method)
|
89
|
+
find_todos if @todos.nil?
|
90
|
+
public_send(method, message, sticky: false) unless @todos.empty?
|
91
|
+
end
|
92
|
+
|
93
|
+
def find_todos
|
75
94
|
@todos = []
|
76
95
|
return if files_of_interest.empty?
|
77
96
|
|
78
97
|
@todos = DiffTodoFinder.new.find_diffs_containing_todos(diffs_of_interest)
|
79
|
-
|
80
|
-
public_send(method, message, sticky: false) unless @todos.empty?
|
81
98
|
end
|
82
99
|
|
83
100
|
def message
|
data/lib/todoist/todo.rb
ADDED
data/spec/todoist_spec.rb
CHANGED
@@ -26,12 +26,10 @@ module Danger
|
|
26
26
|
)
|
27
27
|
|
28
28
|
allow(@dangerfile.git).to receive(:diff_for_file)
|
29
|
-
.with("some/file.rb")
|
30
|
-
.and_return(modified)
|
29
|
+
.with("some/file.rb").and_return(modified)
|
31
30
|
|
32
31
|
allow(@dangerfile.git).to receive(:diff_for_file)
|
33
|
-
.with("another/stuff.rb")
|
34
|
-
.and_return(added)
|
32
|
+
.with("another/stuff.rb").and_return(added)
|
35
33
|
|
36
34
|
allow(@dangerfile.git).to receive(:modified_files)
|
37
35
|
.and_return(["some/file.rb"])
|
@@ -58,8 +56,7 @@ module Danger
|
|
58
56
|
expect(warnings).to eq(["changed message"])
|
59
57
|
end
|
60
58
|
|
61
|
-
it "can print a report" do
|
62
|
-
@todoist.warn_for_todos
|
59
|
+
it "can print a report, even without warning first" do
|
63
60
|
@todoist.print_todos_table
|
64
61
|
|
65
62
|
expect(markdowns).to eq(
|
@@ -70,6 +67,12 @@ module Danger
|
|
70
67
|
]
|
71
68
|
)
|
72
69
|
end
|
70
|
+
|
71
|
+
it "exposes todos to the dangerfile" do
|
72
|
+
expect(@todoist.todos.length).to eq(2)
|
73
|
+
expect(@todoist.todos.first.text).to eq("some todo")
|
74
|
+
expect(@todoist.todos.last.file).to eq("another/stuff.rb")
|
75
|
+
end
|
73
76
|
end
|
74
77
|
|
75
78
|
context "changed files not containing a todo" do
|
@@ -80,8 +83,7 @@ module Danger
|
|
80
83
|
patch: "+ some added line"
|
81
84
|
)
|
82
85
|
allow(@dangerfile.git).to receive(:diff_for_file)
|
83
|
-
.with("some/file.rb")
|
84
|
-
.and_return(modified)
|
86
|
+
.with("some/file.rb").and_return(modified)
|
85
87
|
|
86
88
|
allow(@dangerfile.git).to receive(:modified_files)
|
87
89
|
.and_return(["some/file.rb"])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-todoist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hannes Käufler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/todoist/diff_todo_finder.rb
|
174
174
|
- lib/todoist/gem_version.rb
|
175
175
|
- lib/todoist/plugin.rb
|
176
|
+
- lib/todoist/todo.rb
|
176
177
|
- spec/diff_todo_finder_spec.rb
|
177
178
|
- spec/spec_helper.rb
|
178
179
|
- spec/todoist_spec.rb
|