danger-prose 1.0.0 → 2.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: baec8d353bfa0f99782d3fa6774635e2415726a1
4
- data.tar.gz: bc3d97b3f5800b04dab5103c20c3e1423ae91b65
3
+ metadata.gz: cbe1a62aa5863906f879c31de1e4a73bc60cba7d
4
+ data.tar.gz: 4374a4456fcefe699660edf4ad3dcde8fbe2911e
5
5
  SHA512:
6
- metadata.gz: fee815fd988fbfd0a085c06a9d65fcda49d7275829175662f09104279fe2a0f0814e259ac780ed717bb00717e3839665353446cf06757be99736ef3526ca4377
7
- data.tar.gz: 5bed58cfa62e809440227c39e7fa19946c8d1fe4a7dfdfa1167e7a454dd388c5f6059085cb2bce06096ecc0ad00c98e759974ffe5e547e4bbf4eac8047cc69db
6
+ metadata.gz: 4dbb3ac28eeff44f3c1d7ba4f374011520b81d8aa2b7ef199ea0f9e075c396dc706ebfb1727cef203cf87dc3e21674fea0f4765b535d56155140f2dff9235419
7
+ data.tar.gz: 1e5a007df22b038d54b87a6919f3693a3a89d3609680bd59ca5b561b2ba515b467a4074c44ce485c6a3ec58ed6d4caac03a265137f2e75472274f3cad1a51655
data/.travis.yml CHANGED
@@ -10,4 +10,4 @@ rvm:
10
10
 
11
11
  script:
12
12
  - bundle exec rake spec
13
- # - bundle exec danger plugin lint
13
+ - bundle exec danger plugin lint
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-prose (0.0.1)
4
+ danger-prose (2.0.0)
5
5
  danger
6
6
 
7
7
  GEM
@@ -14,7 +14,7 @@ GEM
14
14
  colored (1.2)
15
15
  cork (0.1.0)
16
16
  colored (~> 1.2)
17
- danger (0.8.3)
17
+ danger (0.8.5)
18
18
  claide (~> 1.0)
19
19
  colored (~> 1.2)
20
20
  cork (~> 0.1)
@@ -91,6 +91,7 @@ GEM
91
91
  slop (3.6.0)
92
92
  terminal-table (1.6.0)
93
93
  thor (0.19.1)
94
+ yard (0.8.7.6)
94
95
 
95
96
  PLATFORMS
96
97
  ruby
@@ -108,6 +109,7 @@ DEPENDENCIES
108
109
  pry
109
110
  rake (~> 10.0)
110
111
  rspec (~> 3.4)
112
+ yard (~> 0.8)
111
113
 
112
114
  BUNDLED WITH
113
115
  1.12.5
data/Guardfile CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  # To run, use `bundle exec guard`.
5
5
 
6
- guard :rspec, cmd: "bundle exec rspec" do
7
- require "guard/rspec/dsl"
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
8
  dsl = Guard::RSpec::Dsl.new(self)
9
9
 
10
10
  # Feel free to open issues for suggestions and improvements
data/README.md CHANGED
@@ -6,16 +6,44 @@ A description of danger-proselint.
6
6
 
7
7
  $ gem install danger-proselint
8
8
 
9
- ## Usage
10
9
 
11
- Add it to your Dangerfile
12
10
 
13
- ``` ruby
14
- # Look through all changed Markdown files
15
- markdown_files = (modified_files + added_files).select do |line|
16
- line.start_with?("_posts") && (line.end_with?(".markdown") || line.end_with?(".md"))
17
- end
11
+ ### prose
18
12
 
19
- # will check any .markdown files in this PR with proselint
20
- proselint.lint_files markdown_files
21
- ```
13
+ Lint markdown files inside your projects.
14
+ This is done using the [proselint](http://proselint.com) python egg.
15
+ Results are passed out as a table in markdown.
16
+
17
+ <blockquote>Specifying custom CocoaPods installation options
18
+ <pre>
19
+ # Runs a linter with comma style disabled
20
+ proselint.disable_linters = ["misc.scare_quotes", "misc.tense_present"]
21
+ proselint.lint_files "_posts/*.md"
22
+
23
+ # Runs a linter with all styles, on modified and added markdown files in this PR
24
+ proselint.lint_files</pre>
25
+ </blockquote>
26
+
27
+
28
+
29
+ #### Attributes
30
+ <tr>
31
+ `disable_linters` - Allows you to disable a collection of linters from running. Doesn't work yet.
32
+ You can get a list of [them here](https://github.com/amperser/proselint#checks)
33
+ defaults to `["misc.scare_quotes", "typography.symbols"]` when it's nil.
34
+ <tr>
35
+ `ignored_words` - Allows you to add a collection of words to skip in spellchecking.
36
+ defaults to `[""]` when it's nil.
37
+
38
+
39
+
40
+ #### Methods
41
+
42
+ `lint_files` - Lints the globbed markdown files. Will fail if `proselint` cannot be installed correctly.
43
+ Generates a `markdown` list of warnings for the prose in a corpus of .markdown and .md files.
44
+
45
+ `proselint_installed?` - Determine if proselint is currently installed in the system paths.
46
+
47
+ `mdspell_installed?` - Determine if mdspell is currently installed in the system paths.
48
+
49
+ `check_spelling` - Runs a markdown-specific spell checker, against a corpus of `.markdown` and `.md` files.
data/Rakefile CHANGED
@@ -1,13 +1,5 @@
1
1
  require 'bundler/gem_tasks'
2
- require "rspec/core/rake_task"
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
-
6
5
  task default: :spec
7
-
8
- task :spec do
9
- Rake::Task['specs'].invoke
10
- end
11
-
12
- task :default => :spec
13
-
data/danger-prose.gemspec CHANGED
@@ -8,35 +8,37 @@ Gem::Specification.new do |spec|
8
8
  spec.version = DangerProse::VERSION
9
9
  spec.authors = ['David Grandinetti', 'Orta Therox']
10
10
  spec.email = ['dbgrandi@gmail.com', 'orta.therox@gmail.com']
11
- spec.description = %q{A danger plugin for working with bodies of markdown prose.}
12
- spec.summary = %q{A danger plugin for working with bodies of markdown prose.}
11
+ spec.description = 'A danger plugin for working with bodies of markdown prose.'
12
+ spec.summary = 'A danger plugin for working with bodies of markdown prose.'
13
13
  spec.homepage = 'https://github.com/dbgrandi/danger-prose'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_dependency 'danger'
21
21
 
22
+ # Let's you test your plugin via the linter
23
+ spec.add_development_dependency "yard", '~> 0.8'
24
+
22
25
  # General ruby development
23
26
  spec.add_development_dependency 'bundler', '~> 1.3'
24
27
  spec.add_development_dependency 'rake', '~> 10.0'
25
28
 
26
29
  # Testing support
27
- spec.add_development_dependency "rspec", '~> 3.4'
30
+ spec.add_development_dependency 'rspec', '~> 3.4'
28
31
 
29
32
  # Makes testing easy via `bundle exec guard`
30
- spec.add_development_dependency "guard", '~> 2.14'
31
- spec.add_development_dependency "guard-rspec", '~> 4.7'
32
-
33
+ spec.add_development_dependency 'guard', '~> 2.14'
34
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
35
+
33
36
  # If you want to work on older builds of ruby
34
- spec.add_development_dependency "listen", '3.0.7'
37
+ spec.add_development_dependency 'listen', '3.0.7'
35
38
 
36
39
  # This gives you the chance to run a REPL inside your test
37
- # via
40
+ # via
38
41
  # binding.pry
39
42
  # This will stop test execution and let you inspect the results
40
- spec.add_development_dependency "pry"
41
-
43
+ spec.add_development_dependency 'pry'
42
44
  end
data/lib/danger_plugin.rb CHANGED
@@ -1,72 +1,82 @@
1
- module Danger
1
+ require 'json'
2
2
 
3
+ module Danger
3
4
  # Lint markdown files inside your projects.
4
5
  # This is done using the [proselint](http://proselint.com) python egg.
5
6
  # Results are passed out as a table in markdown.
6
7
  #
7
- # @example Specifying custom CocoaPods installation options
8
+ # @example Running linter with custom disabled linters
9
+ #
10
+ # # Runs a linter with comma style and tense present disabled
11
+ # prose.disable_linters = ["misc.scare_quotes", "misc.tense_present"]
12
+ # prose.lint_files "_posts/*.md"
13
+ #
14
+ # @example Running linter with default linters
15
+ #
16
+ # # Runs a linter with all styles, on modified and added markdown files in this PR
17
+ # prose.lint_files
18
+ #
19
+ # @example Running the spell checker
20
+ #
21
+ # # Runs a spell checker on all files in `_post`
22
+ # prose.check_spelling "_posts/*.md"
8
23
  #
9
- # # Runs a linter with comma style disabled
10
- # proselint.disable_linters = [“misc.scare_quotes”, "misc.tense_present"]
11
- # proselint.lint_files “_posts/*.md”
24
+ # @example Running the spell checker, with some words whitelisted
12
25
  #
13
- # # Runs a linter with all styles, on modified and added markpown files in this PR
14
- # proselint.lint_files
26
+ # prose.ignored_words = ["orta", "artsy"]
27
+ # prose.lint_files
15
28
  #
16
29
  # @see artsy/artsy.github.io
17
30
  # @tags blogging, blog, writing, jekyll, middleman, hugo, metalsmith, gatsby, express
18
31
  #
19
32
  class DangerProse < Plugin
20
-
21
- # Allows you to disable a collection of linters from being ran.
33
+ # Allows you to disable a collection of linters from running. Doesn't work yet.
22
34
  # You can get a list of [them here](https://github.com/amperser/proselint#checks)
35
+ # defaults to `["misc.scare_quotes", "typography.symbols"]` when it's nil.
36
+ #
37
+ # @return [Array<String>]
23
38
  attr_accessor :disable_linters
24
39
 
25
- # Lints the globbed files, will only fail if `proselint` cannot be installed correctly.
26
- # Generates a `markdown` list of warnings for the prose in a corpus of .markdown and .md files.
40
+ # Lints the globbed markdown files. Will fail if `proselint` cannot be installed correctly.
41
+ # Generates a `markdown` list of warnings for the prose in a corpus of .markdown and .md files.
27
42
  #
28
43
  # @param [String] files
29
44
  # A globbed string which should return the files that you want to lint, defaults to nil.
30
45
  # if nil, modified and added files from the diff will be used.
31
46
  # @return [void]
32
47
  #
33
- def lint_files(files=nil)
48
+ def lint_files(files = nil)
34
49
  # Installs a prose checker if needed
35
- system "pip install --user proselint" unless proselint_installed?
50
+ system 'pip install --user proselint' unless proselint_installed?
36
51
 
37
52
  # Check that this is in the user's PATH after installing
38
- unless proselint_installed?
39
- fail "proselint is not in the user's PATH, or it failed to install"
40
- return
41
- end
53
+ raise "proselint is not in the user's PATH, or it failed to install" unless proselint_installed?
42
54
 
43
55
  # Either use files provided, or use the modified + added
44
- markdown_files = files ? Dir.glob(files) : (modified_files + added_files)
45
- markdown_files.select! do |line| (line.end_with?(".markdown") || line.end_with?(".md")) end
46
-
47
- # TODO create the disabled linters JSON in ~/.proselintrc
48
- # using @disable_linter
56
+ markdown_files = get_files files
49
57
 
50
- # Convert paths to proselint results
51
- require 'json'
52
- result_jsons = Hash[markdown_files.uniq.collect { |v| [v, JSON.parse(`proselint #{v} --json`.strip) ] }]
53
- proses = result_jsons.select { |path, prose| prose['data']['errors'].count }
58
+ proses = {}
59
+ to_disable = disable_linters || ["misc.scare_quotes", "typography.symbols"]
60
+ with_proselint_disabled(to_disable) do
61
+ # Convert paths to proselint results
62
+ result_jsons = Hash[markdown_files.uniq.collect { |v| [v, get_proselint_json(v)] }]
63
+ proses = result_jsons.select { |_, prose| prose['data']['errors'].count }
64
+ end
54
65
 
55
66
  # Get some metadata about the local setup
56
- current_branch = env.request_source.pr_json["head"]["ref"]
57
67
  current_slug = env.ci_source.repo_slug
58
68
 
59
69
  # We got some error reports back from proselint
60
70
  if proses.count > 0
61
71
  message = "### Proselint found issues\n\n"
62
72
  proses.each do |path, prose|
63
- github_loc = "/#{current_slug}/tree/#{current_branch}/#{path}"
73
+ github_loc = "/#{current_slug}/tree/#{github.branch_for_head}/#{path}"
64
74
  message << "#### [#{path}](#{github_loc})\n\n"
65
75
 
66
76
  message << "Line | Message | Severity |\n"
67
77
  message << "| --- | ----- | ----- |\n"
68
78
 
69
- prose["data"]["errors"].each do |error|
79
+ prose['data']['errors'].each do |error|
70
80
  message << "#{error['line']} | #{error['message']} | #{error['severity']}\n"
71
81
  end
72
82
  end
@@ -81,5 +91,111 @@ module Danger
81
91
  def proselint_installed?
82
92
  `which proselint`.strip.empty? == false
83
93
  end
94
+
95
+ # Determine if mdspell is currently installed in the system paths.
96
+ # @return [Bool]
97
+ #
98
+ def mdspell_installed?
99
+ `which mdspell`.strip.empty? == false
100
+ end
101
+
102
+ # Allows you to add a collection of words to skip in spellchecking.
103
+ # defaults to `[""]` when it's nil.
104
+ # @return [Array<String>]
105
+ attr_accessor :ignored_words
106
+
107
+ # Runs a markdown-specific spell checker, against a corpus of `.markdown` and `.md` files.
108
+ #
109
+ # @param [String] files
110
+ # A globbed string which should return the files that you want to spell check, defaults to nil.
111
+ # if nil, modified and added files from the diff will be used.
112
+ # @return [void]
113
+ #
114
+ def check_spelling(files = nil)
115
+ # Installs my fork of the spell checker if needed
116
+ # my fork has line numbers + indexes
117
+ system "npm install -g orta/node-markdown-spellcheck" unless mdspell_installed?
118
+
119
+ # Check that this is in the user's PATH after installing
120
+ raise "mdspell is not in the user's PATH, or it failed to install" unless mdspell_installed?
121
+
122
+ markdown_files = get_files files
123
+
124
+ skip_words = ignored_words || []
125
+ File.write(".spelling", skip_words.join("\n"))
126
+ result_texts = Hash[markdown_files.uniq.collect { |md| [md, `mdspell #{md} -r`.strip] }]
127
+ spell_issues = result_texts.select { |path, output| output.include? "spelling errors found" }
128
+ File.unlink(".spelling")
129
+
130
+ # Get some metadata about the local setup
131
+ current_slug = env.ci_source.repo_slug
132
+
133
+ if spell_issues.count > 0
134
+ message = "### Spell Checker found issues\n\n"
135
+ spell_issues.each do |path, output|
136
+ github_loc = "/#{current_slug}/tree/#{github.branch_for_head}/#{path}"
137
+ message << "#### [#{path}](#{github_loc})\n\n"
138
+
139
+ message << "Line | Typo |\n"
140
+ message << "| --- | ------ |\n"
141
+
142
+ output.lines[1..-3].each do |line|
143
+ index_info = line.strip.split("|").first
144
+ index_line, index = index_info.split(":").map { |n| n.to_i }
145
+
146
+ file = File.read(path)
147
+
148
+ unknown_word = file[index..-1].split(" ").first
149
+
150
+ error_text = line.strip.split("|")[1..-1].join("|").strip
151
+ error = error_text.gsub(unknown_word, "**" + unknown_word + "**")
152
+
153
+ message << "#{index_line} | #{error} | \n"
154
+ end
155
+ markdown message
156
+ end
157
+ end
158
+ end
159
+
160
+ private
161
+ # Creates a temporary proselint settings file
162
+ # @return void
163
+ #
164
+ def with_proselint_disabled(disable_linters)
165
+ # Create the disabled linters JSON in ~/.proselintrc
166
+ proselint_template = File.join(File.dirname(__FILE__), 'proselintrc')
167
+ proselintJSON = JSON.parse(File.read(proselint_template))
168
+
169
+ # Disable individual linters
170
+ disable_linters.each do |linter|
171
+ proselintJSON['checks'][linter] = false
172
+ end
173
+
174
+ # Re-save the new JSON into the home dir
175
+ temp_proselint_rc_path = File.join(Dir.home, '.proselintrc')
176
+ File.write(temp_proselint_rc_path, JSON.pretty_generate(proselintJSON))
177
+
178
+ # Run the closure
179
+ yield
180
+
181
+ # Delete .proselintrc
182
+ File.unlink temp_proselint_rc_path
183
+ end
184
+
185
+ def get_files files
186
+ # Either use files provided, or use the modified + added
187
+ markdown_files = files ? Dir.glob(files) : (git.modified_files + git.added_files)
188
+ markdown_files.select { |line| line.end_with? '.markdown', '.md' }
189
+ end
190
+
191
+ # Always returns a hash, regardless of whether the command gives JSON, weird data, or no response
192
+ def get_proselint_json path
193
+ json = `proselint "#{path}" --json`.strip
194
+ if json[0] == "{" and json[-1] == "}"
195
+ JSON.parse json
196
+ else
197
+ {}
198
+ end
199
+ end
84
200
  end
85
201
  end
data/lib/proselintrc ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "max_errors": 1000,
3
+ "checks": {
4
+ "airlinese.misc" : true,
5
+ "annotations.misc" : true,
6
+ "archaism.misc" : true,
7
+ "cliches.hell" : true,
8
+ "cliches.misc" : true,
9
+ "consistency.spacing" : true,
10
+ "consistency.spelling" : true,
11
+ "corporate_speak.misc" : true,
12
+ "cursing.filth" : true,
13
+ "cursing.nfl" : false,
14
+ "cursing.nword" : true,
15
+ "dates_times.am_pm" : true,
16
+ "dates_times.dates" : true,
17
+ "hedging.misc" : true,
18
+ "hyperbole.misc" : true,
19
+ "jargon.misc" : true,
20
+ "lexical_illusions.misc" : true,
21
+ "links.broken" : false,
22
+ "malapropisms.misc" : true,
23
+ "misc.apologizing" : true,
24
+ "misc.back_formations" : true,
25
+ "misc.bureaucratese" : true,
26
+ "misc.but" : true,
27
+ "misc.capitalization" : true,
28
+ "misc.chatspeak" : true,
29
+ "misc.commercialese" : true,
30
+ "misc.composition" : true,
31
+ "misc.currency" : true,
32
+ "misc.debased" : true,
33
+ "misc.false_plurals" : true,
34
+ "misc.illogic" : true,
35
+ "misc.inferior_superior" : true,
36
+ "misc.latin" : true,
37
+ "misc.many_a" : true,
38
+ "misc.metaconcepts" : true,
39
+ "misc.metadiscourse" : true,
40
+ "misc.narcisissm" : true,
41
+ "misc.not_guilty" : true,
42
+ "misc.phrasal_adjectives" : true,
43
+ "misc.preferred_forms" : true,
44
+ "misc.pretension" : true,
45
+ "misc.professions" : true,
46
+ "misc.punctuation" : true,
47
+ "misc.scare_quotes" : true,
48
+ "misc.suddenly" : true,
49
+ "misc.tense_present" : true,
50
+ "misc.waxed" : true,
51
+ "misc.whence" : true,
52
+ "mixed_metaphors.misc" : true,
53
+ "mondegreens.misc" : true,
54
+ "needless_variants.misc" : true,
55
+ "nonwords.misc" : true,
56
+ "oxymorons.misc" : true,
57
+ "psychology.misc" : true,
58
+ "redundancy.misc" : true,
59
+ "redundancy.ras_syndrome" : true,
60
+ "skunked_terms.misc" : true,
61
+ "spelling.able_atable" : true,
62
+ "spelling.able_ible" : true,
63
+ "spelling.athletes" : true,
64
+ "spelling.em_im_en_in" : true,
65
+ "spelling.er_or" : true,
66
+ "spelling.in_un" : true,
67
+ "spelling.misc" : true,
68
+ "security.credit_card" : true,
69
+ "security.password" : true,
70
+ "sexism.misc" : true,
71
+ "terms.animal_adjectives" : true,
72
+ "terms.denizen_labels" : true,
73
+ "terms.eponymous_adjectives" : true,
74
+ "terms.venery" : true,
75
+ "typography.diacritical_marks" : true,
76
+ "typography.exclamation" : true,
77
+ "typography.symbols" : true,
78
+ "uncomparables.misc" : true,
79
+ "weasel_words.misc" : true,
80
+ "weasel_words.very" : true
81
+ }
82
+ }
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DangerProse
2
- VERSION = "1.0.0".freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -1,58 +1,103 @@
1
1
  require File.expand_path('../spec_helper', __FILE__)
2
2
 
3
3
  module Danger
4
- describe Prose do
4
+ describe DangerProse do
5
5
  it 'is a plugin' do
6
6
  expect(Danger::DangerProse < Danger::Plugin).to be_truthy
7
7
  end
8
-
8
+
9
9
  describe 'with Dangerfile' do
10
10
  before do
11
11
  @dangerfile = testing_dangerfile
12
12
  @prose = testing_dangerfile.prose
13
13
  end
14
14
 
15
- it "handles proselint not being installed" do
16
- allow(@prose).to receive(:`).with("which proselint").and_return("")
17
- expect(@prose.proselint_installed?).to be_falsy
18
- end
15
+ describe 'linter' do
16
+ it 'handles proselint not being installed' do
17
+ allow(@prose).to receive(:`).with('which proselint').and_return('')
18
+ expect(@prose.proselint_installed?).to be_falsy
19
+ end
20
+
21
+ it 'handles proselint being installed' do
22
+ allow(@prose).to receive(:`).with('which proselint').and_return('/bin/thing/proselint')
23
+ expect(@prose.proselint_installed?).to be_truthy
24
+ end
25
+
26
+ describe :lint_files do
27
+ before do
28
+ # So it doesn't try to install on your computer
29
+ allow(@prose).to receive(:`).with('which proselint').and_return('/bin/thing/proselint')
30
+
31
+ # Proselint returns JSON data, which is nice 👍
32
+ errors = '[{"start": 1441, "replacements": null, "end": 1445, "severity": "warning", "extent": 4, "column": 1, "message": "!!! is hyperbolic.", "line": 46, "check": "hyperbolic.misc"}]'
33
+ proselint_response = '{"status" : "success", "data" : { "errors" : ' + errors + '}}'
34
+
35
+ # This is where we generate our JSON
36
+ allow(@prose).to receive(:`).with('proselint "spec/fixtures/blog_post.md" --json').and_return(proselint_response)
37
+
38
+ # it's worth noting - you can call anything on your plugin that a Dangerfile responds to
39
+ # The request source's PR JSON typically looks like
40
+ # https://raw.githubusercontent.com/danger/danger/bffc246a11dac883d76fc6636319bd6c2acd58a3/spec/fixtures/pr_response.json
41
+
42
+ @prose.env.request_source.pr_json = { head: { ref: 'my_fake_branch' } }
43
+ end
44
+
45
+ it 'handles a known JSON report from proselint' do
46
+ @prose.lint_files('spec/fixtures/*.md')
47
+ output = @prose.status_report[:markdowns].first
19
48
 
20
- it "handles proselint being installed" do
21
- allow(@prose).to receive(:`).with("which proselint").and_return("/bin/thing/proselint")
22
- expect(@prose.proselint_installed?).to be_truthy
49
+ # A title
50
+ expect(output).to include('Proselint found issues')
51
+ # A warning
52
+ expect(output).to include('!!! is hyperbolic. | warning')
53
+ # A link to the file inside the fixtures dir
54
+ expect(output).to include('[spec/fixtures/blog_post.md](/artsy/eigen/tree/my_fake_branch/spec/fixtures/blog_post.md)')
55
+ end
56
+ end
23
57
  end
24
58
 
25
- describe :lint_files do
26
- it "handles a known JSON report from proselint" do
27
- # So it doesn't try to install on your computer
28
- allow(@prose).to receive(:`).with("which proselint").and_return("/bin/thing/proselint")
29
-
30
- # Proselint returns JSON data, which is nice 👍
31
- errors = '[{"start": 1441, "replacements": null, "end": 1445, "severity": "warning", "extent": 4, "column": 1, "message": "!!! is hyperbolic.", "line": 46, "check": "hyperbolic.misc"}]'
32
- proselint_response = '{"status" : "success", "data" : { "errors" : ' + errors + '}}'
33
-
34
- # This is where we generate our JSON
35
- allow(@prose).to receive(:`).with("proselint spec/fixtures/blog_post.md --json").and_return(proselint_response)
36
-
37
- # it's worth noting - you can call anything on your plugin that a Dangerfile responds to
38
- # The request source's PR JSON typically looks like
39
- # https://raw.githubusercontent.com/danger/danger/bffc246a11dac883d76fc6636319bd6c2acd58a3/spec/fixtures/pr_response.json
40
- @prose.env.request_source.pr_json = { "head" => { "ref" => "my_fake_branch" }}
41
-
42
- # Do it
43
- @prose.lint_files("spec/fixtures/*.md")
44
-
45
- output = @prose.status_report[:markdowns].first
46
-
47
- # A title
48
- expect(output).to include("Proselint found issues")
49
- # A warning
50
- expect(output).to include("!!! is hyperbolic. | warning")
51
- # A link to the file inside the fixtures dir
52
- expect(output).to include("[spec/fixtures/blog_post.md](/artsy/eigen/tree/my_fake_branch/spec/fixtures/blog_post.md)")
59
+ describe 'spell checking' do
60
+ it 'handles proselint not being installed' do
61
+ allow(@prose).to receive(:`).with('which mdspell').and_return('')
62
+ expect(@prose.mdspell_installed?).to be_falsy
63
+ end
64
+
65
+ it 'handles proselint being installed' do
66
+ allow(@prose).to receive(:`).with('which mdspell').and_return('/bin/thing/mdspell')
67
+ expect(@prose.mdspell_installed?).to be_truthy
68
+ end
69
+
70
+ describe 'full command' do
71
+ before do
72
+ # So it doesn't try to install on your computer
73
+ allow(@prose).to receive(:`).with('which mdspell').and_return('/bin/thing/mdspell')
74
+
75
+ # mdspell returns JSON data, which is nice 👍
76
+ proselint_response = " spec/fixtures/blog_post.md\n 1:27 | This post intentional left blank-ish.\n 4:84 | Here's a tpyo - it should registor.\n 4:101 | Here's a tpyo - it should registor.\n\n >> 3 spelling errors found in 1 file"
77
+
78
+ # This is where we generate our JSON
79
+ allow(@prose).to receive(:`).with('mdspell spec/fixtures/blog_post.md -r').and_return(proselint_response)
80
+
81
+ # it's worth noting - you can call anything on your plugin that a Dangerfile responds to
82
+ # The request source's PR JSON typically looks like
83
+ # https://raw.githubusercontent.com/danger/danger/bffc246a11dac883d76fc6636319bd6c2acd58a3/spec/fixtures/pr_response.json
84
+
85
+ @prose.env.request_source.pr_json = { head: { ref: 'my_fake_branch' } }
86
+ end
87
+
88
+ it 'handles a known JSON report from mdspell' do
89
+ @prose.check_spelling('spec/fixtures/*.md')
90
+ output = @prose.status_report[:markdowns].first
91
+
92
+ # A title
93
+ expect(output).to include('Spell Checker found issues')
94
+ # A typo, in bold
95
+ expect(output).to include('**tpyo**')
96
+ # A link to the file inside the fixtures dir
97
+ expect(output).to include('[spec/fixtures/blog_post.md](/artsy/eigen/tree/my_fake_branch/spec/fixtures/blog_post.md)')
98
+ end
53
99
  end
54
100
  end
55
101
  end
56
102
  end
57
103
  end
58
-
@@ -1 +1,4 @@
1
- This post intentional left blank-ish.
1
+ This post intentional left blank-ish.
2
+ And this is to trigger a warning!!!
3
+
4
+ Here's a tpyo - it should registor.
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  ROOT = Pathname.new(File.expand_path('../../', __FILE__))
2
- $:.unshift((ROOT + 'lib').to_s)
3
- $:.unshift((ROOT + 'spec').to_s)
2
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
3
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
4
4
 
5
5
  RSpec.configure do |config|
6
- # Use color in STDOUT
6
+ # Use color in STDOUT
7
7
  config.color = true
8
8
  end
9
9
 
@@ -26,11 +26,11 @@ end
26
26
  # running a PR on TravisCI
27
27
  def testing_env
28
28
  {
29
- "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
30
- "TRAVIS_PULL_REQUEST" => "800",
31
- "TRAVIS_REPO_SLUG" => "artsy/eigen",
32
- "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
33
- "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
29
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
30
+ 'TRAVIS_PULL_REQUEST' => '800',
31
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
32
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
33
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
34
34
  }
35
35
  end
36
36
 
@@ -38,4 +38,4 @@ end
38
38
  def testing_dangerfile
39
39
  env = Danger::EnvironmentManager.new(testing_env)
40
40
  Danger::Dangerfile.new(env, testing_ui)
41
- end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-prose
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Grandinetti
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-26 00:00:00.000000000 Z
12
+ date: 2016-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: danger
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: yard
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.8'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.8'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: bundler
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +155,7 @@ files:
141
155
  - Rakefile
142
156
  - danger-prose.gemspec
143
157
  - lib/danger_plugin.rb
158
+ - lib/proselintrc
144
159
  - lib/version.rb
145
160
  - spec/danger_plugin_spec.rb
146
161
  - spec/fixtures/blog_post.md
@@ -165,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
180
  version: '0'
166
181
  requirements: []
167
182
  rubyforge_project:
168
- rubygems_version: 2.2.2
183
+ rubygems_version: 2.4.8
169
184
  signing_key:
170
185
  specification_version: 4
171
186
  summary: A danger plugin for working with bodies of markdown prose.