guard-rubocop 1.1.0 → 1.2.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: aa248932e68a78aa1fc24ae53d4d300b71640a11
4
- data.tar.gz: d23806def0e10055e1aa4988dcd0138a4fa9d43a
3
+ metadata.gz: 1535c13164518a07f9bd376581c0900c514ce4af
4
+ data.tar.gz: 279736e6d095f6a5c941ed5d8b2f52850c92c535
5
5
  SHA512:
6
- metadata.gz: fc9f0a685b407939a1d8ea48498d0b5be5f1886c9108281f712cb5d0cc39fb7acad86d33cf8f9fe5a0f8211c716a10178682f457c9188e6529fcfaf2a32220d5
7
- data.tar.gz: d00ac9dee7125d9b4fa215953121376d2dcce500a5261e58066748732454574b1c5768c74c88798bf27c1a67ead7c64d3aa197b155360a73b9f5736d23cab798
6
+ metadata.gz: 9db576e8a05603ebb436e244bc55a8f62bc436b7c3670211d82e5d4e990660eb8274fad252bcc4fe0b8461cb6130c5afa39d9eec4a5a43b3c81426328ff3011b
7
+ data.tar.gz: ae8db14b3b120dfbea98d0086c39348d4bd28f8a76188f463ceedf7fe6d67b3b975847a510430306c333a70d11381c702f3c3c4f16952737e268cc6c1cf786d4
@@ -5,3 +5,7 @@ LineLength:
5
5
  # The default 10 lines limit is unrealistic.
6
6
  MethodLength:
7
7
  Max: 15
8
+
9
+ RegexpLiteral:
10
+ Exclude:
11
+ - '**/Guardfile'
@@ -4,7 +4,6 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.0
6
6
  - jruby-19mode
7
- - rbx
8
7
  script:
9
8
  - bundle exec rspec
10
9
  - bundle exec rubocop
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v1.2.0
6
+
7
+ * Add `:hide_stdout` option ([#15](https://github.com/yujinakayama/guard-rubocop/pull/15))
8
+
5
9
  ## v1.1.0
6
10
 
7
11
  * Use RuboCop's `--force-exclusion` option to always ignore files specified in the `Exclude` configuration in `.rubocop.yml`
data/Guardfile CHANGED
@@ -5,8 +5,8 @@ group :red_green_refactor, halt_on_fail: true do
5
5
  guard :rspec, all_after_pass: true, all_on_start: true, cmd: 'bundle exec rspec' do
6
6
  watch(%r{^spec/.+_spec\.rb$})
7
7
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
- watch('spec/spec_helper.rb') { "spec" }
9
- watch(%r{^spec/support/.+\.rb$}) { "spec" }
8
+ watch('spec/spec_helper.rb') { 'spec' }
9
+ watch(%r{^spec/support/.+\.rb$}) { 'spec' }
10
10
  end
11
11
 
12
12
  guard :rubocop do
data/README.md CHANGED
@@ -62,6 +62,8 @@ all_on_start: true # Check all files at Guard startup.
62
62
  cli: '--rails' # Pass arbitrary RuboCop CLI arguments.
63
63
  # An array or string is acceptable.
64
64
  # default: nil
65
+ hide_stdout: false # Do not display console output (in case outputting to file).
66
+ # default: false
65
67
  keep_failed: true # Keep failed files until they pass.
66
68
  # default: true
67
69
  notification: :failed # Display Growl notification after each run.
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
+ # coding: utf-8
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rubocop/rake_task'
4
6
 
5
7
  RSpec::Core::RakeTask.new(:spec)
6
- Rubocop::RakeTask.new(:style)
8
+ RuboCop::RakeTask.new(:style)
7
9
 
8
10
  namespace :ci do
9
11
  task :spec do
@@ -7,17 +7,18 @@ require 'guard/rubocop/version'
7
7
 
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'guard-rubocop'
10
- spec.version = Guard::RubocopVersion.to_s
10
+ spec.version = Guard::RuboCopVersion.to_s
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 automatically checks Ruby code style with RuboCop when files are modified.'
14
+ spec.description = 'Guard::Rubocop automatically checks Ruby code style with RuboCop ' \
15
+ 'when files are modified.'
15
16
  spec.homepage = 'https://github.com/yujinakayama/guard-rubocop'
16
17
  spec.license = 'MIT'
17
18
 
18
- spec.files = `git ls-files`.split($/)
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
20
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(/^spec\//)
21
22
  spec.require_paths = ['lib']
22
23
 
23
24
  spec.add_runtime_dependency 'guard', '~> 2.0'
@@ -25,7 +26,7 @@ Gem::Specification.new do |spec|
25
26
 
26
27
  spec.add_development_dependency 'bundler', '~> 1.3'
27
28
  spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec', '~> 3.0.0.beta1'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
30
  spec.add_development_dependency 'simplecov', '~> 0.7'
30
31
  spec.add_development_dependency 'guard-rspec', '>= 4.2.3', '< 5.0'
31
32
  spec.add_development_dependency 'ruby_gntp', '~> 0.3'
@@ -4,9 +4,9 @@ require 'guard'
4
4
  require 'guard/plugin'
5
5
 
6
6
  module Guard
7
- # This class gets API calls from `guard` and runs `rubocop` command via {Guard::Rubocop::Runner}.
7
+ # This class gets API calls from `guard` and runs `rubocop` command via {Guard::RuboCop::Runner}.
8
8
  # An instance of this class stays alive in a `guard` command session.
9
- class Rubocop < Plugin
9
+ class RuboCop < Plugin
10
10
  autoload :Runner, 'guard/rubocop/runner'
11
11
 
12
12
  attr_reader :options, :failed_paths
@@ -18,7 +18,8 @@ module Guard
18
18
  all_on_start: true,
19
19
  keep_failed: true,
20
20
  notification: :failed,
21
- cli: nil
21
+ cli: nil,
22
+ hide_stdout: false
22
23
  }.merge(options)
23
24
 
24
25
  @failed_paths = []
@@ -3,7 +3,7 @@
3
3
  require 'json'
4
4
 
5
5
  module Guard
6
- class Rubocop
6
+ class RuboCop
7
7
  # This class runs `rubocop` command, retrieves result and notifies.
8
8
  # An instance of this class is intended to invoke `rubocop` only once in its lifetime.
9
9
  class Runner
@@ -28,7 +28,7 @@ module Guard
28
28
  def build_command(paths)
29
29
  command = ['rubocop']
30
30
 
31
- unless include_formatter_for_console?(args_specified_by_user)
31
+ if should_add_default_formatter_for_console?
32
32
  command.concat(%w(--format progress)) # Keep default formatter for console.
33
33
  end
34
34
 
@@ -38,6 +38,10 @@ module Guard
38
38
  command.concat(paths)
39
39
  end
40
40
 
41
+ def should_add_default_formatter_for_console?
42
+ !@options[:hide_stdout] && !include_formatter_for_console?(args_specified_by_user)
43
+ end
44
+
41
45
  def args_specified_by_user
42
46
  @args_specified_by_user ||= begin
43
47
  args = @options[:cli]
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Guard
4
- # A workaround for declaring `class Rubocop`
5
- # before `class Rubocop < Guard` in rubocop.rb
6
- module RubocopVersion
4
+ # A workaround for declaring `class RuboCop`
5
+ # before `class RuboCop < Guard` in rubocop.rb
6
+ module RuboCopVersion
7
7
  # http://semver.org/
8
8
  MAJOR = 1
9
- MINOR = 1
9
+ MINOR = 2
10
10
  PATCH = 0
11
11
 
12
12
  def self.to_s
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'spec_helper.rb'
4
4
 
5
- describe Guard::Rubocop::Runner do
6
- subject(:runner) { Guard::Rubocop::Runner.new(options) }
5
+ describe Guard::RuboCop::Runner do
6
+ subject(:runner) { Guard::RuboCop::Runner.new(options) }
7
7
  let(:options) { {} }
8
8
 
9
9
  describe '#run' do
@@ -96,19 +96,41 @@ describe Guard::Rubocop::Runner do
96
96
  let(:options) { { cli: %w(--debug --rails) } }
97
97
  let(:paths) { %w(file1.rb file2.rb) }
98
98
 
99
- context 'when :cli option includes formatter for console' do
100
- let(:options) { { cli: %w(--format simple) } }
99
+ context 'when :hide_stdout is not set' do
100
+ context 'and :cli option includes formatter for console' do
101
+ before { options[:cli] = %w(--format simple) }
101
102
 
102
- it 'does not add args for the default formatter for console' do
103
- expect(build_command[0..2]).not_to eq(%w(rubocop --format progress))
103
+ it 'does not add args for the default formatter for console' do
104
+ expect(build_command[0..2]).not_to eq(%w(rubocop --format progress))
105
+ end
106
+ end
107
+
108
+ context 'and :cli option does not include formatter for console' do
109
+ before { options[:cli] = %w(--format simple --out simple.txt) }
110
+
111
+ it 'adds args for the default formatter for console' do
112
+ expect(build_command[0..2]).to eq(%w(rubocop --format progress))
113
+ end
104
114
  end
105
115
  end
106
116
 
107
- context 'when :cli option does not include formatter for console' do
108
- let(:options) { { cli: %w(--format simple --out simple.txt) } }
117
+ context 'when :hide_stdout is set' do
118
+ before { options[:hide_stdout] = true }
119
+
120
+ context 'and :cli option includes formatter for console' do
121
+ before { options[:cli] = %w(--format simple) }
109
122
 
110
- it 'adds args for the default formatter for console' do
111
- expect(build_command[0..2]).to eq(%w(rubocop --format progress))
123
+ it 'does not add args for the default formatter for console' do
124
+ expect(build_command[0..2]).not_to eq(%w(rubocop --format progress))
125
+ end
126
+ end
127
+
128
+ context 'and :cli option does not include formatter for console' do
129
+ before { options[:cli] = %w(--format simple --out simple.txt) }
130
+
131
+ it 'does not add args for the default formatter for console' do
132
+ expect(build_command[0..2]).not_to eq(%w(rubocop --format progress))
133
+ end
112
134
  end
113
135
  end
114
136
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'spec_helper.rb'
4
4
 
5
- describe Guard::Rubocop, :silence_output do
6
- subject(:guard) { Guard::Rubocop.new(options) }
5
+ describe Guard::RuboCop, :silence_output do
6
+ subject(:guard) { Guard::RuboCop.new(options) }
7
7
  let(:options) { {} }
8
8
 
9
9
  describe '#options' do
@@ -57,13 +57,13 @@ describe Guard::Rubocop, :silence_output do
57
57
  shared_examples 'processes after running', :processes_after_running do
58
58
  context 'when passed' do
59
59
  it 'throws nothing' do
60
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true)
60
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:run).and_return(true)
61
61
  expect { subject }.not_to throw_symbol
62
62
  end
63
63
 
64
64
  it 'clears failed paths' do
65
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true)
66
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:failed_paths).and_return([])
65
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:run).and_return(true)
66
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:failed_paths).and_return([])
67
67
  subject
68
68
  expect(guard.failed_paths).to be_empty
69
69
  end
@@ -71,7 +71,7 @@ describe Guard::Rubocop, :silence_output do
71
71
 
72
72
  context 'when failed' do
73
73
  it 'throws symbol :task_has_failed' do
74
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(false)
74
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:run).and_return(false)
75
75
  expect { subject }.to throw_symbol(:task_has_failed)
76
76
  end
77
77
 
@@ -81,8 +81,8 @@ describe Guard::Rubocop, :silence_output do
81
81
  'some_failed_file.rb',
82
82
  'dir/another_failed_file.rb'
83
83
  ]
84
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(false)
85
- allow_any_instance_of(Guard::Rubocop::Runner)
84
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:run).and_return(false)
85
+ allow_any_instance_of(Guard::RuboCop::Runner)
86
86
  .to receive(:failed_paths).and_return(failed_paths)
87
87
  subject
88
88
  expect(guard.failed_paths).to eq(failed_paths)
@@ -91,7 +91,7 @@ describe Guard::Rubocop, :silence_output do
91
91
 
92
92
  context 'when an exception is raised' do
93
93
  it 'prevents itself from firing' do
94
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_raise(RuntimeError)
94
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:run).and_raise(RuntimeError)
95
95
  expect { subject }.not_to raise_error
96
96
  end
97
97
  end
@@ -101,12 +101,12 @@ describe Guard::Rubocop, :silence_output do
101
101
  subject { super().run_all }
102
102
 
103
103
  before do
104
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:run).and_return(true)
105
- allow_any_instance_of(Guard::Rubocop::Runner).to receive(:failed_paths).and_return([])
104
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:run).and_return(true)
105
+ allow_any_instance_of(Guard::RuboCop::Runner).to receive(:failed_paths).and_return([])
106
106
  end
107
107
 
108
108
  it 'inspects all files with rubocop' do
109
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run).with([])
109
+ expect_any_instance_of(Guard::RuboCop::Runner).to receive(:run).with([])
110
110
  guard.run_all
111
111
  end
112
112
  end
@@ -122,17 +122,17 @@ describe Guard::Rubocop, :silence_output do
122
122
  end
123
123
 
124
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([])
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
127
  end
128
128
 
129
129
  it 'inspects changed files with rubocop' do
130
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run)
130
+ expect_any_instance_of(Guard::RuboCop::Runner).to receive(:run)
131
131
  subject
132
132
  end
133
133
 
134
134
  it 'passes cleaned paths to rubocop' do
135
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |_instance, paths|
135
+ expect_any_instance_of(Guard::RuboCop::Runner).to receive(:run) do |_instance, paths|
136
136
  expect(paths).to eq([
137
137
  File.expand_path('lib/guard/rubocop.rb'),
138
138
  File.expand_path('spec/spec_helper.rb')
@@ -147,7 +147,7 @@ describe Guard::Rubocop, :silence_output do
147
147
  end
148
148
 
149
149
  it 'does nothing' do
150
- expect_any_instance_of(Guard::Rubocop::Runner).not_to receive(:run)
150
+ expect_any_instance_of(Guard::RuboCop::Runner).not_to receive(:run)
151
151
  subject
152
152
  end
153
153
  end
@@ -159,7 +159,7 @@ describe Guard::Rubocop, :silence_output do
159
159
 
160
160
  it 'also inspects paths which are failed last time' do
161
161
  guard.failed_paths << failed_path
162
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |_instance, paths|
162
+ expect_any_instance_of(Guard::RuboCop::Runner).to receive(:run) do |_instance, paths|
163
163
  expect(paths).to include failed_path
164
164
  end
165
165
  subject
@@ -171,7 +171,7 @@ describe Guard::Rubocop, :silence_output do
171
171
 
172
172
  it 'inspects just changed paths' do
173
173
  guard.failed_paths << failed_path
174
- expect_any_instance_of(Guard::Rubocop::Runner).to receive(:run) do |_instance, paths|
174
+ expect_any_instance_of(Guard::RuboCop::Runner).to receive(:run) do |_instance, paths|
175
175
  expect(paths).to eq([
176
176
  File.expand_path('lib/guard/rubocop.rb'),
177
177
  File.expand_path('spec/spec_helper.rb')
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: 1.1.0
4
+ version: 1.2.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: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 3.0.0.beta1
75
+ version: '3.0'
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
- version: 3.0.0.beta1
82
+ version: '3.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.2.2
179
+ rubygems_version: 2.4.2
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Guard plugin for RuboCop