warder 0.3.1 → 0.3.2

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: 6c517f0218b6da1d2e630821743464d8189b8ed3
4
- data.tar.gz: 1fa74a10d1ccb85997aed8eccd0b13497cbc25eb
3
+ metadata.gz: 9a9860813b6cf0f11289b9a7272fac12d7151f39
4
+ data.tar.gz: 8362ff15175f9c7cccaa542daddc7ac38918a503
5
5
  SHA512:
6
- metadata.gz: 09ecec2361551e410eefb61e6f3ef9de3a6d92f05e213830ac630769b6433204519fe7983f54243437b5a51acdfc61f30d470bd28a7bdb8a01c13b6c6510fc5e
7
- data.tar.gz: 06b39ee496ee24ea2fe853de2201ed2ada89f18358db575cc825cfde24e9b8628b4b1106ca858c564fd09f1998e832077e3f9d6e95f5e223aa8a87cbd142a4b8
6
+ metadata.gz: 70fc86147b403485a2e1d01e6629670bdd1b84f59c19d1a27d8f2d4c847a8e25cf7a285f2715f3d5a418d8104e2b49fddca5c55a8c66e15b1b51e15151992b72
7
+ data.tar.gz: 5296b0b893355b53f03cd81f5e9c68bdc42b6c6fcf99e335ff5bbd353642eb6389fc8138245efa072d0ff7870d8490487266f794863a8ff3ec4334903d09521c
@@ -19,5 +19,6 @@ Given(/^I have ((in)?valid_rails_app) project in directory$/) do |name, _|
19
19
  end
20
20
 
21
21
  Given(/^I am on project directory$/) do
22
- @dirs = ["tmp/aruba/#{@projectname}"]
22
+ dir = Aruba::ArubaPath.new("tmp/aruba/#{@projectname}")
23
+ aruba.instance_variable_set('@current_directory', dir)
23
24
  end
@@ -18,10 +18,10 @@ Then(/^warder does nothing$/) do
18
18
  end
19
19
 
20
20
  Then(/^warder detects( no)? (.+) (issues|violations)$/) do |no, what, _|
21
- executing_output = send(:"executing_#{what.gsub(' ', '_')}")
21
+ executing_output = send(:"executing_#{what.tr(' ', '_')}")
22
22
  step "the output should#{' not' if no} contain \"#{executing_output}\""
23
23
 
24
- validation_output = send(:"#{what.gsub(' ', '_')}_output")
24
+ validation_output = send(:"#{what.tr(' ', '_')}_output")
25
25
  validation_output.split("\n").each do |string|
26
26
  step "the output should#{' not' if no} contain \"#{string}\""
27
27
  end
@@ -17,5 +17,7 @@ ENV['PATH'] = "#{bin_path}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
17
17
 
18
18
  require 'warder'
19
19
 
20
- Aruba.process = Aruba::Processes::InProcess
21
- Aruba.process.main_class = Warder::CLI
20
+ Aruba.configure do |config|
21
+ config.command_launcher = :in_process
22
+ config.main_class = Warder::CLI
23
+ end
@@ -11,7 +11,8 @@ require 'warder/rails_advice_runner'
11
11
  require 'warder/sandi_rules_runner'
12
12
  require 'warder/bundle_audit_runner'
13
13
  require 'warder/coffee_lint_runner'
14
- require 'warder/cli/arguments'
14
+ require 'warder/aruba_app'
15
+ require 'warder/arguments'
15
16
  require 'warder/cli'
16
17
 
17
18
  # scope for validators
@@ -0,0 +1,104 @@
1
+ require 'optparse'
2
+
3
+ module Warder
4
+ # responsible for parsing cli arguments
5
+ class Arguments
6
+ def initialize(argv, stdout, kernel)
7
+ @argv = argv
8
+ @stdout = stdout
9
+ @kernel = kernel
10
+ @options = {}
11
+ end
12
+
13
+ def parse
14
+ parse_options
15
+ assign_files
16
+ OpenStruct.new(@options)
17
+ end
18
+
19
+ private
20
+
21
+ def parse_options
22
+ OptionParser.new do |opts|
23
+ quiet(opts)
24
+ stats(opts)
25
+ combined(opts)
26
+ validators(opts)
27
+ end.parse!(@argv)
28
+ end
29
+
30
+ def assign_files
31
+ @options['files'] = @argv.empty? ? '.' : @argv.join(' ')
32
+ end
33
+
34
+ def combined(opts)
35
+ version(opts)
36
+ opts.banner = 'Usage: warder [options] [dir1 file1 file2 ...]'
37
+ all(opts)
38
+ rails(opts)
39
+ end
40
+
41
+ def version(opts)
42
+ opts.on('-v', '--version', 'Show version') do |_|
43
+ @stdout.puts Warder::VERSION
44
+ @kernel.exit 0
45
+ end
46
+ end
47
+
48
+ def quiet(opts)
49
+ opts.on('-q', '--quiet', 'Do not echo validators output.') do
50
+ @options['quiet'] = true
51
+ end
52
+ end
53
+
54
+ def stats(opts)
55
+ opts.on('-t', '--[no-]stats', 'Print statistics.') do |value|
56
+ @options['stats'] = value
57
+ end
58
+ end
59
+
60
+ def all(opts)
61
+ opts.on('-A', '--all', 'Run all validators') do |value|
62
+ all_validators(value)
63
+ end
64
+ end
65
+
66
+ def all_validators(value)
67
+ Warder.validators.each do |validator|
68
+ full_option = validator::CLI_FULL_OPTION
69
+ @options[full_option] = value
70
+ end
71
+ end
72
+
73
+ def rails(opts)
74
+ desc = 'Run rails related validators'
75
+ opts.on('-R', '--[no-]rails', desc) do |value|
76
+ rails_validators(value)
77
+ end
78
+ end
79
+
80
+ def rails_validators(value)
81
+ Warder.validators.each do |validator|
82
+ next unless validator.to_s.match(/\AWarder::Rails/)
83
+ full_option = validator::CLI_FULL_OPTION
84
+ @options[full_option] = value
85
+ end
86
+ end
87
+
88
+ def validators(opts)
89
+ Warder.validators.each do |validator|
90
+ validator(opts, validator)
91
+ end
92
+ end
93
+
94
+ def validator(opts, validator)
95
+ option = validator::CLI_OPTION
96
+ full_option = validator::CLI_FULL_OPTION
97
+ desc = validator::DESCRIPTION
98
+
99
+ opts.on("-#{option}", "--[no-]#{full_option}", desc) do |value|
100
+ @options[full_option] = value
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,20 @@
1
+ module Warder
2
+ # responsible for aruba cli app test integration
3
+ class ArubaApp
4
+ def initialize(argv, stdin = STDIN, stdout = STDOUT,
5
+ stderr = STDERR, kernel = Kernel)
6
+ @stdin = stdin
7
+ @stdout = stdout
8
+ @stderr = stderr
9
+ @kernel = kernel
10
+ argv
11
+ end
12
+
13
+ def execute!
14
+ @kernel.exit execute || 0
15
+ end
16
+
17
+ def execute
18
+ end
19
+ end
20
+ end
@@ -1,38 +1,26 @@
1
1
  module Warder
2
2
  # responsible for cli integration
3
- class CLI
3
+ class CLI < ArubaApp
4
4
  def initialize(argv, stdin = STDIN, stdout = STDOUT,
5
5
  stderr = STDERR, kernel = Kernel)
6
+ super
6
7
  @argv = argv
7
- @stdin = stdin
8
- @stdout = stdout
9
- @stderr = stderr
10
- @kernel = kernel
11
- end
12
-
13
- def execute!
14
- @kernel.exit execute
15
8
  end
16
9
 
17
10
  private
18
11
 
19
12
  def execute
20
- parse_arguments
13
+ options = Arguments.new(@argv, @stdout, @kernel).parse
21
14
  exit_codes = Warder.validators.map do |validator|
22
- perform_validation(validator)
15
+ perform_validation(validator, options)
23
16
  end
24
17
  exit_codes.compact.inject(0, :+)
25
18
  end
26
19
 
27
- def parse_arguments
28
- args = Arguments.new(@argv, @stdout, @kernel)
29
- @options = args.parse
30
- end
31
-
32
- def perform_validation(validator)
20
+ def perform_validation(validator, options)
33
21
  key = validator::CLI_FULL_OPTION
34
- return 0 unless @options.send(key)
35
- runner = validator.new(@stdout, @options)
22
+ return 0 unless options.send(key)
23
+ runner = validator.new(@stdout, options)
36
24
  runner.perform
37
25
  end
38
26
  end
@@ -1,4 +1,4 @@
1
1
  # defines warder version
2
2
  module Warder
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
  end
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
4
  run Rails.application
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '~> 4.2.3'
3
+ gem 'rails', '~> 4.2.5'
4
4
 
5
5
  gem 'sqlite3'
@@ -1,92 +1,94 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- actionmailer (4.2.3)
5
- actionpack (= 4.2.3)
6
- actionview (= 4.2.3)
7
- activejob (= 4.2.3)
4
+ actionmailer (4.2.5)
5
+ actionpack (= 4.2.5)
6
+ actionview (= 4.2.5)
7
+ activejob (= 4.2.5)
8
8
  mail (~> 2.5, >= 2.5.4)
9
9
  rails-dom-testing (~> 1.0, >= 1.0.5)
10
- actionpack (4.2.3)
11
- actionview (= 4.2.3)
12
- activesupport (= 4.2.3)
10
+ actionpack (4.2.5)
11
+ actionview (= 4.2.5)
12
+ activesupport (= 4.2.5)
13
13
  rack (~> 1.6)
14
14
  rack-test (~> 0.6.2)
15
15
  rails-dom-testing (~> 1.0, >= 1.0.5)
16
16
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
- actionview (4.2.3)
18
- activesupport (= 4.2.3)
17
+ actionview (4.2.5)
18
+ activesupport (= 4.2.5)
19
19
  builder (~> 3.1)
20
20
  erubis (~> 2.7.0)
21
21
  rails-dom-testing (~> 1.0, >= 1.0.5)
22
22
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
- activejob (4.2.3)
24
- activesupport (= 4.2.3)
23
+ activejob (4.2.5)
24
+ activesupport (= 4.2.5)
25
25
  globalid (>= 0.3.0)
26
- activemodel (4.2.3)
27
- activesupport (= 4.2.3)
26
+ activemodel (4.2.5)
27
+ activesupport (= 4.2.5)
28
28
  builder (~> 3.1)
29
- activerecord (4.2.3)
30
- activemodel (= 4.2.3)
31
- activesupport (= 4.2.3)
29
+ activerecord (4.2.5)
30
+ activemodel (= 4.2.5)
31
+ activesupport (= 4.2.5)
32
32
  arel (~> 6.0)
33
- activesupport (4.2.3)
33
+ activesupport (4.2.5)
34
34
  i18n (~> 0.7)
35
35
  json (~> 1.7, >= 1.7.7)
36
36
  minitest (~> 5.1)
37
37
  thread_safe (~> 0.3, >= 0.3.4)
38
38
  tzinfo (~> 1.1)
39
- arel (6.0.0)
39
+ arel (6.0.3)
40
40
  builder (3.2.2)
41
+ concurrent-ruby (1.0.0)
41
42
  erubis (2.7.0)
42
- globalid (0.3.5)
43
+ globalid (0.3.6)
43
44
  activesupport (>= 4.1.0)
44
45
  i18n (0.7.0)
45
46
  json (1.8.3)
46
- loofah (2.0.2)
47
+ loofah (2.0.3)
47
48
  nokogiri (>= 1.5.9)
48
49
  mail (2.6.3)
49
50
  mime-types (>= 1.16, < 3)
50
- mime-types (2.6.1)
51
- mini_portile (0.6.2)
52
- minitest (5.7.0)
53
- nokogiri (1.6.6.2)
54
- mini_portile (~> 0.6.0)
51
+ mime-types (2.99)
52
+ mini_portile2 (2.0.0)
53
+ minitest (5.8.3)
54
+ nokogiri (1.6.7)
55
+ mini_portile2 (~> 2.0.0.rc2)
55
56
  rack (1.6.4)
56
57
  rack-test (0.6.3)
57
58
  rack (>= 1.0)
58
- rails (4.2.3)
59
- actionmailer (= 4.2.3)
60
- actionpack (= 4.2.3)
61
- actionview (= 4.2.3)
62
- activejob (= 4.2.3)
63
- activemodel (= 4.2.3)
64
- activerecord (= 4.2.3)
65
- activesupport (= 4.2.3)
59
+ rails (4.2.5)
60
+ actionmailer (= 4.2.5)
61
+ actionpack (= 4.2.5)
62
+ actionview (= 4.2.5)
63
+ activejob (= 4.2.5)
64
+ activemodel (= 4.2.5)
65
+ activerecord (= 4.2.5)
66
+ activesupport (= 4.2.5)
66
67
  bundler (>= 1.3.0, < 2.0)
67
- railties (= 4.2.3)
68
+ railties (= 4.2.5)
68
69
  sprockets-rails
69
70
  rails-deprecated_sanitizer (1.0.3)
70
71
  activesupport (>= 4.2.0.alpha)
71
- rails-dom-testing (1.0.6)
72
+ rails-dom-testing (1.0.7)
72
73
  activesupport (>= 4.2.0.beta, < 5.0)
73
74
  nokogiri (~> 1.6.0)
74
75
  rails-deprecated_sanitizer (>= 1.0.1)
75
76
  rails-html-sanitizer (1.0.2)
76
77
  loofah (~> 2.0)
77
- railties (4.2.3)
78
- actionpack (= 4.2.3)
79
- activesupport (= 4.2.3)
78
+ railties (4.2.5)
79
+ actionpack (= 4.2.5)
80
+ activesupport (= 4.2.5)
80
81
  rake (>= 0.8.7)
81
82
  thor (>= 0.18.1, < 2.0)
82
83
  rake (10.4.2)
83
- sprockets (3.2.0)
84
- rack (~> 1.0)
85
- sprockets-rails (2.3.2)
84
+ sprockets (3.5.2)
85
+ concurrent-ruby (~> 1.0)
86
+ rack (> 1, < 3)
87
+ sprockets-rails (2.3.3)
86
88
  actionpack (>= 3.0)
87
89
  activesupport (>= 3.0)
88
90
  sprockets (>= 2.8, < 4.0)
89
- sqlite3 (1.3.10)
91
+ sqlite3 (1.3.11)
90
92
  thor (0.19.1)
91
93
  thread_safe (0.3.5)
92
94
  tzinfo (1.2.2)
@@ -96,8 +98,8 @@ PLATFORMS
96
98
  ruby
97
99
 
98
100
  DEPENDENCIES
99
- rails (~> 4.2.3)
101
+ rails (~> 4.2.5)
100
102
  sqlite3
101
103
 
102
104
  BUNDLED WITH
103
- 1.10.4
105
+ 1.10.6
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
4
  run Rails.application
@@ -18,21 +18,21 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features|cucumber)\/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'rubocop', '~> 0.32'
22
- spec.add_dependency 'reek', '~> 3.0', '>= 3.0.3'
21
+ spec.add_dependency 'rubocop', '~> 0.35'
22
+ spec.add_dependency 'reek', '~> 3.7'
23
23
  spec.add_dependency 'flay', '~> 2.6', '>= 2.6.1'
24
24
  spec.add_dependency 'flog', '~> 4.3'
25
25
  spec.add_dependency 'mago', '~> 0.1'
26
- spec.add_dependency 'brakeman', '~> 3.0'
26
+ spec.add_dependency 'brakeman', '~> 3.1'
27
27
  spec.add_dependency 'rails_best_practices', '~> 1.15'
28
28
  spec.add_dependency 'sandi_meter', '~> 1.2'
29
- spec.add_dependency 'bundler-audit', '~> 0.3'
30
- spec.add_dependency 'coffeelint', '~> 1.10'
29
+ spec.add_dependency 'bundler-audit', '~> 0.4'
30
+ spec.add_dependency 'coffeelint', '~> 1.14'
31
31
 
32
32
  spec.add_development_dependency 'bundler', '~> 1.3'
33
33
  spec.add_development_dependency 'rake', '~> 10.0'
34
- spec.add_development_dependency 'rspec', '~> 3.3'
35
- spec.add_development_dependency 'cucumber', '~> 2.0'
36
- spec.add_development_dependency 'aruba', '~> 0.7'
37
- spec.add_development_dependency 'simplecov', '~> 0.10'
34
+ spec.add_development_dependency 'rspec', '~> 3.4'
35
+ spec.add_development_dependency 'cucumber', '~> 2.1'
36
+ spec.add_development_dependency 'aruba', '~> 0.11'
37
+ spec.add_development_dependency 'simplecov', '~> 0.11'
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yura Tolstik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-04 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,34 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.32'
19
+ version: '0.35'
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.32'
26
+ version: '0.35'
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: '3.0'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 3.0.3
33
+ version: '3.7'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '3.0'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 3.0.3
40
+ version: '3.7'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: flay
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -98,14 +92,14 @@ dependencies:
98
92
  requirements:
99
93
  - - "~>"
100
94
  - !ruby/object:Gem::Version
101
- version: '3.0'
95
+ version: '3.1'
102
96
  type: :runtime
103
97
  prerelease: false
104
98
  version_requirements: !ruby/object:Gem::Requirement
105
99
  requirements:
106
100
  - - "~>"
107
101
  - !ruby/object:Gem::Version
108
- version: '3.0'
102
+ version: '3.1'
109
103
  - !ruby/object:Gem::Dependency
110
104
  name: rails_best_practices
111
105
  requirement: !ruby/object:Gem::Requirement
@@ -140,28 +134,28 @@ dependencies:
140
134
  requirements:
141
135
  - - "~>"
142
136
  - !ruby/object:Gem::Version
143
- version: '0.3'
137
+ version: '0.4'
144
138
  type: :runtime
145
139
  prerelease: false
146
140
  version_requirements: !ruby/object:Gem::Requirement
147
141
  requirements:
148
142
  - - "~>"
149
143
  - !ruby/object:Gem::Version
150
- version: '0.3'
144
+ version: '0.4'
151
145
  - !ruby/object:Gem::Dependency
152
146
  name: coffeelint
153
147
  requirement: !ruby/object:Gem::Requirement
154
148
  requirements:
155
149
  - - "~>"
156
150
  - !ruby/object:Gem::Version
157
- version: '1.10'
151
+ version: '1.14'
158
152
  type: :runtime
159
153
  prerelease: false
160
154
  version_requirements: !ruby/object:Gem::Requirement
161
155
  requirements:
162
156
  - - "~>"
163
157
  - !ruby/object:Gem::Version
164
- version: '1.10'
158
+ version: '1.14'
165
159
  - !ruby/object:Gem::Dependency
166
160
  name: bundler
167
161
  requirement: !ruby/object:Gem::Requirement
@@ -196,56 +190,56 @@ dependencies:
196
190
  requirements:
197
191
  - - "~>"
198
192
  - !ruby/object:Gem::Version
199
- version: '3.3'
193
+ version: '3.4'
200
194
  type: :development
201
195
  prerelease: false
202
196
  version_requirements: !ruby/object:Gem::Requirement
203
197
  requirements:
204
198
  - - "~>"
205
199
  - !ruby/object:Gem::Version
206
- version: '3.3'
200
+ version: '3.4'
207
201
  - !ruby/object:Gem::Dependency
208
202
  name: cucumber
209
203
  requirement: !ruby/object:Gem::Requirement
210
204
  requirements:
211
205
  - - "~>"
212
206
  - !ruby/object:Gem::Version
213
- version: '2.0'
207
+ version: '2.1'
214
208
  type: :development
215
209
  prerelease: false
216
210
  version_requirements: !ruby/object:Gem::Requirement
217
211
  requirements:
218
212
  - - "~>"
219
213
  - !ruby/object:Gem::Version
220
- version: '2.0'
214
+ version: '2.1'
221
215
  - !ruby/object:Gem::Dependency
222
216
  name: aruba
223
217
  requirement: !ruby/object:Gem::Requirement
224
218
  requirements:
225
219
  - - "~>"
226
220
  - !ruby/object:Gem::Version
227
- version: '0.7'
221
+ version: '0.11'
228
222
  type: :development
229
223
  prerelease: false
230
224
  version_requirements: !ruby/object:Gem::Requirement
231
225
  requirements:
232
226
  - - "~>"
233
227
  - !ruby/object:Gem::Version
234
- version: '0.7'
228
+ version: '0.11'
235
229
  - !ruby/object:Gem::Dependency
236
230
  name: simplecov
237
231
  requirement: !ruby/object:Gem::Requirement
238
232
  requirements:
239
233
  - - "~>"
240
234
  - !ruby/object:Gem::Version
241
- version: '0.10'
235
+ version: '0.11'
242
236
  type: :development
243
237
  prerelease: false
244
238
  version_requirements: !ruby/object:Gem::Requirement
245
239
  requirements:
246
240
  - - "~>"
247
241
  - !ruby/object:Gem::Version
248
- version: '0.10'
242
+ version: '0.11'
249
243
  description: Warder of ruby code
250
244
  email:
251
245
  - yltsrc@gmail.com
@@ -293,9 +287,10 @@ files:
293
287
  - features/validates_coffeescript_style_guide.feature
294
288
  - features/validates_ruby_style_guide.feature
295
289
  - lib/warder.rb
290
+ - lib/warder/arguments.rb
291
+ - lib/warder/aruba_app.rb
296
292
  - lib/warder/bundle_audit_runner.rb
297
293
  - lib/warder/cli.rb
298
- - lib/warder/cli/arguments.rb
299
294
  - lib/warder/code_complexity_runner.rb
300
295
  - lib/warder/code_duplication_runner.rb
301
296
  - lib/warder/code_smell_runner.rb
@@ -388,7 +383,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
388
383
  version: '0'
389
384
  requirements: []
390
385
  rubyforge_project:
391
- rubygems_version: 2.4.8
386
+ rubygems_version: 2.4.5.1
392
387
  signing_key:
393
388
  specification_version: 4
394
389
  summary: Tool to help improve the quality of ruby code
@@ -1,107 +0,0 @@
1
- require 'optparse'
2
-
3
- module Warder
4
- # responsible for hiding arguments from global scope
5
- class CLI
6
- # responsible for parsing cli arguments
7
- class Arguments
8
- def initialize(argv, stdout, kernel)
9
- @argv = argv
10
- @stdout = stdout
11
- @kernel = kernel
12
- @options = {}
13
- end
14
-
15
- def parse
16
- parse_options
17
- assign_files
18
- OpenStruct.new(@options)
19
- end
20
-
21
- private
22
-
23
- def parse_options
24
- OptionParser.new do |opts|
25
- quiet(opts)
26
- stats(opts)
27
- combined(opts)
28
- validators(opts)
29
- end.parse!(@argv)
30
- end
31
-
32
- def assign_files
33
- @options['files'] = @argv.empty? ? '.' : @argv.join(' ')
34
- end
35
-
36
- def combined(opts)
37
- version(opts)
38
- opts.banner = 'Usage: warder [options] [dir1 file1 file2 ...]'
39
- all(opts)
40
- rails(opts)
41
- end
42
-
43
- def version(opts)
44
- opts.on('-v', '--version', 'Show version') do |_|
45
- @stdout.puts Warder::VERSION
46
- @kernel.exit 0
47
- end
48
- end
49
-
50
- def quiet(opts)
51
- opts.on('-q', '--quiet', 'Do not echo validators output.') do
52
- @options['quiet'] = true
53
- end
54
- end
55
-
56
- def stats(opts)
57
- opts.on('-t', '--[no-]stats', 'Print statistics.') do |value|
58
- @options['stats'] = value
59
- end
60
- end
61
-
62
- def all(opts)
63
- opts.on('-A', '--all', 'Run all validators') do |value|
64
- all_validators(value)
65
- end
66
- end
67
-
68
- def all_validators(value)
69
- Warder.validators.each do |validator|
70
- full_option = validator::CLI_FULL_OPTION
71
- @options[full_option] = value
72
- end
73
- end
74
-
75
- def rails(opts)
76
- desc = 'Run rails related validators'
77
- opts.on('-R', '--[no-]rails', desc) do |value|
78
- rails_validators(value)
79
- end
80
- end
81
-
82
- def rails_validators(value)
83
- Warder.validators.each do |validator|
84
- next unless validator.to_s.match(/\AWarder::Rails/)
85
- full_option = validator::CLI_FULL_OPTION
86
- @options[full_option] = value
87
- end
88
- end
89
-
90
- def validators(opts)
91
- Warder.validators.each do |validator|
92
- validator(opts, validator)
93
- end
94
- end
95
-
96
- def validator(opts, validator)
97
- option = validator::CLI_OPTION
98
- full_option = validator::CLI_FULL_OPTION
99
- desc = validator::DESCRIPTION
100
-
101
- opts.on("-#{option}", "--[no-]#{full_option}", desc) do |value|
102
- @options[full_option] = value
103
- end
104
- end
105
- end
106
- end
107
- end