danger-todoist 0.3.0 → 1.0.0

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
  SHA1:
3
- metadata.gz: 6c36d110785f3189707375cac0476f44b4acd8ec
4
- data.tar.gz: 7612717fc4b352dc74d77c8e675046cb30dd79dd
3
+ metadata.gz: cd9c28016359b27e3cc65bfee31b76086743db32
4
+ data.tar.gz: 6f24675207d0aef9ce0ef092fca5b8431d91327c
5
5
  SHA512:
6
- metadata.gz: 163b2adc591716885f98dcdbcd868b81c20d4bbcaedde0d0e55096bcea8f975168ff5a8b167a3624660fab15e71aaa5e15c5fffa9e605e88bd586f014bf73396
7
- data.tar.gz: 202815e4b3142852421f26b183ac10c9ef1de906b918ff1f44c74173430ccc62c1a4630f09415d54cfe1e530e54c21332619bf07f60f7338cc2fc9c53246f8a5
6
+ metadata.gz: d67dc9615ec24a7e81100f9855194a0d07c97ff6fbae3cf9f4a4582486a310c7e86ece35d497a31f9dbe9d0d445bfe3c77c79b3c6ff880a6defeeda2f8a4e697
7
+ data.tar.gz: 82c158c181261b48cdefa2d5918aa999be4514ec4ca5f3edadfc0c0014b773855818b66e0187e3dc3764defa80e0140565e90c9800fc3ab05ac0b6022d81175d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## master
2
2
 
3
+ ## 1.0.0
4
+
5
+ * group todos by file - hanneskaeufler
6
+
3
7
  ## 0.3.0
4
8
 
5
9
  * exposed `todoist.todos` to dangerfile - hanneskaeufler
data/README.md CHANGED
@@ -2,21 +2,18 @@
2
2
 
3
3
  # danger-todoist
4
4
 
5
- A description of danger-todoist.
5
+ danger-todoist is a [https://danger.systems](danger) plugin to automatically notify you of
6
+ todos left in the code of a pull/merge request.
6
7
 
7
8
  ## Installation
8
9
 
9
- $ gem install danger-todoist
10
+ Add `gem 'danger-todoist'` to your `Gemfile` and start using todoist in your `Dangerfile`.
10
11
 
11
12
  ## Usage
12
13
 
13
14
  Methods and attributes from this plugin are available in
14
15
  your `Dangerfile` under the `todoist` namespace.
15
16
 
16
- ### todoist
17
-
18
- This is a danger plugin to detect any TODO/FIXME entries left in the code.
19
-
20
17
  <blockquote>Ensure, by warning, there are no TODOS left in the modified code
21
18
  <pre>
22
19
  todoist.warn_for_todos</pre>
@@ -1,3 +1,3 @@
1
1
  module Todoist
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "1.0.0".freeze
3
3
  end
@@ -67,10 +67,9 @@ module Danger
67
67
 
68
68
  markdown("#### Todos left in files")
69
69
 
70
- @todos.each do |todo|
71
- text = ": #{todo.text}" if todo.text
72
- markdown("- #{todo.file}#{text}")
73
- end
70
+ @todos
71
+ .group_by(&:file)
72
+ .each { |file, todos| print_todos_per_file(file, todos) }
74
73
  end
75
74
 
76
75
  #
@@ -85,6 +84,13 @@ module Danger
85
84
 
86
85
  private
87
86
 
87
+ def print_todos_per_file(file, todos)
88
+ markdown("- #{file}")
89
+ todos
90
+ .select(&:text)
91
+ .each { |todo| markdown(" - #{todo.text}") }
92
+ end
93
+
88
94
  def call_method_for_todos(method)
89
95
  find_todos if @todos.nil?
90
96
  public_send(method, message, sticky: false) unless @todos.empty?
data/spec/spec_helper.rb CHANGED
@@ -57,3 +57,15 @@ def testing_dangerfile
57
57
  env = Danger::EnvironmentManager.new(testing_env)
58
58
  Danger::Dangerfile.new(env, testing_ui)
59
59
  end
60
+
61
+ def failures
62
+ @dangerfile.status_report[:errors]
63
+ end
64
+
65
+ def warnings
66
+ @dangerfile.status_report[:warnings]
67
+ end
68
+
69
+ def markdowns
70
+ @dangerfile.status_report[:markdowns].map(&:message)
71
+ end
data/spec/todoist_spec.rb CHANGED
@@ -14,10 +14,17 @@ module Danger
14
14
 
15
15
  context "changed files containing newly introduced todos" do
16
16
  before do
17
+ patch = <<PATCH
18
+ + # TODO: some todo
19
+ + def foo
20
+ + end
21
+ + # TODO: more todo in same file
22
+ PATCH
23
+
17
24
  modified = Git::Diff::DiffFile.new(
18
25
  "base",
19
26
  path: "some/file.rb",
20
- patch: "+ # TODO: some todo"
27
+ patch: patch
21
28
  )
22
29
  added = Git::Diff::DiffFile.new(
23
30
  "base",
@@ -62,14 +69,17 @@ module Danger
62
69
  expect(markdowns).to eq(
63
70
  [
64
71
  "#### Todos left in files",
65
- "- some/file.rb: some todo",
66
- "- another/stuff.rb: another todo"
72
+ "- some/file.rb",
73
+ " - some todo",
74
+ " - more todo in same file",
75
+ "- another/stuff.rb",
76
+ " - another todo"
67
77
  ]
68
78
  )
69
79
  end
70
80
 
71
81
  it "exposes todos to the dangerfile" do
72
- expect(@todoist.todos.length).to eq(2)
82
+ expect(@todoist.todos.length).to eq(3)
73
83
  expect(@todoist.todos.first.text).to eq("some todo")
74
84
  expect(@todoist.todos.last.file).to eq("another/stuff.rb")
75
85
  end
@@ -104,23 +114,13 @@ module Danger
104
114
  allow(@dangerfile.git).to receive(:added_files).and_return([])
105
115
 
106
116
  @todoist.warn_for_todos
117
+ @todoist.fail_for_todos
107
118
  @todoist.print_todos_table
108
119
 
109
120
  expect(warnings).to be_empty
121
+ expect(failures).to be_empty
110
122
  expect(markdowns).to be_empty
111
123
  end
112
124
  end
113
-
114
- def failures
115
- @dangerfile.status_report[:errors]
116
- end
117
-
118
- def warnings
119
- @dangerfile.status_report[:warnings]
120
- end
121
-
122
- def markdowns
123
- @dangerfile.status_report[:markdowns].map(&:message)
124
- end
125
125
  end
126
126
  end
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.3.0
4
+ version: 1.0.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-07 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api