danger-clorox 1.0.0 → 1.1.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: 6b674b32946188d77a7316cc4effc59201f1c487
4
- data.tar.gz: d41d4a774ea2a346f5608ef6728d7fd602217ed1
3
+ metadata.gz: ae1427713f4cce42f01cc442c765de8bfddcc687
4
+ data.tar.gz: f41c88a12f1fa9fb8b292a1a779a9105975f25c6
5
5
  SHA512:
6
- metadata.gz: 4e169b4d61f39882461f8320cf4c8cc911f1e33709d0582384610fea7e338d4f337f1919b9790e9234e83bf1d15d10b7949ca8599b1f6af4d9f99a3d177b59ea
7
- data.tar.gz: 8bcd4aebca1eca8c72acc5baac6562334a22b7b05d713eff6c58a51f4d83ab78ea6a5469b2d72106360a19cacef4b7b0fd92d1998c15ddef25513f3b743b3722
6
+ metadata.gz: 6d19496bfa6b44008144c71473fb253c0366311315d6fb00fed182259c7aa53fbc97044c47499788bade65a04ceffc737d171850e3d854af65c79eaaee32c552
7
+ data.tar.gz: b1fe315c112212caaecc7013e89933422b3fd1b3e56453bed01089650196fb209c4fcd959e5147ed043cc4799e5105888001e3493345b38889f98f566ca70aea
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 1.1.0
2
+ - Adds support for multiple directories
3
+
4
+ ## 1.0.0
5
+ - Initial version
data/README.md CHANGED
@@ -15,6 +15,7 @@ gem 'danger-clorox'
15
15
  The easiest way to use is just add this to your Dangerfile:
16
16
 
17
17
  ```rb
18
+ clorox.directories = ["YourProject", "YourProjectNotificationExtension"]
18
19
  clorox.check_files
19
20
  ```
20
21
 
data/lib/danger_plugin.rb CHANGED
@@ -3,8 +3,11 @@ module Danger
3
3
 
4
4
  class DangerClorox < Plugin
5
5
 
6
- # Allows you to specify a directory from where clorox will be run.
7
- attr_accessor :directory
6
+ ROOT_DIR = "/tmp/danger_clorox"
7
+ EXECUTABLE = "#{ROOT_DIR}/clorox/clorox.py"
8
+
9
+ # Allows you to specify directories from where clorox will be run.
10
+ attr_accessor :directories
8
11
 
9
12
  # Checks presence of file header comments. Will fail if `clorox` cannot be installed correctly.
10
13
  # Generates a `markdown` list of dirty Objective-C and Swift files
@@ -13,7 +16,7 @@ module Danger
13
16
  #
14
17
  def check_files
15
18
  # Installs clorox if needed
16
- system "pip install --target /tmp/danger_clorox clorox" unless clorox_installed?
19
+ system "pip install --target #{ROOT_DIR} clorox" unless clorox_installed?
17
20
 
18
21
  # Check that this is in the user's PATH after installing
19
22
  unless clorox_installed?
@@ -21,13 +24,13 @@ module Danger
21
24
  return
22
25
  end
23
26
 
24
- clorox_command = "python /tmp/danger_clorox/clorox/clorox.py "
25
- clorox_command += "--path #{directory ? directory : '.'} "
27
+ clorox_command = "python #{EXECUTABLE} "
28
+ clorox_command += "--path #{directories ? directories.join(' ') : '.'} "
26
29
  clorox_command += "--inspection "
27
30
  clorox_command += "--report json"
28
31
 
29
32
  require 'json'
30
- result_json = JSON.parse(`(#{clorox_command})`)
33
+ result_json = JSON.parse(`#{clorox_command}`)
31
34
 
32
35
  message = ''
33
36
  if result_json['status'] == 'dirty'
@@ -40,25 +43,11 @@ module Danger
40
43
  end
41
44
  end
42
45
 
43
- # Parses clorox invocation results into a string
44
- # which is formatted as a markdown table.
45
- #
46
- # @return [String]
47
- #
48
- def parse_results(results)
49
- message = ""
50
- results.each do |r|
51
- message << "- #{r} :hankey:\n"
52
- end
53
-
54
- message
55
- end
56
-
57
46
  # Determine if clorox is currently installed in the system paths.
58
47
  # @return [Bool]
59
48
  #
60
49
  def clorox_installed?
61
- Dir.exists? "/tmp/danger_clorox"
50
+ File.exists? EXECUTABLE
62
51
  end
63
52
  end
64
53
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DangerClorox
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.1.0".freeze
3
3
  end
@@ -13,47 +13,62 @@ module Danger
13
13
  end
14
14
 
15
15
  it "handles clorox not being installed" do
16
- allow(@clorox).to receive(:`).with("which clorox").and_return("")
16
+ allow(File).to receive(:exists?).with(Danger::DangerClorox::EXECUTABLE).and_return(false)
17
17
  expect(@clorox.clorox_installed?).to be_falsy
18
18
  end
19
19
 
20
20
  it "handles clorox being installed" do
21
- allow(@clorox).to receive(:`).with("which clorox").and_return("/bin/wherever/clorox")
21
+ allow(File).to receive(:exists?).with(Danger::DangerClorox::EXECUTABLE).and_return(true)
22
22
  expect(@clorox.clorox_installed?).to be_truthy
23
23
  end
24
24
 
25
- describe :lint_files do
26
- before do
27
- # So it doesn't try to install on your computer
28
- allow(@clorox).to receive(:`).with("which clorox").and_return("/bin/wheverever/clorox")
25
+ it "handles a single directory" do
26
+ allow(File).to receive(:exists?).with(Danger::DangerClorox::EXECUTABLE).and_return(true)
27
+
28
+ @clorox_response = '{"status": "dirty", "files": ["some/path/FileA.swift", "some/path/FileB.m"]}'
29
+ allow(@clorox).to receive(:`).with("python #{Danger::DangerClorox::EXECUTABLE} --path some/dir --inspection --report json").and_return(@clorox_response)
30
+
31
+ @clorox.directories = ["some/dir"]
32
+ @clorox.check_files
33
+ end
34
+
35
+ it "handles multiple directories" do
36
+ allow(File).to receive(:exists?).with(Danger::DangerClorox::EXECUTABLE).and_return(true)
29
37
 
30
- # Set up our stubbed JSON response
31
- @clorox_response = '[{"reason": "Force casts should be avoided.", "file": "/User/me/this_repo/spec/fixtures/SwiftFile.swift", "line": 13, "severity": "Error" }]'
38
+ @clorox_response = '{"status": "dirty", "files": ["some/path/FileA.swift", "some/path/FileB.m"]}'
39
+ allow(@clorox).to receive(:`).with("python #{Danger::DangerClorox::EXECUTABLE} --path some/dir some/path --inspection --report json").and_return(@clorox_response)
40
+
41
+ @clorox.directories = ["some/dir", "some/path"]
42
+ @clorox.check_files
43
+ end
44
+
45
+ describe :check_files do
46
+ before do
47
+ allow(File).to receive(:exists?).with(Danger::DangerClorox::EXECUTABLE).and_return(true)
32
48
  end
33
49
 
34
- it 'handles a known Clorox report' do
35
- allow(@clorox).to receive(:`).with('clorox lint --quiet --reporter json --path spec/fixtures/SwiftFile.swift').and_return(@clorox_response)
50
+ it 'handles a dirty clorox report' do
51
+ @clorox_response = '{"status": "dirty", "files": ["some/path/FileA.swift", "some/path/FileB.m"]}'
52
+ allow(@clorox).to receive(:`).with("python #{Danger::DangerClorox::EXECUTABLE} --path some/dir --inspection --report json").and_return(@clorox_response)
36
53
 
37
- # Do it
38
- @clorox.lint_files("spec/fixtures/*.swift")
54
+ @clorox.directories = ["some/dir"]
55
+ @clorox.check_files
39
56
 
40
57
  output = @clorox.status_report[:markdowns].first
41
58
 
42
- expect(output).to_not be_empty
43
-
44
- # A title
45
- expect(output).to include("Clorox found issues")
46
- # A warning
47
- expect(output).to include("SwiftFile.swift | 13 | Force casts should be avoided.")
59
+ expect(output).to include("Clorox has found issues")
60
+ expect(output).to include("- some/path/FileA.swift")
61
+ expect(output).to include("- some/path/FileB.m")
48
62
  end
49
63
 
50
- it 'handles no files' do
51
- allow(@clorox).to receive(:modified_files).and_return('spec/fixtures/SwiftFile.swift')
52
- allow(@clorox).to receive(:`).with('clorox lint --quiet --reporter json --path spec/fixtures/SwiftFile.swift').and_return(@clorox_response)
64
+ it 'handles a clean clorox report' do
65
+ @clorox_response = '{"status": "clean", "files": []}'
66
+ allow(@clorox).to receive(:`).with("python #{Danger::DangerClorox::EXECUTABLE} --path some/dir --inspection --report json").and_return(@clorox_response)
53
67
 
54
- @clorox.lint_files("spec/fixtures/*.swift")
68
+ @clorox.directories = ["some/dir"]
69
+ @clorox.check_files
55
70
 
56
- expect(@clorox.status_report[:markdowns].first).to_not be_empty
71
+ expect(@clorox.status_report[:markdowns].first).to be_nil
57
72
  end
58
73
 
59
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-clorox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Barbosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-22 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger
@@ -131,6 +131,7 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - .gitignore
133
133
  - .ruby-version
134
+ - CHANGELOG.md
134
135
  - Gemfile
135
136
  - Gemfile.lock
136
137
  - Guardfile
@@ -141,7 +142,6 @@ files:
141
142
  - lib/danger_plugin.rb
142
143
  - lib/version.rb
143
144
  - spec/danger_plugin_spec.rb
144
- - spec/fixtures/SwiftFile.swift
145
145
  - spec/spec_helper.rb
146
146
  homepage: https://github.com/barbosa/danger-clorox
147
147
  licenses:
@@ -169,6 +169,5 @@ specification_version: 4
169
169
  summary: A Danger plugin for checking presence of file header comments.
170
170
  test_files:
171
171
  - spec/danger_plugin_spec.rb
172
- - spec/fixtures/SwiftFile.swift
173
172
  - spec/spec_helper.rb
174
173
  has_rdoc:
@@ -1 +0,0 @@
1
- // This file intentional left blank-ish.