guard-reek 1.1.0 → 1.2.0

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: 3e14145294d2397904b31818eca863d6c8d0fc29
4
- data.tar.gz: 83f8324385d5faf09c04205d38dcc281eb6564dc
3
+ metadata.gz: 2b2f9c07536b9de785e7d0e455756820f4d49cfa
4
+ data.tar.gz: 7e5006fbdef4fe4e1c66ac86fd7d0d369f0e1520
5
5
  SHA512:
6
- metadata.gz: ed13bded7c1a6889fff97b47abf83b68afed9ba5e2acf795ea13759be9233bd17dfdb8943285a211c4a6eb9e308aeeba72c37a790bdca10e75a60ba677f32e06
7
- data.tar.gz: f8ccbff9580d94599e85d772b6bd46762dcc82b869fda20243c2a9f12b1922d5ce4f448f3d9cdbb81cca49f11a1be5008267459e752a768de7f19ef93d3a25fe
6
+ metadata.gz: b2a585c094df8e9e40b353c5945a86d821f75ee5c8b080d98080b2088b82e969d523ca83fcfb09eb00c4c8e2ea7042a314a3b9ccfc2fca0e64dc76b4ced83ec2
7
+ data.tar.gz: ef18dd28416c02bd8f2cde852b60fac8e9c413e3d803f021185d027312da3d74af729a8debe1cf4556cad0dcd615f13764b6de34f3fa203d8fd5e4f2915ae002
@@ -1,10 +1,14 @@
1
1
  language: ruby
2
+ addons:
3
+ apt:
4
+ packages:
5
+ - haveged
2
6
  rvm:
3
- - 2.1.9
4
- - 2.2.5
5
- - 2.3.1
7
+ - 2.1.10
8
+ - 2.2.7
9
+ - 2.3.4
6
10
  - jruby-9.0.5.0
7
- - jruby-9.1.5.0
11
+ - jruby-9.1.12.0
8
12
  env:
9
13
  global:
10
14
  - RUBY_ENV=test
@@ -0,0 +1,5 @@
1
+ # Change log
2
+
3
+ ## 1.2.0
4
+ * `all` defaults to `*`
5
+ * option to set `all`
data/Guardfile CHANGED
@@ -4,7 +4,7 @@ guard :rspec, cmd: 'bundle exec rspec', all_on_start: true do
4
4
  watch('spec/spec_helper.rb') { "spec" }
5
5
  end
6
6
 
7
- guard :reek, cli: '--single-line' do
7
+ guard :reek, cli: ['--single-line', '--empty-headings'] do
8
8
  watch('config.reek')
9
9
  watch(/^lib\/.*\.rb$/)
10
10
  end
data/README.md CHANGED
@@ -54,6 +54,9 @@ end
54
54
  ```
55
55
  all_on_start: true # Check all files at Guard startup.
56
56
  # default: true
57
+ all: 'app lib spec' # What to run when running all
58
+ # An array or string is acceptable.
59
+ # default: *
57
60
  cli: '--single-line' # Pass arbitrary reek CLI arguments.
58
61
  # An array or string is acceptable.
59
62
  # default: nil
@@ -9,41 +9,55 @@ module Guard
9
9
 
10
10
  def initialize(options)
11
11
  @cli = options[:cli]
12
+ @all = options[:all] || '*'
12
13
  @notifier = options[:notifier] || Notifier
13
14
  @ui = options[:ui] || UI
14
15
  end
15
16
 
16
- def run(paths = [])
17
- paths = [] if paths.include?('.reek')
18
- ui_message(paths)
19
-
20
- command = reek_cmd.concat(paths)
21
- @result = Kernel.system(*command)
22
-
23
- notify_about_result
24
- end
25
-
26
- private
17
+ # this class decides which files are run against reek
18
+ class Paths
19
+ def initialize(paths, all)
20
+ @all = all
21
+ @paths = paths
22
+ @paths = [] if @paths.include?('.reek')
23
+ end
27
24
 
28
- def reek_cmd
29
- ['reek', @cli].compact
30
- end
25
+ def to_s
26
+ @paths.empty? ? 'all' : @paths.to_s
27
+ end
31
28
 
32
- def ui_message(paths)
33
- if paths.empty?
34
- ui.info('Guard::Reek running on all')
35
- else
36
- ui.info("Guard::Reek is running on #{paths}")
29
+ def to_ary
30
+ if @paths.empty?
31
+ Array(@all)
32
+ else
33
+ @paths
34
+ end
37
35
  end
38
36
  end
39
37
 
40
- def notify_about_result
38
+ def run(paths = [])
39
+ result = run_reek_cmd(paths)
40
+
41
41
  if result
42
42
  notifier.notify('Reek Results', title: 'Passed', image: :success)
43
43
  else
44
44
  notifier.notify('Reek Results', title: 'Failed', image: :failed)
45
45
  end
46
46
  end
47
+
48
+ private
49
+
50
+ def run_reek_cmd(paths)
51
+ runner_paths = Paths.new(paths, @all)
52
+ ui.info("Guard::Reek is running on #{runner_paths}")
53
+
54
+ command = reek_cmd.concat(runner_paths)
55
+ Kernel.system(command.join(' '))
56
+ end
57
+
58
+ def reek_cmd
59
+ ['reek', @cli].compact
60
+ end
47
61
  end
48
62
  end
49
63
  end
@@ -6,7 +6,7 @@ module Guard
6
6
  module ReekVersion
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
@@ -12,23 +12,35 @@ describe Guard::Reek::Runner do
12
12
  end
13
13
 
14
14
  it 'executes reek' do
15
- expect(Kernel).to receive(:system).with('reek')
15
+ expect(Kernel).to receive(:system).with('reek *')
16
16
  subject.run
17
17
  end
18
18
 
19
19
  it 'executes reek with file' do
20
- expect(Kernel).to receive(:system).with('reek', 'test.rb')
20
+ expect(Kernel).to receive(:system).with('reek test.rb')
21
21
  subject.run(['test.rb'])
22
22
  end
23
23
 
24
24
  it 'executes reek when .reek updated' do
25
- expect(Kernel).to receive(:system).with('reek')
25
+ expect(Kernel).to receive(:system).with('reek *')
26
26
  subject.run(['.reek'])
27
27
  end
28
28
 
29
29
  it 'executes reek with cli options' do
30
30
  options[:cli] = '-s'
31
- expect(Kernel).to receive(:system).with('reek', '-s')
31
+ expect(Kernel).to receive(:system).with('reek -s *')
32
+ subject.run
33
+ end
34
+
35
+ it 'executes reek with all options as string' do
36
+ options[:all] = 'app'
37
+ expect(Kernel).to receive(:system).with('reek app')
38
+ subject.run
39
+ end
40
+
41
+ it 'executes reek with all options as array' do
42
+ options[:all] = %w[app lib]
43
+ expect(Kernel).to receive(:system).with('reek app lib')
32
44
  subject.run
33
45
  end
34
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-reek
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
  - Grant Petersen-Speelman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-23 00:00:00.000000000 Z
12
+ date: 2017-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: reek
@@ -148,6 +148,7 @@ files:
148
148
  - .gitignore
149
149
  - .rspec
150
150
  - .travis.yml
151
+ - CHANGELOG.md
151
152
  - Gemfile
152
153
  - Guardfile
153
154
  - LICENSE.txt