guard-rubocop 1.0.0 → 1.0.1
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 +4 -4
- data/.gitignore +18 -0
- data/.rubocop.yml +7 -0
- data/.travis.yml +8 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +5 -1
- data/README.md +6 -0
- data/guard-rubocop.gemspec +2 -2
- data/lib/guard/rubocop.rb +25 -17
- data/lib/guard/rubocop/runner.rb +0 -4
- data/lib/guard/rubocop/version.rb +1 -1
- data/spec/.rubocop.yml +5 -0
- data/spec/guard/rubocop_spec.rb +78 -56
- metadata +29 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec82afdd85de6be92deca90949f571a84eae25cf
|
4
|
+
data.tar.gz: 68d6f82e862a90d3625e4fcf0b1c06d36a67221c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40d80a751bc72240d3c0d5b1c1ace21c12e1792a66ee481511733c91ff1f360c478eda6ccf31bf80cf2475ab1c4464176ebf979f61514a668998339687328ea
|
7
|
+
data.tar.gz: 5a2c18d2e662dc0744463c374bd94cf55979b816538726dd89f81bac3dce0d14850ced6d4dbd35a72caf3c72372cf96cb433651a775ccfdb4eef8ac1cd6127cd
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -74,3 +74,9 @@ notification: :failed # Display Growl notification after each run.
|
|
74
74
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
75
75
|
4. Push to the branch (`git push origin my-new-feature`)
|
76
76
|
5. Create new Pull Request
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
Copyright (c) 2013 Yuji Nakayama
|
81
|
+
|
82
|
+
See the [LICENSE.txt](LICENSE.txt) for details.
|
data/guard-rubocop.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = 'https://github.com/yujinakayama/guard-rubocop'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
|
-
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ['lib']
|
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
29
29
|
spec.add_development_dependency 'simplecov', '~> 0.7'
|
30
|
-
spec.add_development_dependency 'guard-rspec', '~>
|
30
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.0'
|
31
31
|
spec.add_development_dependency 'ruby_gntp', '~> 0.3'
|
32
32
|
end
|
data/lib/guard/rubocop.rb
CHANGED
@@ -30,10 +30,24 @@ module Guard
|
|
30
30
|
|
31
31
|
def run_all
|
32
32
|
UI.info 'Inspecting Ruby code style of all files'
|
33
|
-
|
33
|
+
inspect_with_rubocop
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def run_on_additions(paths)
|
37
|
+
run_partially(paths)
|
38
|
+
end
|
39
|
+
|
40
|
+
def run_on_modifications(paths)
|
41
|
+
run_partially(paths)
|
42
|
+
end
|
43
|
+
|
44
|
+
def reload
|
45
|
+
@failed_paths = []
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def run_partially(paths)
|
37
51
|
paths += @failed_paths if @options[:keep_failed]
|
38
52
|
paths = clean_paths(paths)
|
39
53
|
|
@@ -42,11 +56,17 @@ module Guard
|
|
42
56
|
displayed_paths = paths.map { |path| smart_path(path) }
|
43
57
|
UI.info "Inspecting Ruby code style: #{displayed_paths.join(' ')}"
|
44
58
|
|
45
|
-
|
59
|
+
inspect_with_rubocop(paths)
|
46
60
|
end
|
47
61
|
|
48
|
-
def
|
49
|
-
|
62
|
+
def inspect_with_rubocop(paths = [])
|
63
|
+
runner = Runner.new(@options)
|
64
|
+
passed = runner.run(paths)
|
65
|
+
@failed_paths = runner.failed_paths
|
66
|
+
throw :task_has_failed unless passed
|
67
|
+
rescue => error
|
68
|
+
UI.error 'The following exception occurred while running guard-rubocop: ' +
|
69
|
+
"#{error.backtrace.first} #{error.message} (#{error.class.name})"
|
50
70
|
end
|
51
71
|
|
52
72
|
def clean_paths(paths)
|
@@ -60,18 +80,6 @@ module Guard
|
|
60
80
|
paths
|
61
81
|
end
|
62
82
|
|
63
|
-
private
|
64
|
-
|
65
|
-
def run(paths = [])
|
66
|
-
runner = Runner.new(@options)
|
67
|
-
passed = runner.run(paths)
|
68
|
-
@failed_paths = runner.failed_paths
|
69
|
-
throw :task_has_failed unless passed
|
70
|
-
rescue => error
|
71
|
-
UI.error 'The following exception occurred while running guard-rubocop: ' +
|
72
|
-
"#{error.backtrace.first} #{error.message} (#{error.class.name})"
|
73
|
-
end
|
74
|
-
|
75
83
|
def included_in_other_path?(target_path, other_paths)
|
76
84
|
dir_paths = other_paths.select { |path| File.directory?(path) }
|
77
85
|
dir_paths.delete(target_path)
|
data/lib/guard/rubocop/runner.rb
CHANGED
@@ -2,15 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
|
5
|
-
# rubocop:disable Documentation
|
6
5
|
module Guard
|
7
6
|
class Rubocop
|
8
7
|
# This class runs `rubocop` command, retrieves result and notifies.
|
9
8
|
# An instance of this class is intended to invoke `rubocop` only once in its lifetime.
|
10
9
|
class Runner
|
11
|
-
# rubocop:enable Documentation
|
12
|
-
|
13
|
-
#
|
14
10
|
def initialize(options)
|
15
11
|
@options = options
|
16
12
|
end
|
data/spec/.rubocop.yml
ADDED
data/spec/guard/rubocop_spec.rb
CHANGED
@@ -11,10 +11,26 @@ describe Guard::Rubocop, :silence_output do
|
|
11
11
|
|
12
12
|
context 'by default' do
|
13
13
|
let(:options) { {} }
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
|
15
|
+
describe '[:all_on_start]' do
|
16
|
+
subject { super()[:all_on_start] }
|
17
|
+
it { should be_true }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '[:keep_failed]' do
|
21
|
+
subject { super()[:keep_failed] }
|
22
|
+
it { should be_true }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '[:notification]' do
|
26
|
+
subject { super()[:notification] }
|
27
|
+
it { should == :failed }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '[:cli]' do
|
31
|
+
subject { super()[:cli] }
|
32
|
+
it { should be_nil }
|
33
|
+
end
|
18
34
|
end
|
19
35
|
end
|
20
36
|
|
@@ -95,69 +111,71 @@ describe Guard::Rubocop, :silence_output do
|
|
95
111
|
end
|
96
112
|
end
|
97
113
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
before do
|
108
|
-
allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true)
|
109
|
-
allow_any_instance_of(Guard::Rubocop::Runner).to receive(:failed_paths).and_return([])
|
110
|
-
end
|
114
|
+
[:run_on_additions, :run_on_modifications].each do |method|
|
115
|
+
describe "##{method}", :processes_after_running do
|
116
|
+
subject { super().send(method, changed_paths) }
|
117
|
+
let(:changed_paths) do
|
118
|
+
[
|
119
|
+
'lib/guard/rubocop.rb',
|
120
|
+
'spec/spec_helper.rb'
|
121
|
+
]
|
122
|
+
end
|
111
123
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
124
|
+
before do
|
125
|
+
allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true)
|
126
|
+
allow_any_instance_of(Guard::Rubocop::Runner).to receive(:failed_paths).and_return([])
|
127
|
+
end
|
116
128
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
File.expand_path('some.rb'),
|
121
|
-
File.expand_path('dir/another.rb')
|
122
|
-
])
|
129
|
+
it 'inspects changed files with rubocop' do
|
130
|
+
expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run)
|
131
|
+
subject
|
123
132
|
end
|
124
|
-
guard.run_on_changes(changed_paths)
|
125
|
-
end
|
126
133
|
|
127
|
-
|
128
|
-
|
129
|
-
|
134
|
+
it 'passes cleaned paths to rubocop' do
|
135
|
+
expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths|
|
136
|
+
expect(paths).to eq([
|
137
|
+
File.expand_path('some.rb'),
|
138
|
+
File.expand_path('dir/another.rb')
|
139
|
+
])
|
140
|
+
end
|
141
|
+
subject
|
130
142
|
end
|
131
143
|
|
132
|
-
|
133
|
-
|
134
|
-
|
144
|
+
context 'when cleaned paths are empty' do
|
145
|
+
before do
|
146
|
+
allow(guard).to receive(:clean_paths).and_return([])
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'does nothing' do
|
150
|
+
expect_any_instance_of(Guard::Rubocop::Runner).not_to receive(:run)
|
151
|
+
subject
|
152
|
+
end
|
135
153
|
end
|
136
|
-
end
|
137
154
|
|
138
|
-
|
155
|
+
let(:failed_path) { File.expand_path('Rakefile') }
|
139
156
|
|
140
|
-
|
141
|
-
|
157
|
+
context 'when :keep_failed option is enabled' do
|
158
|
+
let(:options) { { keep_failed: true } }
|
142
159
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
160
|
+
it 'also inspects paths which are failed last time' do
|
161
|
+
guard.failed_paths << failed_path
|
162
|
+
expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths|
|
163
|
+
expect(paths).to include failed_path
|
164
|
+
end
|
165
|
+
subject
|
147
166
|
end
|
148
|
-
guard.run_on_changes(changed_paths)
|
149
167
|
end
|
150
|
-
end
|
151
168
|
|
152
|
-
|
153
|
-
|
169
|
+
context 'when :keep_failed option is disabled' do
|
170
|
+
let(:options) { { keep_failed: false } }
|
154
171
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
172
|
+
it 'inspects just changed paths' do
|
173
|
+
guard.failed_paths << failed_path
|
174
|
+
expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths|
|
175
|
+
expect(paths).to eq(changed_paths)
|
176
|
+
end
|
177
|
+
subject
|
159
178
|
end
|
160
|
-
guard.run_on_changes(changed_paths)
|
161
179
|
end
|
162
180
|
end
|
163
181
|
end
|
@@ -171,12 +189,16 @@ describe Guard::Rubocop, :silence_output do
|
|
171
189
|
end
|
172
190
|
|
173
191
|
describe '#clean_paths' do
|
192
|
+
def clean_paths(path)
|
193
|
+
guard.send(:clean_paths, path)
|
194
|
+
end
|
195
|
+
|
174
196
|
it 'converts to absolute paths' do
|
175
197
|
paths = [
|
176
198
|
'lib/guard/rubocop.rb',
|
177
199
|
'spec/spec_helper.rb'
|
178
200
|
]
|
179
|
-
expect(
|
201
|
+
expect(clean_paths(paths)).to eq([
|
180
202
|
File.expand_path('lib/guard/rubocop.rb'),
|
181
203
|
File.expand_path('spec/spec_helper.rb')
|
182
204
|
])
|
@@ -188,7 +210,7 @@ describe Guard::Rubocop, :silence_output do
|
|
188
210
|
'spec/spec_helper.rb',
|
189
211
|
'lib/guard/../guard/rubocop.rb'
|
190
212
|
]
|
191
|
-
expect(
|
213
|
+
expect(clean_paths(paths)).to eq([
|
192
214
|
File.expand_path('lib/guard/rubocop.rb'),
|
193
215
|
File.expand_path('spec/spec_helper.rb')
|
194
216
|
])
|
@@ -200,7 +222,7 @@ describe Guard::Rubocop, :silence_output do
|
|
200
222
|
'path/to/non_existent_file.rb',
|
201
223
|
'spec/spec_helper.rb'
|
202
224
|
]
|
203
|
-
expect(
|
225
|
+
expect(clean_paths(paths)).to eq([
|
204
226
|
File.expand_path('lib/guard/rubocop.rb'),
|
205
227
|
File.expand_path('spec/spec_helper.rb')
|
206
228
|
])
|
@@ -212,7 +234,7 @@ describe Guard::Rubocop, :silence_output do
|
|
212
234
|
'spec/spec_helper.rb',
|
213
235
|
'spec'
|
214
236
|
]
|
215
|
-
expect(
|
237
|
+
expect(clean_paths(paths)).to eq([
|
216
238
|
File.expand_path('lib/guard/rubocop.rb'),
|
217
239
|
File.expand_path('spec')
|
218
240
|
])
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.10'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '10.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.14'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.14'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.7'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.7'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: guard-rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '4.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '4.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: ruby_gntp
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0.3'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.3'
|
125
125
|
description: Guard::Rubocop automatically checks Ruby code style with RuboCop when
|
@@ -130,6 +130,10 @@ executables: []
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- ".yardopts"
|
133
137
|
- CHANGELOG.md
|
134
138
|
- Gemfile
|
135
139
|
- Guardfile
|
@@ -141,6 +145,7 @@ files:
|
|
141
145
|
- lib/guard/rubocop/runner.rb
|
142
146
|
- lib/guard/rubocop/templates/Guardfile
|
143
147
|
- lib/guard/rubocop/version.rb
|
148
|
+
- spec/.rubocop.yml
|
144
149
|
- spec/guard/rubocop/runner_spec.rb
|
145
150
|
- spec/guard/rubocop_spec.rb
|
146
151
|
- spec/spec_helper.rb
|
@@ -155,21 +160,22 @@ require_paths:
|
|
155
160
|
- lib
|
156
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
157
162
|
requirements:
|
158
|
-
- -
|
163
|
+
- - ">="
|
159
164
|
- !ruby/object:Gem::Version
|
160
165
|
version: '0'
|
161
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
167
|
requirements:
|
163
|
-
- -
|
168
|
+
- - ">="
|
164
169
|
- !ruby/object:Gem::Version
|
165
170
|
version: '0'
|
166
171
|
requirements: []
|
167
172
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.0.
|
173
|
+
rubygems_version: 2.0.14
|
169
174
|
signing_key:
|
170
175
|
specification_version: 4
|
171
176
|
summary: Guard plugin for RuboCop
|
172
177
|
test_files:
|
178
|
+
- spec/.rubocop.yml
|
173
179
|
- spec/guard/rubocop/runner_spec.rb
|
174
180
|
- spec/guard/rubocop_spec.rb
|
175
181
|
- spec/spec_helper.rb
|