guard-rubocop 1.0.0 → 1.0.1

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: ee67224feb5ed77ab48db7a593b0d9dc97047014
4
- data.tar.gz: 2b2c4fc6e147d90bf97922dbd4c870e4aa389e1d
3
+ metadata.gz: ec82afdd85de6be92deca90949f571a84eae25cf
4
+ data.tar.gz: 68d6f82e862a90d3625e4fcf0b1c06d36a67221c
5
5
  SHA512:
6
- metadata.gz: bfd262dbc1a81cfe4cb9ef6f1cec3fea7d3e0f2092b9afdd8e7c88dc2809bde6b0d46f925b715321d1d4ec9512c49fc644ec1e0b5cb1940ba20490f7b301e838
7
- data.tar.gz: 18ebd330633b8a5e3bd023aa94d9b2ab6608d9a30674893c4768d79770d220e8a786f82a5c61a8ded02598b028879028c7b0b0c588bebc041085b934c31378a5
6
+ metadata.gz: d40d80a751bc72240d3c0d5b1c1ace21c12e1792a66ee481511733c91ff1f360c478eda6ccf31bf80cf2475ab1c4464176ebf979f61514a668998339687328ea
7
+ data.tar.gz: 5a2c18d2e662dc0744463c374bd94cf55979b816538726dd89f81bac3dce0d14850ced6d4dbd35a72caf3c72372cf96cb433651a775ccfdb4eef8ac1cd6127cd
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/bundle
@@ -0,0 +1,7 @@
1
+ # The default 79 character limit is sometimes unproductive.
2
+ LineLength:
3
+ Max: 100
4
+
5
+ # The default 10 lines limit is unrealistic.
6
+ MethodLength:
7
+ Max: 15
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-19mode
6
+ script:
7
+ - bundle exec rspec
8
+ - bundle exec rubocop
@@ -0,0 +1 @@
1
+ --markup markdown
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Master
3
+ ## Development
4
+
5
+ ## v1.0.1
6
+
7
+ * Fix inappripriate multiple run on a save with Vim ([#6](https://github.com/yujinakayama/guard-rubocop/pull/6))
4
8
 
5
9
  ## v1.0.0
6
10
 
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.
@@ -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($/).reject { |f| File.basename(f).start_with?('.') }
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', '~> 3.0'
30
+ spec.add_development_dependency 'guard-rspec', '~> 4.0'
31
31
  spec.add_development_dependency 'ruby_gntp', '~> 0.3'
32
32
  end
@@ -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
- run
33
+ inspect_with_rubocop
34
34
  end
35
35
 
36
- def run_on_changes(paths)
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
- run(paths)
59
+ inspect_with_rubocop(paths)
46
60
  end
47
61
 
48
- def reload
49
- @failed_paths = []
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)
@@ -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
@@ -7,7 +7,7 @@ module Guard
7
7
  # http://semver.org/
8
8
  MAJOR = 1
9
9
  MINOR = 0
10
- PATCH = 0
10
+ PATCH = 1
11
11
 
12
12
  def self.to_s
13
13
  [MAJOR, MINOR, PATCH].join('.')
@@ -0,0 +1,5 @@
1
+ inherit_from: ../.rubocop.yml
2
+
3
+ # Sometimes I want to indicate that “This is a hash” explicitly with #and_return.
4
+ BracesAroundHashParameters:
5
+ Enabled: false
@@ -11,10 +11,26 @@ describe Guard::Rubocop, :silence_output do
11
11
 
12
12
  context 'by default' do
13
13
  let(:options) { {} }
14
- its([:all_on_start]) { should be_true }
15
- its([:keep_failed]) { should be_true }
16
- its([:notification]) { should == :failed }
17
- its([:cli]) { should be_nil }
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
- describe '#run_on_changes', :processes_after_running do
99
- subject { super().run_on_changes(changed_paths) }
100
- let(:changed_paths) do
101
- [
102
- 'lib/guard/rubocop.rb',
103
- 'spec/spec_helper.rb'
104
- ]
105
- end
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
- it 'inspects changed files with rubocop' do
113
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run)
114
- guard.run_on_changes(changed_paths)
115
- end
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
- it 'passes cleaned paths to rubocop' do
118
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths|
119
- expect(paths).to eq([
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
- context 'when cleaned paths are empty' do
128
- before do
129
- allow(guard).to receive(:clean_paths).and_return([])
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
- it 'does nothing' do
133
- expect_any_instance_of(Guard::Rubocop::Runner).not_to receive(:run)
134
- guard.run_on_changes(changed_paths)
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
- let(:failed_path) { File.expand_path('Rakefile') }
155
+ let(:failed_path) { File.expand_path('Rakefile') }
139
156
 
140
- context 'when :keep_failed option is enabled' do
141
- let(:options) { { keep_failed: true } }
157
+ context 'when :keep_failed option is enabled' do
158
+ let(:options) { { keep_failed: true } }
142
159
 
143
- it 'also inspects paths which are failed last time' do
144
- guard.failed_paths << failed_path
145
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths|
146
- expect(paths).to include failed_path
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
- context 'when :keep_failed option is disabled' do
153
- let(:options) { { keep_failed: false } }
169
+ context 'when :keep_failed option is disabled' do
170
+ let(:options) { { keep_failed: false } }
154
171
 
155
- it 'inspects just changed paths' do
156
- guard.failed_paths << failed_path
157
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |paths|
158
- expect(paths).to eq(changed_paths)
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(guard.clean_paths(paths)).to eq([
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(guard.clean_paths(paths)).to eq([
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(guard.clean_paths(paths)).to eq([
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(guard.clean_paths(paths)).to eq([
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.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-10-06 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
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.3
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