danger-clorox 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -0
- data/lib/danger_plugin.rb +10 -21
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +38 -23
- metadata +3 -4
- data/spec/fixtures/SwiftFile.swift +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae1427713f4cce42f01cc442c765de8bfddcc687
|
4
|
+
data.tar.gz: f41c88a12f1fa9fb8b292a1a779a9105975f25c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d19496bfa6b44008144c71473fb253c0366311315d6fb00fed182259c7aa53fbc97044c47499788bade65a04ceffc737d171850e3d854af65c79eaaee32c552
|
7
|
+
data.tar.gz: b1fe315c112212caaecc7013e89933422b3fd1b3e56453bed01089650196fb209c4fcd959e5147ed043cc4799e5105888001e3493345b38889f98f566ca70aea
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
data/lib/danger_plugin.rb
CHANGED
@@ -3,8 +3,11 @@ module Danger
|
|
3
3
|
|
4
4
|
class DangerClorox < Plugin
|
5
5
|
|
6
|
-
|
7
|
-
|
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
|
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
|
25
|
-
clorox_command += "--path #{
|
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(
|
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
|
-
|
50
|
+
File.exists? EXECUTABLE
|
62
51
|
end
|
63
52
|
end
|
64
53
|
end
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -13,47 +13,62 @@ module Danger
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "handles clorox not being installed" do
|
16
|
-
allow(
|
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(
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
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
|
35
|
-
|
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
|
-
|
38
|
-
@clorox.
|
54
|
+
@clorox.directories = ["some/dir"]
|
55
|
+
@clorox.check_files
|
39
56
|
|
40
57
|
output = @clorox.status_report[:markdowns].first
|
41
58
|
|
42
|
-
expect(output).
|
43
|
-
|
44
|
-
|
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
|
51
|
-
|
52
|
-
allow(@clorox).to receive(:`).with(
|
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.
|
68
|
+
@clorox.directories = ["some/dir"]
|
69
|
+
@clorox.check_files
|
55
70
|
|
56
|
-
expect(@clorox.status_report[:markdowns].first).
|
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.
|
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-
|
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.
|