danger-jazzy 0.1.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35d58202f487e509470c90aab65fa9cea18e90a0
4
- data.tar.gz: 05dfed94d0ae49d856ace9152dc9baf416239af6
3
+ metadata.gz: e8bb53cde4ba129560e1f27e05941d12307f34ac
4
+ data.tar.gz: d73cfb80d5771789f127f82a92a461c2e55f487a
5
5
  SHA512:
6
- metadata.gz: 0a10983eb00e1005984ce3ac4bf313c40d08a2c9b85404e304f79d21bc96ce892b15a0ca36af22e3fc98c94dff97fd48e92b7bb71440729f45c07d87a30e5775
7
- data.tar.gz: 53c25744ba1dd7f8822344160fc678b4029125c2dfd00155247e26995268681320523fce11b928938f0bd39830704279d91cb46750ddae4f24d73691f6fb6218
6
+ metadata.gz: 5471744bf514104875f84a8f6a60755b8cb6e3ee126331930031111bb4e75208d15becd15c3fcb5be878a9683e7b5cb29278090c79bf3d457bd95223537ede85
7
+ data.tar.gz: cc5e4e7196b8ffe0bfc3bc1502ea5aee9c2d23677e965ac4a4bbb4fa12177b9824058911bfb9e80cf03972529d722778dbba11f1e35c64f9e9ba3cae160e9a03
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pkg
3
3
  .idea/
4
4
  .yardoc/
5
5
  Gemfile.lock
6
+ coverage/
@@ -0,0 +1,20 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.0
5
+ Exclude:
6
+ - 'spec/fixtures/**/*'
7
+ - 'lib/danger/plugin_support/plugin_parser.rb'
8
+
9
+ Metrics/LineLength:
10
+ Exclude:
11
+ - 'spec/*'
12
+ - 'danger-jazzy.gemspec'
13
+
14
+ Style/IfUnlessModifier:
15
+ Exclude:
16
+ - 'Gemfile'
17
+
18
+ Style/SpecialGlobalVars:
19
+ Exclude:
20
+ - 'danger-jazzy.gemspec'
@@ -1,5 +1,8 @@
1
1
  ## [Unreleased][]
2
2
 
3
+ ## [1.0.0][] (2016-11-22)
4
+ * Completely new api!
5
+
3
6
  ## [0.1.1][] (2016-11-09)
4
7
  * Bugfixes.
5
8
 
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in danger-jazzy.gemspec
4
4
  gemspec
5
5
 
6
- gem 'chandler', '~> 0.5.0'
6
+ if RUBY_VERSION == '2.3.1'
7
+ gem 'chandler', '~> 0.5.0'
8
+ end
data/README.md CHANGED
@@ -1,26 +1,58 @@
1
1
  ### jazzy
2
2
  This is a danger plugin to check for undocumented symbols via Jazzy.
3
3
 
4
- <blockquote>Warn about undocumented symbols.
4
+ <blockquote>Fail on undocumented symbols in modified files.
5
5
  <pre>
6
- jazzy.warn_of_undocumented</pre>
6
+ jazzy.check</pre>
7
7
  </blockquote>
8
8
 
9
- <blockquote>Write a custom message for undocumented symbols.
9
+ <blockquote>Fail on undocumented symbols in all files.
10
10
  <pre>
11
- jazzy.undocumented do |file,line|
12
- message("You forgot to document this", file:file, line:line)
11
+ jazzy.check fail: :all</pre>
12
+ </blockquote>
13
+
14
+ <blockquote>Warn about undocumented symbols in modified files.
15
+ <pre>
16
+ jazzy.check warn: :modified</pre>
17
+ </blockquote>
18
+
19
+ <blockquote>Write a custom message for undocumented symbols in modified files.
20
+ <pre>
21
+ jazzy.undocumented.each do |item|
22
+ message "You forgot to document this", file:item.file, line:item.line
23
+ end</pre>
24
+ </blockquote>
25
+
26
+ <blockquote>Write a custom message for undocumented symbols in all files.
27
+ <pre>
28
+ jazzy.undocumented(:all).each do |item|
29
+ message "You forgot to document this", file:item.file, line:item.line
13
30
  end</pre>
14
31
  </blockquote>
15
32
 
16
33
 
17
34
  #### Attributes
18
35
 
19
- `path_to_docs` - Path to the docs folder, defaults to 'docs/'.
36
+ `path` - Path to the docs folder, defaults to 'docs/'.
20
37
 
21
38
 
22
39
  #### Methods
23
40
 
24
- `warn_of_undocumented` - Warns about undocumented symbols.
41
+ `check` - Checks files for modified symbols.
42
+
43
+ Takes a hash with the following keys:
44
+
45
+ * `fail`
46
+ * `warn`
47
+
48
+ Available scopes:
49
+
50
+ * `modified`
51
+ * `all`
52
+
53
+ `undocumented` - Returns a list of undocumented symbols in the current diff.
54
+
55
+ Available scopes:
25
56
 
26
- `undocumented` - Finds and yields information about undocumented symbols.
57
+ * `modified`
58
+ * `all`
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Jazzy::VERSION
9
9
  spec.authors = ['Frederik Wallner']
10
10
  spec.email = ['frederik.wallner@gmail.com']
11
- spec.description = %q{A short description of danger-jazzy.}
12
- spec.summary = %q{A longer description of danger-jazzy.}
11
+ spec.description = 'A danger plugin for validating documentation generated with jazzy'
12
+ spec.summary = 'A danger plugin for validating documentation generated with jazzy'
13
13
  spec.homepage = 'https://github.com/fwal/danger-jazzy'
14
14
  spec.license = 'MIT'
15
15
 
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.required_ruby_version = '>= 2.0.0'
22
+
21
23
  spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
24
  spec.add_runtime_dependency 'json', '~> 1.8'
23
25
 
@@ -31,6 +33,7 @@ Gem::Specification.new do |spec|
31
33
  # Linting code and docs
32
34
  spec.add_development_dependency 'rubocop', '~> 0.41'
33
35
  spec.add_development_dependency 'yard', '~> 0.8'
36
+ spec.add_development_dependency 'coveralls', '~> 0.8.15'
34
37
 
35
38
  # Makes testing easy via `bundle exec guard`
36
39
  spec.add_development_dependency 'guard', '~> 2.14'
@@ -1,3 +1,3 @@
1
1
  module Jazzy
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -1,46 +1,82 @@
1
1
  module Danger
2
+ # rubocop:disable Metrics/LineLength
2
3
  # This is a danger plugin to check for undocumented symbols via Jazzy.
3
4
  #
4
- # @example Warn about undocumented symbols.
5
+ # @example Fail on undocumented symbols in modified files.
5
6
  #
6
- # jazzy.warn_of_undocumented
7
+ # jazzy.check
7
8
  #
8
- # @example Write a custom message for undocumented symbols.
9
+ # @example Fail on undocumented symbols in all files.
9
10
  #
10
- # jazzy.undocumented do |file,line|
11
- # message("You forgot to document this", file:file, line:line)
11
+ # jazzy.check fail: :all
12
+ #
13
+ # @example Warn about undocumented symbols in modified files.
14
+ #
15
+ # jazzy.check warn: :modified
16
+ #
17
+ # @example Write a custom message for undocumented symbols in modified files.
18
+ #
19
+ # jazzy.undocumented.each do |item|
20
+ # message "You forgot to document this", file:item.file, line:item.line
21
+ # end
22
+ #
23
+ # @example Write a custom message for undocumented symbols in all files.
24
+ #
25
+ # jazzy.undocumented(:all).each do |item|
26
+ # message "You forgot to document this", file:item.file, line:item.line
12
27
  # end
13
28
  #
14
29
  # @see fwal/danger-jazzy
15
30
  # @tags jazzy, docs, documentation
16
31
  #
32
+ # rubocop:enable Metrics/LineLength
17
33
  class DangerJazzy < Plugin
18
34
  DEFAULT_MESSAGE = 'Undocumented symbol.'.freeze
19
35
 
20
36
  # Path to the docs folder, defaults to 'docs/'.
21
37
  # @return [String]
22
- attr_accessor :path_to_docs
38
+ attr_accessor :path
23
39
 
24
- # Warns about undocumented symbols.
25
- # @return [void]
26
- def warn_of_undocumented
27
- undocumented.each do |item|
28
- warn DEFAULT_MESSAGE, file: item.file, line: item.line
29
- end
40
+ # Checks files for modified symbols.
41
+ #
42
+ # Takes a hash with the following keys:
43
+ #
44
+ # * `fail`
45
+ # * `warn`
46
+ #
47
+ # Available scopes:
48
+ #
49
+ # * `modified`
50
+ # * `all`
51
+ #
52
+ # @param [Hash] config
53
+ # @return [void]
54
+ def check(config = {})
55
+ @config = config
56
+ fail_check
57
+ warn_check
30
58
  end
31
59
 
32
60
  # Returns a list of undocumented symbols in the current diff.
61
+ #
62
+ # Available scopes:
63
+ #
64
+ # * `modified`
65
+ # * `all`
66
+ #
67
+ # @param [Key] scope
33
68
  # @return [Array of symbol]
34
- def undocumented
35
- return unless File.exist? undocumented_path
36
- load_undocumented if @undocumented.nil?
37
- @undocumented
69
+ def undocumented(scope = :modified)
70
+ return [] unless scope != :ignore && File.exist?(undocumented_path)
71
+ @undocumented = { modified: [], all: [] } if @undocumented.nil?
72
+ load_undocumented(scope) if @undocumented[scope].empty?
73
+ @undocumented[scope]
38
74
  end
39
75
 
40
76
  private
41
77
 
42
78
  def docs_path
43
- @path_to_docs || 'docs/'
79
+ @path || 'docs/'
44
80
  end
45
81
 
46
82
  def undocumented_path
@@ -51,10 +87,36 @@ module Danger
51
87
  git.modified_files + git.added_files
52
88
  end
53
89
 
54
- def load_undocumented
90
+ def load_undocumented(scope)
55
91
  reader = UndocumentedReader.new(undocumented_path)
56
- @undocumented = reader.undocumented_symbols.select do |item|
57
- files_of_interest.include?(item.file)
92
+ @undocumented[scope] = reader.undocumented_symbols.select do |item|
93
+ if scope == :modified
94
+ files_of_interest.include?(item.file)
95
+ else
96
+ true
97
+ end
98
+ end
99
+ end
100
+
101
+ def fail_scope
102
+ @config[:fail] || :modified
103
+ end
104
+
105
+ def warn_scope
106
+ @config[:warn] || :ignore
107
+ end
108
+
109
+ def fail_check
110
+ undocumented(fail_scope).each do |item|
111
+ # rubocop:disable Style/SignalException
112
+ fail DEFAULT_MESSAGE, file: item.file, line: item.line
113
+ # rubocop:enable Style/SignalException
114
+ end
115
+ end
116
+
117
+ def warn_check
118
+ undocumented(warn_scope).each do |item|
119
+ warn DEFAULT_MESSAGE, file: item.file, line: item.line
58
120
  end
59
121
  end
60
122
  end
@@ -14,6 +14,7 @@ module Danger
14
14
  @dangerfile = testing_dangerfile
15
15
  @my_plugin = @dangerfile.jazzy
16
16
  @default_message = 'Undocumented symbol.'
17
+ @my_plugin.path = 'spec/fixtures'
17
18
  end
18
19
 
19
20
  context 'changed files contains undocumented symbols' do
@@ -42,10 +43,38 @@ module Danger
42
43
  .and_return(['MyFile.swift'])
43
44
  end
44
45
 
45
- it 'Warns on undocumented symbols' do
46
- @my_plugin.path_to_docs = 'spec/fixtures'
47
- @my_plugin.warn_of_undocumented
48
- expect(@dangerfile.status_report[:warnings]).to eq([@default_message])
46
+ it 'finds undocumented symbols only in modified files by default' do
47
+ expect(@my_plugin.undocumented.length).to eq(1)
48
+ end
49
+
50
+ it 'can find undocumented symbols in all files' do
51
+ expect(@my_plugin.undocumented(:all).length).to eq(2)
52
+ end
53
+
54
+ it 'fails on undocumented symbols only in modified files by default' do
55
+ @my_plugin.check
56
+ expect(@dangerfile.status_report[:errors]).to eq([@default_message])
57
+ end
58
+
59
+ it 'does not warn on undocumented symbols by default' do
60
+ @my_plugin.check
61
+ expect(@dangerfile.status_report[:warnings]).to eq([])
62
+ end
63
+
64
+ it 'can fail on undocumented symbols in all files' do
65
+ @my_plugin.check fail: :all
66
+ expect(@dangerfile.status_report[:errors]).to eq([@default_message, @default_message])
67
+ end
68
+
69
+ it 'can warn on undocumented symbols in all files' do
70
+ @my_plugin.check warn: :all
71
+ expect(@dangerfile.status_report[:warnings]).to eq([@default_message, @default_message])
72
+ end
73
+
74
+ it 'does not fail if there is no undocumented json' do
75
+ @my_plugin.path = 'spec/empty'
76
+ @my_plugin.check
77
+ expect(@dangerfile.status_report[:errors]).to eq([])
49
78
  end
50
79
  end
51
80
  end
@@ -9,6 +9,9 @@ require 'pry'
9
9
  require 'rspec'
10
10
  require 'danger'
11
11
 
12
+ require 'coveralls'
13
+ Coveralls.wear!
14
+
12
15
  # Use coloured output, it's the best.
13
16
  RSpec.configure do |config|
14
17
  config.filter_gems_from_backtrace 'bundler'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-jazzy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederik Wallner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.8.15
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.8.15
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: guard
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +178,7 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
- description: A short description of danger-jazzy.
181
+ description: A danger plugin for validating documentation generated with jazzy
168
182
  email:
169
183
  - frederik.wallner@gmail.com
170
184
  executables: []
@@ -172,6 +186,7 @@ extensions: []
172
186
  extra_rdoc_files: []
173
187
  files:
174
188
  - ".gitignore"
189
+ - ".rubocop.yml"
175
190
  - ".travis.yml"
176
191
  - CHANGELOG.md
177
192
  - Gemfile
@@ -201,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
216
  requirements:
202
217
  - - ">="
203
218
  - !ruby/object:Gem::Version
204
- version: '0'
219
+ version: 2.0.0
205
220
  required_rubygems_version: !ruby/object:Gem::Requirement
206
221
  requirements:
207
222
  - - ">="
@@ -212,7 +227,7 @@ rubyforge_project:
212
227
  rubygems_version: 2.5.1
213
228
  signing_key:
214
229
  specification_version: 4
215
- summary: A longer description of danger-jazzy.
230
+ summary: A danger plugin for validating documentation generated with jazzy
216
231
  test_files:
217
232
  - spec/fixtures/undocumented.json
218
233
  - spec/jazzy_spec.rb