guard-preek 0.0.4 → 0.0.5

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: f0ab530a436bfeed1df22b41a0b2488997008542
4
- data.tar.gz: cc3ec50ace5e0461f5620c53393b3216ecfa05f2
3
+ metadata.gz: 1bc8f29cf814a1eed75c9c8caac776ddf52740af
4
+ data.tar.gz: a38f19c09e73c0c951fe57024c0e37757947c74d
5
5
  SHA512:
6
- metadata.gz: eba871e32c5901b9572f16342509bc5557587132e4859825bd8d5a0f2c9bb4befa1667d99639613e1493d8576b4a8a754b26713a5dcc6b7c3a26a05209da38fd
7
- data.tar.gz: ff681b1144717d152726e0a3855459fe4b473812e60075cf77a4971704b6cc57e891b606e8c406c12a76add9355f7cb7c30f8dd96c269de4934c9dba2640090c
6
+ metadata.gz: 7ecfd778f5907098c181d11b40f2bb345dbc1b316119889bb5010e35f0631b7693f1e8d3d1db3377e3e45fa2a99ff67998b97aab61ca6ba5aad24fec96d88b47
7
+ data.tar.gz: 86fd27e82939b99bd358c2abd8cd49410201ddecdf5b91c734a36ce09c079fe7afc682ef9cc90156ec37335f6e09235ac280ee7ce932900e9590640fcdc2910f
data/Guardfile CHANGED
@@ -1,24 +1,5 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
1
  guard :rspec do
5
2
  watch(%r{^spec/.+_spec\.rb$})
6
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
4
  watch('spec/spec_helper.rb') { "spec" }
8
-
9
- # Rails example
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
- watch('config/routes.rb') { "spec/routing" }
15
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
-
17
- # Capybara features specs
18
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
-
20
- # Turnip features and steps
21
- watch(%r{^spec/acceptance/(.+)\.feature$})
22
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
5
  end
24
-
data/README.md CHANGED
@@ -10,7 +10,7 @@ Do your refactoring with [Guard](https://github.com/guard/guard) and [Preek](htt
10
10
  ## Installation
11
11
 
12
12
  $ gem install guard-preek
13
-
13
+
14
14
  or
15
15
 
16
16
  # Add to Gemfile
@@ -21,12 +21,12 @@ or install it yourself
21
21
  $ git clone git@github.com:joenas/guard-preek.git
22
22
  $ cd guard-preek
23
23
  $ rake install
24
-
24
+
25
25
 
26
26
  ## Usage
27
27
 
28
- To generate template:
29
-
28
+ To generate template:
29
+
30
30
  $ guard init preek
31
31
 
32
32
  ### Examples
@@ -40,6 +40,7 @@ end
40
40
 
41
41
  ``` ruby
42
42
  run_all_dir: 'lib' # Enter in guard will run Preek on 'lib'
43
+ report: :verbose # Use Preek::VerboseReport, default is QuietReport
43
44
  ```
44
45
 
45
46
  ## Contributing
data/guard-preek.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "guard", '~> 1.6'
22
- spec.add_dependency "preek", "~> 1.0"
22
+ spec.add_dependency "preek", "~> 1.3.1"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
@@ -3,18 +3,27 @@ require 'preek'
3
3
  module Guard
4
4
  class Preek
5
5
  class Runner
6
- def initialize(files)
6
+ def initialize(files, report_type)
7
7
  @files = Array(files)
8
+ @report_type = report_type
8
9
  end
9
10
 
10
11
  def perform
11
- ::Preek::Smell(@files, excludes)
12
+ ::Preek::Examiner.new(@files, excludes, reporter: reporter).perform
12
13
  end
13
14
 
14
15
  private
15
16
  def excludes
16
17
  %w(IrresponsibleModule)
17
18
  end
19
+
20
+ def reporter
21
+ if @report_type == :verbose
22
+ ::Preek::VerboseReport
23
+ else
24
+ ::Preek::QuietReport
25
+ end
26
+ end
18
27
  end
19
28
  end
20
29
  end
@@ -2,6 +2,6 @@
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
4
  guard :preek, run_all_dir: 'lib' do
5
- watch(/lib\/(.*).rb/)
5
+ watch(/^lib\/(.*).rb/)
6
6
  end
7
7
 
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  class PreekVersion
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
data/lib/guard/preek.rb CHANGED
@@ -7,14 +7,14 @@ module Guard
7
7
  autoload :Runner, 'guard/preek/runner'
8
8
 
9
9
  def run_on_changes(paths)
10
- Runner.new(paths).perform
10
+ Runner.new(paths, options[:report]).perform
11
11
  end
12
12
 
13
13
  def run_all
14
14
  dir = options[:run_all_dir]
15
15
  raise_dir_missing unless dir
16
16
  UI.info %(Running Preek on '#{dir}'. Wait for it...!)
17
- Runner.new(dir).perform
17
+ Runner.new(dir, options[:report]).perform
18
18
  end
19
19
 
20
20
  private
@@ -10,20 +10,48 @@ describe Guard::Preek do
10
10
  Given(:paths){ ["spec/test_files/#{file}.rb"] }
11
11
  When(:output) { capture(:stdout) { guard.run_on_changes(paths) } }
12
12
 
13
- context 'with a smell' do
14
- Given(:file) {'nil_check'}
15
- Then { output.should match(/NilCheck/) }
16
- end
13
+ context 'with no options' do
14
+ context 'with a smell' do
15
+ Given(:file) {'nil_check'}
16
+ Then { output.should match(/NilCheck/) }
17
+ Then { output.should include(paths[0])}
18
+ end
19
+
20
+ context 'with Irresponsible' do
21
+ Given(:file) {'irresponsible'}
22
+ Then { output.should match(/No smells detected/) }
23
+ Then { output.should_not include(paths[0])}
24
+ end
17
25
 
18
- context 'with Irresponsible' do
19
- Given(:file) {'irresponsible'}
20
- Then { output.should match(/No smells detected/) }
26
+ context 'without smell' do
27
+ Given(:file) {'non_smelly'}
28
+ Then { output.should match(/No smells detected/) }
29
+ Then { output.should_not include(paths[0])}
30
+ end
21
31
  end
22
32
 
23
- context 'without smell' do
24
- Given(:file) {'non_smelly'}
25
- Then { output.should match(/No smells detected/) }
33
+ context 'with option "report: :verbose"' do
34
+ Given(:options){ {report: :verbose} }
35
+
36
+ context 'with a smell' do
37
+ Given(:file) {'nil_check'}
38
+ Then { output.should match(/NilCheck/) }
39
+ Then { output.should include(paths[0])}
40
+ end
41
+
42
+ context 'with Irresponsible' do
43
+ Given(:file) {'irresponsible'}
44
+ Then { output.should match(/No smells detected/) }
45
+ Then { output.should include(paths[0])}
46
+ end
47
+
48
+ context 'without smell' do
49
+ Given(:file) {'non_smelly'}
50
+ Then { output.should match(/No smells detected/) }
51
+ Then { output.should include(paths[0])}
52
+ end
26
53
  end
54
+
27
55
  end
28
56
 
29
57
  context '#run_all' do
@@ -4,26 +4,46 @@ describe Guard::Preek do
4
4
 
5
5
  Given(:guard){ Guard::Preek.new([], options) }
6
6
  Given(:options){ Hash.new }
7
+ Given(:paths){ ['some_file.rb'] }
8
+ Given(:runner){ double('runner', perform: true) }
9
+
7
10
 
8
11
  context '#run_on_changes' do
9
- Given(:paths){ ['some_file.rb'] }
10
- Given(:runner){ double('runner', perform: true) }
11
- Given{ Guard::Preek::Runner.should_receive(:new).with(paths).and_return(runner) }
12
- Given{ runner.should_receive(:perform) }
13
12
  When{ guard.run_on_changes(paths) }
14
- Then{ 'its great' }
13
+
14
+ context 'with no options' do
15
+ Given{ Guard::Preek::Runner.should_receive(:new).with(paths, options[:report]).and_return(runner) }
16
+ Given{ runner.should_receive(:perform) }
17
+ Then{ 'its great' }
18
+ end
19
+
20
+ context 'with "report: :verbose" option' do
21
+ Given(:options){ {report: :verbose} }
22
+ Given(:runner){ double('runner', perform: true) }
23
+ Given{ Guard::Preek::Runner.should_receive(:new).with(paths, options[:report]).and_return(runner) }
24
+ Given{ runner.should_receive(:perform) }
25
+ Then{ 'its great' }
26
+ end
15
27
  end
16
28
 
17
29
  context '#run_all' do
18
30
  context 'with "run_all_dir" option' do
19
31
  Given(:options){ {run_all_dir: 'lib'} }
20
32
  Given(:runner){ double('runner', perform: true) }
21
- Given{ Guard::Preek::Runner.should_receive(:new).with(options[:run_all_dir]).and_return(runner) }
33
+ Given{ Guard::Preek::Runner.should_receive(:new).with(options[:run_all_dir], options[:report]).and_return(runner) }
22
34
  Given{ runner.should_receive(:perform) }
23
35
  When{ guard.run_all }
24
36
  Then{ 'also great' }
25
37
  end
26
38
 
39
+ context 'with "report: verbose" option' do
40
+ Given(:options){ {report: :verbose, run_all_dir: 'lib'} }
41
+ Given(:runner){ double('runner', perform: true) }
42
+ Given{ Guard::Preek::Runner.should_receive(:new).with(options[:run_all_dir], options[:report]).and_return(runner) }
43
+ Given{ runner.should_receive(:perform) }
44
+ When{ guard.run_all }
45
+ Then{ 'its great' }
46
+ end
27
47
 
28
48
  context 'with no options' do
29
49
  Then{
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-preek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Neverland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-25 00:00:00.000000000 Z
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: 1.3.1
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
- version: '1.0'
40
+ version: 1.3.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.0.2
188
+ rubygems_version: 2.0.3
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Simple refactoring Guard, pretty prints Reek smells