preek 1.2.1 → 1.3.1

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: 6a2898d250cb8cea642a90c538ce337b21b582fb
4
- data.tar.gz: 963cbb7dcebd619e3da7a47fd2fdce46d767a406
3
+ metadata.gz: 0cb49e8b58f821000455e1d1941e25e9af1d7e3b
4
+ data.tar.gz: c253a2d0358384d2f0de5681abafa92d78d22755
5
5
  SHA512:
6
- metadata.gz: 0f33bf0471e6fde2f572c62bd546da8611ef8be0f54ce4e81bcfaac2da2335c9e55ae2f4b4cfea0300a503c89272ec1444ea8c95bb7cad4cedfb610e465bd8c6
7
- data.tar.gz: 3a51ab71c58530be58fd33affcf172ac7b4f8abc781050d73f02da3fb103d04a71a8bf49c9bbae1d20af7faacfd4575d8769ee2e8b42c6f3753fb205c82f0ed4
6
+ metadata.gz: 86e4cda27dac0f8728976b0fedccef6924c68fb15886c8f0f123665e0e76524996a928d363a2655ef8207cd15d1a4d1f65e6ab75df78e43b05302f3470692c16
7
+ data.tar.gz: 8cfa8c70876c56740a529a3abfc778b0c4dc4424c0d5c91133bb1beedd1e97842998f6e6bf8aba82ede6f0e4f0579672237dacb4dec5b17fb1dd477d5db86856
data/README.md CHANGED
@@ -28,7 +28,7 @@ From source
28
28
  ### CLI
29
29
  ```bash
30
30
  Usage:
31
- preek smell FILE(S)|DIR
31
+ preek FILE(S)|DIR
32
32
 
33
33
  Options:
34
34
  -i, [--irresponsible] # Include IrresponsibleModule smell in output.
data/lib/preek/cli.rb CHANGED
@@ -1,19 +1,21 @@
1
1
  require 'thor'
2
2
  require 'preek/version'
3
+ require 'preek/default_command'
3
4
 
4
5
  module Preek
5
6
 
6
7
  # whoop whoop
7
8
  class CLI < Thor
8
9
  include Thor::Actions
10
+ extend DefaultCommand
9
11
 
10
12
  desc 'version', 'Shows version'
11
13
  def version(*)
12
14
  say VERSION
13
15
  end
14
16
 
15
- desc 'smell FILE(S)|DIR', 'Pretty format Reek output'
16
-
17
+ default_command :smell
18
+ desc 'smell FILE(S)|DIR', 'Shorthand: preek [FILES]'
17
19
  method_option :irresponsible,
18
20
  type: :boolean,
19
21
  aliases: '-i',
@@ -30,12 +32,11 @@ module Preek
30
32
  desc: 'Report files with no smells.'
31
33
 
32
34
 
33
- def smell(*args)
34
- Examiner.new(args, excludes, reporter: reporter, output: output).perform
35
+ def smell(*files)
36
+ Examiner.new(files, excludes, reporter: reporter, output: output).perform
35
37
  end
36
38
 
37
39
  private
38
-
39
40
  def reporter
40
41
  options[:verbose] ? VerboseReport : QuietReport
41
42
  end
@@ -0,0 +1,18 @@
1
+ module Preek
2
+ #Lets monkey patch to have a default action with arguments!
3
+ module DefaultCommand
4
+ def dispatch(meth, given_args, given_opts, config)
5
+ meth = retrieve_command_name(given_args)
6
+ command = all_commands[normalize_command_name(meth)]
7
+ unless command
8
+ given_args.unshift meth
9
+ meth = default_command
10
+ command = all_commands[meth]
11
+ end
12
+ if given_args.empty? && command.name == default_command
13
+ handle_argument_error(command, nil, given_args, nil)
14
+ end
15
+ super
16
+ end
17
+ end
18
+ end
data/lib/preek/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Preek
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.1"
3
3
  end
data/preek.gemspec CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.name = "preek"
17
17
  gem.require_paths = ["lib"]
18
18
  gem.version = Preek::VERSION
19
- gem.add_runtime_dependency "thor", ">=0.16"
20
- gem.add_runtime_dependency "reek", ">=1.3"
19
+ gem.add_runtime_dependency "thor", "~> 0.18"
20
+ gem.add_runtime_dependency "reek", "~> 1.3.3"
21
21
  gem.add_development_dependency "rspec", ">=2.13"
22
22
  gem.add_development_dependency "rspec-given"
23
23
  gem.add_development_dependency "guard", ">=1.6"
data/spec/cli_spec.rb CHANGED
@@ -9,22 +9,57 @@ describe Preek::CLI do
9
9
  File.expand_path(File.join(File.dirname(__FILE__),'test_files/',"#{file_name}.rb"))
10
10
  end
11
11
 
12
- describe "#version" do
13
- When(:output) { capture(:stdout) { subject.version} }
14
- Then {output.should =~ /(\d\.?){3}/}
15
- end
12
+ When(:output) { capture(:stdout) { Preek::CLI.start args } }
13
+
14
+ describe 'Commands' do
16
15
 
17
- describe "#smell" do
16
+ context 'errors' do
17
+ When(:output) { capture(:stderr) { Preek::CLI.start args } }
18
18
 
19
- When(:output) { capture(:stdout) { subject.smell(*args) } }
19
+ context 'with no argument' do
20
+ Given(:args){ [] }
21
+ Then{ output.should include("was called with no arguments")}
22
+ end
20
23
 
21
- context "with non-existing file in ARGS" do
22
- Given(:args) { ['i/am/not/a_file'] }
23
- Then{output.should_not include("success")}
24
- Then{output.should include("No such file")}
25
- Then{output.should include(args[0])}
24
+ context 'with "smell" and no argument' do
25
+ Given(:args){ ['smell'] }
26
+ Then{ output.should include("was called with no arguments")}
27
+ end
26
28
  end
27
29
 
30
+ context 'no errors' do
31
+
32
+ context 'with "smell" and a file as argument' do
33
+ Given(:args){ ['smell', test_file('non_smelly')] }
34
+ Then{output.should include("No smells")}
35
+ end
36
+
37
+ context 'with a file as argument' do
38
+ Given(:args){ [test_file('non_smelly')] }
39
+ Then{output.should include("No smells")}
40
+ end
41
+
42
+ context 'with "help" as argument' do
43
+ Given(:args){ ['help'] }
44
+ Then{output.should =~ /Commands:/}
45
+ end
46
+
47
+ context 'with "version"' do
48
+ Given(:args){ ['version'] }
49
+ Then {output.should =~ /(\d\.?){3}/}
50
+ end
51
+
52
+ context "with non-existing file in ARGS" do
53
+ Given(:args) { ['i/am/not/a_file'] }
54
+ Then{output.should_not include("success")}
55
+ Then{output.should include("No such file")}
56
+ Then{output.should include(args[0])}
57
+ end
58
+ end
59
+ end
60
+
61
+ describe "Reports" do
62
+
28
63
  context 'default quiet report' do
29
64
 
30
65
  context "when given file has no smells" do
@@ -77,7 +112,7 @@ describe Preek::CLI do
77
112
  end
78
113
 
79
114
  context 'with --irresponsible option' do
80
- Given{subject.options = {irresponsible: true} }
115
+ When(:output) { capture(:stdout) { Preek::CLI.start ['-i'].concat(args) } }
81
116
 
82
117
  context "when given file has Irresponsible smell" do
83
118
  Given(:args){ [test_file('irresponsible')] }
@@ -104,7 +139,7 @@ describe Preek::CLI do
104
139
  end
105
140
 
106
141
  context 'with --verbose option' do
107
- Given{subject.options = {verbose: true}}
142
+ When(:output) { capture(:stdout) { Preek::CLI.start ['--verbose'].concat(args) } }
108
143
 
109
144
  context "when given file has no smells" do
110
145
  Given(:args){ [test_file('non_smelly')] }
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.1
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-09-06 00:00:00.000000000 Z
11
+ date: 2013-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0.16'
19
+ version: '0.18'
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
- version: '0.16'
26
+ version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: reek
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: 1.3.3
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.3'
40
+ version: 1.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -127,6 +127,7 @@ files:
127
127
  - bin/preek
128
128
  - lib/preek.rb
129
129
  - lib/preek/cli.rb
130
+ - lib/preek/default_command.rb
130
131
  - lib/preek/examiner.rb
131
132
  - lib/preek/ext/smell_warning.rb
132
133
  - lib/preek/output.rb
@@ -164,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
165
  version: '0'
165
166
  requirements: []
166
167
  rubyforge_project:
167
- rubygems_version: 2.0.3
168
+ rubygems_version: 2.0.2
168
169
  signing_key:
169
170
  specification_version: 4
170
171
  summary: It might reek but its pretty