guard-rubocop 0.0.4 → 0.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 +4 -4
- data/CHANGELOG.md +26 -0
- data/guard-rubocop.gemspec +3 -5
- data/lib/guard/rubocop.rb +23 -13
- data/lib/guard/rubocop/runner.rb +52 -59
- data/lib/guard/rubocop/version.rb +2 -2
- data/spec/guard/rubocop/runner_spec.rb +154 -73
- data/spec/guard/rubocop_spec.rb +10 -1
- metadata +7 -42
- data/spec/support/capture_helper.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0c295908d4ca4ca5f79bd5c4d85857dc2a05140
|
4
|
+
data.tar.gz: 7cd9a0ff0f3858ab1a9182cb4b2645e2778a8b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84c30fe8fb9538d668bd2951ffd428dce9204d01f725f7ebb6df772652ec3223c767d9bc68a60d5f9f98b6b38aaaec44dc1cd7c9dfb9a84b8e72b8798141f5f5
|
7
|
+
data.tar.gz: b1d22e396e96132d9749a87aae7af718dac2a7c2b425b1a803836a7fdfdc8b793c49b89fd8423b6c83aa191f00950bfe8cc06cb3b745db31955c267a991ed1ad
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## v0.1.0
|
4
|
+
|
5
|
+
* Update RuboCop dependency to 0.9 or later and earlier than 1.0
|
6
|
+
* Rework with JSON formatter
|
7
|
+
* Change the displayed text to "Inspecting ..."
|
8
|
+
* Print relative file paths when they are under current working directory
|
9
|
+
|
10
|
+
## v0.0.4
|
11
|
+
|
12
|
+
* Specify dependency on rubocop gem as under 0.9.0
|
13
|
+
* Force RuboCop to colorize output even though output is not TTY
|
14
|
+
* Revert "Use rubocop 0.6.1 --no-color option instead of uncoloring colored output"
|
15
|
+
|
16
|
+
## v0.0.3
|
17
|
+
|
18
|
+
* Use rubocop 0.6.1 --no-color option instead of uncoloring colored output
|
19
|
+
|
20
|
+
## v0.0.2
|
21
|
+
|
22
|
+
* Fix capitalization of the name RuboCop in notification title
|
23
|
+
|
24
|
+
## v0.0.1
|
25
|
+
|
26
|
+
* Initial release
|
data/guard-rubocop.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.authors = ['Yuji Nakayama']
|
12
12
|
spec.email = ['nkymyj@gmail.com']
|
13
13
|
spec.summary = 'Guard plugin for RuboCop'
|
14
|
-
spec.description = 'Guard::Rubocop
|
14
|
+
spec.description = 'Guard::Rubocop automatically checks Ruby code style with RuboCop when files are modified.'
|
15
15
|
spec.homepage = 'https://github.com/yujinakayama/guard-rubocop'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
@@ -20,10 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_runtime_dependency
|
24
|
-
spec.add_runtime_dependency
|
25
|
-
spec.add_runtime_dependency "childprocess", '~> 0.3'
|
26
|
-
spec.add_runtime_dependency "term-ansicolor", '~> 1.1'
|
23
|
+
spec.add_runtime_dependency 'guard', '~> 1.8'
|
24
|
+
spec.add_runtime_dependency 'rubocop', '~> 0.9'
|
27
25
|
|
28
26
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
29
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/guard/rubocop.rb
CHANGED
@@ -26,26 +26,18 @@ module Guard
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def run_all
|
29
|
-
UI.info '
|
30
|
-
|
31
|
-
runner = Runner.new(@options)
|
32
|
-
passed = runner.run
|
33
|
-
@failed_paths = runner.failed_paths
|
34
|
-
|
35
|
-
throw :task_has_failed unless passed
|
29
|
+
UI.info 'Inspecting Ruby code style of all files'
|
30
|
+
run
|
36
31
|
end
|
37
32
|
|
38
33
|
def run_on_changes(paths)
|
39
34
|
paths += @failed_paths if @options[:keep_failed]
|
40
35
|
paths = clean_paths(paths)
|
41
36
|
|
42
|
-
|
37
|
+
displayed_paths = paths.map { |path| smart_path(path) }
|
38
|
+
UI.info "Inspecting Ruby code style: #{displayed_paths.join(' ')}"
|
43
39
|
|
44
|
-
|
45
|
-
passed = runner.run(paths)
|
46
|
-
@failed_paths = runner.failed_paths
|
47
|
-
|
48
|
-
throw :task_has_failed unless passed
|
40
|
+
run(paths)
|
49
41
|
end
|
50
42
|
|
51
43
|
def reload
|
@@ -64,6 +56,16 @@ module Guard
|
|
64
56
|
|
65
57
|
private
|
66
58
|
|
59
|
+
def run(paths = [])
|
60
|
+
runner = Runner.new(@options)
|
61
|
+
passed = runner.run(paths)
|
62
|
+
@failed_paths = runner.failed_paths
|
63
|
+
throw :task_has_failed unless passed
|
64
|
+
rescue => error
|
65
|
+
UI.error 'The following exception occurred while running guard-rubocop: ' +
|
66
|
+
"#{error.backtrace.first} #{error.message} (#{error.class.name})"
|
67
|
+
end
|
68
|
+
|
67
69
|
def included_in_other_path?(target_path, other_paths)
|
68
70
|
dir_paths = other_paths.select { |path| File.directory?(path) }
|
69
71
|
dir_paths.delete(target_path)
|
@@ -71,5 +73,13 @@ module Guard
|
|
71
73
|
target_path.start_with?(dir_path)
|
72
74
|
end
|
73
75
|
end
|
76
|
+
|
77
|
+
def smart_path(path)
|
78
|
+
if path.start_with?(Dir.pwd)
|
79
|
+
Pathname.new(path).relative_path_from(Pathname.getwd).to_s
|
80
|
+
else
|
81
|
+
path
|
82
|
+
end
|
83
|
+
end
|
74
84
|
end
|
75
85
|
end
|
data/lib/guard/rubocop/runner.rb
CHANGED
@@ -1,98 +1,91 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'term/ansicolor'
|
3
|
+
require 'json'
|
5
4
|
|
6
5
|
module Guard
|
7
6
|
class Rubocop
|
8
7
|
class Runner
|
9
|
-
PASSED_EXIT_CODE = 0
|
10
|
-
MINIMUM_POLL_INTERVAL = 0.1
|
11
|
-
|
12
|
-
attr_reader :passed, :output
|
13
|
-
|
14
|
-
alias_method :passed?, :passed
|
15
|
-
|
16
8
|
def initialize(options)
|
17
9
|
@options = options
|
18
10
|
end
|
19
11
|
|
20
12
|
def run(paths = [])
|
21
|
-
|
22
|
-
|
23
|
-
@output = Term::ANSIColor.uncolor(output)
|
13
|
+
command = build_command(paths)
|
14
|
+
passed = system(*command)
|
24
15
|
|
25
16
|
case @options[:notification]
|
26
17
|
when :failed
|
27
|
-
notify unless passed
|
18
|
+
notify(passed) unless passed
|
28
19
|
when true
|
29
|
-
notify
|
20
|
+
notify(passed)
|
30
21
|
end
|
31
22
|
|
32
23
|
passed
|
33
24
|
end
|
34
25
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
process.environment['CLICOLOR_FORCE'] = '1'
|
42
|
-
|
43
|
-
stdout_reader, process.io.stdout = IO.pipe
|
44
|
-
process.start
|
45
|
-
|
46
|
-
output = ''
|
26
|
+
def build_command(paths)
|
27
|
+
command = ['rubocop']
|
28
|
+
command.concat(%w(--format progress)) # Keep default formatter for console.
|
29
|
+
command.concat(['--format', 'json', '--out', json_file_path])
|
30
|
+
command.concat(paths)
|
31
|
+
end
|
47
32
|
|
48
|
-
|
49
|
-
|
50
|
-
|
33
|
+
def json_file_path
|
34
|
+
@tempfile_path ||= begin
|
35
|
+
# Just generate random tempfile path.
|
36
|
+
basename = self.class.name.downcase.gsub('::', '_')
|
37
|
+
tempfile = Tempfile.new(basename)
|
38
|
+
tempfile.close
|
39
|
+
tempfile.path
|
51
40
|
end
|
41
|
+
end
|
52
42
|
|
53
|
-
|
43
|
+
def result
|
44
|
+
@result ||= begin
|
45
|
+
File.open(json_file_path) do |file|
|
46
|
+
JSON.load(file, nil, symbolize_names: true)
|
47
|
+
end
|
48
|
+
end
|
54
49
|
end
|
55
50
|
|
56
|
-
def notify
|
51
|
+
def notify(passed)
|
57
52
|
image = passed ? :success : :failed
|
58
|
-
Notifier.notify(
|
53
|
+
Notifier.notify(summary_text, title: 'RuboCop results', image: image)
|
59
54
|
end
|
60
55
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
56
|
+
def summary_text
|
57
|
+
summary = result[:summary]
|
58
|
+
|
59
|
+
text = pluralize(summary[:inspected_file_count], 'file')
|
60
|
+
text << ' inspected, '
|
61
|
+
|
62
|
+
text << pluralize(summary[:offence_count], 'offence', no_for_zero: true)
|
63
|
+
text << ' detected'
|
64
64
|
end
|
65
65
|
|
66
66
|
def failed_paths
|
67
|
-
|
68
|
-
|
67
|
+
failed_files = result[:files].reject do |file|
|
68
|
+
file[:offences].empty?
|
69
|
+
end
|
70
|
+
failed_files.map do |file|
|
71
|
+
file[:path]
|
72
|
+
end
|
69
73
|
end
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
def capture_and_print_output(output)
|
74
|
-
available_ios, = IO.select([output], nil, nil, MINIMUM_POLL_INTERVAL)
|
75
|
-
return '' unless available_ios
|
76
|
-
chunk = available_ios.first.read_available_nonblock
|
77
|
-
$stdout.write chunk
|
78
|
-
chunk
|
79
|
-
end
|
75
|
+
def pluralize(number, thing, options = {})
|
76
|
+
text = ''
|
80
77
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
data = ''
|
86
|
-
loop do
|
87
|
-
begin
|
88
|
-
data << read_nonblock(READ_CHUNK_SIZE)
|
89
|
-
rescue ::IO::WaitReadable, EOFError
|
90
|
-
return data
|
91
|
-
end
|
92
|
-
end
|
78
|
+
if number == 0 && options[:no_for_zero]
|
79
|
+
text = 'no'
|
80
|
+
else
|
81
|
+
text << number.to_s
|
93
82
|
end
|
94
|
-
end
|
95
83
|
|
84
|
+
text << " #{thing}"
|
85
|
+
text << 's' unless number == 1
|
86
|
+
|
87
|
+
text
|
88
|
+
end
|
96
89
|
end
|
97
90
|
end
|
98
91
|
end
|
@@ -1,11 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper.rb'
|
4
|
-
require 'term/ansicolor'
|
5
|
-
|
6
|
-
describe Guard::Rubocop::Runner, :silence_output do
|
7
|
-
include CaptureHelper
|
8
4
|
|
5
|
+
describe Guard::Rubocop::Runner do
|
9
6
|
subject(:runner) { Guard::Rubocop::Runner.new(options) }
|
10
7
|
let(:options) { {} }
|
11
8
|
|
@@ -14,24 +11,26 @@ describe Guard::Rubocop::Runner, :silence_output do
|
|
14
11
|
let(:paths) { ['spec/spec_helper.rb'] }
|
15
12
|
|
16
13
|
before do
|
17
|
-
runner.stub(:
|
14
|
+
runner.stub(:system)
|
18
15
|
end
|
19
16
|
|
20
17
|
it 'executes rubocop' do
|
21
|
-
runner.should_receive(:
|
18
|
+
runner.should_receive(:system) do |*args|
|
19
|
+
args.first.should == 'rubocop'
|
20
|
+
end
|
22
21
|
runner.run
|
23
22
|
end
|
24
23
|
|
25
|
-
context 'when
|
24
|
+
context 'when RuboCop exited with 0 status' do
|
26
25
|
before do
|
27
|
-
runner.stub(:
|
26
|
+
runner.stub(:system).and_return(true)
|
28
27
|
end
|
29
28
|
it { should be_true }
|
30
29
|
end
|
31
30
|
|
32
|
-
context 'when
|
31
|
+
context 'when RuboCop exited with non 0 status' do
|
33
32
|
before do
|
34
|
-
runner.stub(:
|
33
|
+
runner.stub(:system).and_return(false)
|
35
34
|
end
|
36
35
|
it { should be_false }
|
37
36
|
end
|
@@ -53,7 +52,7 @@ describe Guard::Rubocop::Runner, :silence_output do
|
|
53
52
|
shared_examples 'notification' do |expectations|
|
54
53
|
context 'when passed' do
|
55
54
|
before do
|
56
|
-
runner.stub(:
|
55
|
+
runner.stub(:system).and_return(true)
|
57
56
|
end
|
58
57
|
|
59
58
|
if expectations[:passed]
|
@@ -65,7 +64,7 @@ describe Guard::Rubocop::Runner, :silence_output do
|
|
65
64
|
|
66
65
|
context 'when failed' do
|
67
66
|
before do
|
68
|
-
runner.stub(:
|
67
|
+
runner.stub(:system).and_return(false)
|
69
68
|
end
|
70
69
|
|
71
70
|
if expectations[:failed]
|
@@ -92,116 +91,198 @@ describe Guard::Rubocop::Runner, :silence_output do
|
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
95
|
-
describe '#
|
96
|
-
let(:paths) {
|
94
|
+
describe '#build_command' do
|
95
|
+
let(:paths) { %w(file1.rb file2.rb) }
|
97
96
|
|
98
|
-
it '
|
99
|
-
|
100
|
-
runner.rubocop(paths)
|
101
|
-
end.should include 'inspected'
|
97
|
+
it 'adds args for the default formatter for console' do
|
98
|
+
runner.build_command(paths)[0..2].should == %w(rubocop --format progress)
|
102
99
|
end
|
103
100
|
|
104
|
-
it '
|
105
|
-
|
106
|
-
exit_code.should == 0
|
107
|
-
output.should include 'inspected'
|
101
|
+
it 'adds args for JSON formatter ' do
|
102
|
+
runner.build_command(paths)[3..4].should == %w(--format json)
|
108
103
|
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe '#output' do
|
112
|
-
subject { super().output }
|
113
|
-
let(:paths) { ['spec/spec_helper.rb'] }
|
114
104
|
|
115
|
-
|
116
|
-
|
105
|
+
it 'adds args for output file path of JSON formatter ' do
|
106
|
+
command = runner.build_command(paths)
|
107
|
+
command[5].should == '--out'
|
108
|
+
command[6].should_not be_empty
|
117
109
|
end
|
118
110
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
111
|
+
it 'adds the passed paths' do
|
112
|
+
runner.build_command(paths)[7..-1].should == %w(file1.rb file2.rb)
|
113
|
+
end
|
114
|
+
end
|
123
115
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
116
|
+
describe '#json_file_path' do
|
117
|
+
it 'is not world readable' do
|
118
|
+
File.world_readable?(runner.json_file_path).should be_false
|
128
119
|
end
|
129
120
|
end
|
130
121
|
|
131
|
-
shared_context '
|
122
|
+
shared_context 'JSON file', :json_file do
|
132
123
|
before do
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
124
|
+
json = <<-END
|
125
|
+
{
|
126
|
+
"metadata": {
|
127
|
+
"rubocop_version": "0.9.0",
|
128
|
+
"ruby_engine": "ruby",
|
129
|
+
"ruby_version": "2.0.0",
|
130
|
+
"ruby_patchlevel": "195",
|
131
|
+
"ruby_platform": "x86_64-darwin12.3.0"
|
132
|
+
},
|
133
|
+
"files": [{
|
134
|
+
"path": "lib/foo.rb",
|
135
|
+
"offences": []
|
136
|
+
}, {
|
137
|
+
"path": "lib/bar.rb",
|
138
|
+
"offences": [{
|
139
|
+
"severity": "convention",
|
140
|
+
"message": "Line is too long. [81/79]",
|
141
|
+
"cop_name": "LineLength",
|
142
|
+
"location": {
|
143
|
+
"line": 546,
|
144
|
+
"column": 80
|
145
|
+
}
|
146
|
+
}, {
|
147
|
+
"severity": "warning",
|
148
|
+
"message": "Unreachable code detected.",
|
149
|
+
"cop_name": "UnreachableCode",
|
150
|
+
"location": {
|
151
|
+
"line": 15,
|
152
|
+
"column": 9
|
153
|
+
}
|
154
|
+
}
|
155
|
+
]
|
156
|
+
}
|
157
|
+
],
|
158
|
+
"summary": {
|
159
|
+
"offence_count": 2,
|
160
|
+
"target_file_count": 2,
|
161
|
+
"inspected_file_count": 2
|
162
|
+
}
|
163
|
+
}
|
164
|
+
END
|
165
|
+
File.write(runner.json_file_path, json)
|
166
|
+
end
|
167
|
+
end
|
139
168
|
|
140
|
-
|
141
|
-
|
142
|
-
|
169
|
+
describe '#result', :json_file do
|
170
|
+
it 'parses JSON file' do
|
171
|
+
runner.result[:summary][:offence_count].should == 2
|
143
172
|
end
|
144
173
|
end
|
145
174
|
|
146
|
-
describe '#notify'
|
175
|
+
describe '#notify' do
|
176
|
+
before do
|
177
|
+
runner.stub(:result).and_return(
|
178
|
+
{
|
179
|
+
summary: {
|
180
|
+
offence_count: 4,
|
181
|
+
target_file_count: 3,
|
182
|
+
inspected_file_count: 2
|
183
|
+
}
|
184
|
+
}
|
185
|
+
)
|
186
|
+
end
|
187
|
+
|
147
188
|
it 'notifies summary' do
|
148
189
|
Guard::Notifier.should_receive(:notify) do |message, options|
|
149
|
-
message.should == '
|
190
|
+
message.should == '2 files inspected, 4 offences detected'
|
150
191
|
end
|
151
|
-
runner.notify
|
192
|
+
runner.notify(true)
|
152
193
|
end
|
153
194
|
|
154
195
|
it 'notifies with title "RuboCop results"' do
|
155
196
|
Guard::Notifier.should_receive(:notify) do |message, options|
|
156
197
|
options[:title].should == 'RuboCop results'
|
157
198
|
end
|
158
|
-
runner.notify
|
199
|
+
runner.notify(true)
|
159
200
|
end
|
160
201
|
|
161
202
|
context 'when passed' do
|
162
|
-
before do
|
163
|
-
runner.stub(:passed).and_return(true)
|
164
|
-
end
|
165
|
-
|
166
203
|
it 'shows success image' do
|
167
204
|
Guard::Notifier.should_receive(:notify) do |message, options|
|
168
205
|
options[:image].should == :success
|
169
206
|
end
|
170
|
-
runner.notify
|
207
|
+
runner.notify(true)
|
171
208
|
end
|
172
209
|
end
|
173
210
|
|
174
211
|
context 'when failed' do
|
175
|
-
before do
|
176
|
-
runner.stub(:passed).and_return(false)
|
177
|
-
end
|
178
|
-
|
179
212
|
it 'shows failed image' do
|
180
213
|
Guard::Notifier.should_receive(:notify) do |message, options|
|
181
214
|
options[:image].should == :failed
|
182
215
|
end
|
183
|
-
runner.notify
|
216
|
+
runner.notify(false)
|
184
217
|
end
|
185
218
|
end
|
186
219
|
end
|
187
220
|
|
188
|
-
describe '#
|
189
|
-
|
221
|
+
describe '#summary_text' do
|
222
|
+
before do
|
223
|
+
runner.stub(:result).and_return(
|
224
|
+
{
|
225
|
+
summary: {
|
226
|
+
offence_count: offence_count,
|
227
|
+
target_file_count: target_file_count,
|
228
|
+
inspected_file_count: inspected_file_count
|
229
|
+
}
|
230
|
+
}
|
231
|
+
)
|
232
|
+
end
|
233
|
+
|
234
|
+
subject(:summary_text) { runner.summary_text }
|
235
|
+
|
236
|
+
let(:offence_count) { 0 }
|
237
|
+
let(:target_file_count) { 0 }
|
238
|
+
let(:inspected_file_count) { 0 }
|
190
239
|
|
191
|
-
|
192
|
-
|
240
|
+
context 'when no files are inspected' do
|
241
|
+
let(:inspected_file_count) { 0 }
|
242
|
+
it 'includes "0 files"' do
|
243
|
+
summary_text.should include '0 files'
|
244
|
+
end
|
193
245
|
end
|
194
|
-
end
|
195
246
|
|
196
|
-
|
197
|
-
|
247
|
+
context 'when a file is inspected' do
|
248
|
+
let(:inspected_file_count) { 1 }
|
249
|
+
it 'includes "1 file"' do
|
250
|
+
summary_text.should include '1 file'
|
251
|
+
end
|
252
|
+
end
|
198
253
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
254
|
+
context 'when 2 files are inspected' do
|
255
|
+
let(:inspected_file_count) { 2 }
|
256
|
+
it 'includes "2 files"' do
|
257
|
+
summary_text.should include '2 files'
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
context 'when no offences are detected' do
|
262
|
+
let(:offence_count) { 0 }
|
263
|
+
it 'includes "no offences"' do
|
264
|
+
summary_text.should include 'no offences'
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'when an offence is detected' do
|
269
|
+
let(:offence_count) { 1 }
|
270
|
+
it 'includes "1 offence"' do
|
271
|
+
summary_text.should include '1 offence'
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context 'when 2 offences are detected' do
|
276
|
+
let(:offence_count) { 2 }
|
277
|
+
it 'includes "2 offences"' do
|
278
|
+
summary_text.should include '2 offences'
|
279
|
+
end
|
204
280
|
end
|
205
281
|
end
|
206
282
|
|
283
|
+
describe '#failed_paths', :json_file do
|
284
|
+
it 'returns file paths which have offences' do
|
285
|
+
runner.failed_paths.should == ['lib/bar.rb']
|
286
|
+
end
|
287
|
+
end
|
207
288
|
end
|
data/spec/guard/rubocop_spec.rb
CHANGED
@@ -73,6 +73,13 @@ describe Guard::Rubocop, :silence_output do
|
|
73
73
|
guard.failed_paths.should == failed_paths
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
context 'when an exception is raised' do
|
78
|
+
it 'prevents itself from firing' do
|
79
|
+
runner.stub(:run).and_raise(RuntimeError)
|
80
|
+
expect { subject }.not_to raise_error
|
81
|
+
end
|
82
|
+
end
|
76
83
|
end
|
77
84
|
|
78
85
|
describe '#run_all', :processes_after_running do
|
@@ -80,10 +87,11 @@ describe Guard::Rubocop, :silence_output do
|
|
80
87
|
|
81
88
|
before do
|
82
89
|
runner.stub(:run).and_return(true)
|
90
|
+
runner.stub(:failed_paths).and_return([])
|
83
91
|
end
|
84
92
|
|
85
93
|
it 'inspects all files with rubocop' do
|
86
|
-
runner.should_receive(:run).with(
|
94
|
+
runner.should_receive(:run).with([])
|
87
95
|
guard.run_all
|
88
96
|
end
|
89
97
|
end
|
@@ -94,6 +102,7 @@ describe Guard::Rubocop, :silence_output do
|
|
94
102
|
|
95
103
|
before do
|
96
104
|
runner.stub(:run).and_return(true)
|
105
|
+
runner.stub(:failed_paths).and_return([])
|
97
106
|
end
|
98
107
|
|
99
108
|
it 'inspects changed files with rubocop' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -26,52 +26,18 @@ dependencies:
|
|
26
26
|
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.8.2
|
34
|
-
- - <
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 0.9.0
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - '>='
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.8.2
|
44
|
-
- - <
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.9.0
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: childprocess
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.3'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.3'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: term-ansicolor
|
63
29
|
requirement: !ruby/object:Gem::Requirement
|
64
30
|
requirements:
|
65
31
|
- - ~>
|
66
32
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
33
|
+
version: '0.9'
|
68
34
|
type: :runtime
|
69
35
|
prerelease: false
|
70
36
|
version_requirements: !ruby/object:Gem::Requirement
|
71
37
|
requirements:
|
72
38
|
- - ~>
|
73
39
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
40
|
+
version: '0.9'
|
75
41
|
- !ruby/object:Gem::Dependency
|
76
42
|
name: bundler
|
77
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +122,15 @@ dependencies:
|
|
156
122
|
- - ~>
|
157
123
|
- !ruby/object:Gem::Version
|
158
124
|
version: '0.3'
|
159
|
-
description: Guard::Rubocop
|
160
|
-
|
125
|
+
description: Guard::Rubocop automatically checks Ruby code style with RuboCop when
|
126
|
+
files are modified.
|
161
127
|
email:
|
162
128
|
- nkymyj@gmail.com
|
163
129
|
executables: []
|
164
130
|
extensions: []
|
165
131
|
extra_rdoc_files: []
|
166
132
|
files:
|
133
|
+
- CHANGELOG.md
|
167
134
|
- Gemfile
|
168
135
|
- Guardfile
|
169
136
|
- LICENSE.txt
|
@@ -177,7 +144,6 @@ files:
|
|
177
144
|
- spec/guard/rubocop/runner_spec.rb
|
178
145
|
- spec/guard/rubocop_spec.rb
|
179
146
|
- spec/spec_helper.rb
|
180
|
-
- spec/support/capture_helper.rb
|
181
147
|
- spec/support/silence_output.rb
|
182
148
|
homepage: https://github.com/yujinakayama/guard-rubocop
|
183
149
|
licenses:
|
@@ -207,6 +173,5 @@ test_files:
|
|
207
173
|
- spec/guard/rubocop/runner_spec.rb
|
208
174
|
- spec/guard/rubocop_spec.rb
|
209
175
|
- spec/spec_helper.rb
|
210
|
-
- spec/support/capture_helper.rb
|
211
176
|
- spec/support/silence_output.rb
|
212
177
|
has_rdoc:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
module CaptureHelper
|
4
|
-
# rubocop:disable Eval
|
5
|
-
def capture(stream_name)
|
6
|
-
stream_name = stream_name.to_s.downcase
|
7
|
-
original_stream = eval("$#{stream_name}")
|
8
|
-
eval("$#{stream_name} = StringIO.new")
|
9
|
-
|
10
|
-
begin
|
11
|
-
yield
|
12
|
-
result = eval("$#{stream_name}").string
|
13
|
-
ensure
|
14
|
-
eval("$#{stream_name} = original_stream")
|
15
|
-
end
|
16
|
-
|
17
|
-
result
|
18
|
-
end
|
19
|
-
# rubocop:enable Eval
|
20
|
-
end
|