quality 1.3.1 → 2.0.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: 3fd46a1c5027604b62f85dbe5fe6a29f95242188
4
- data.tar.gz: 3f3da1a73252e2c1b28164084dd3f5f3da8abf89
3
+ metadata.gz: 4a6c78a9d29f78396f6a42f055cd86b36d675c1f
4
+ data.tar.gz: c5309355b11fa9fd5670e0608a009d50fd0e0965
5
5
  SHA512:
6
- metadata.gz: e1894369f734937ee0df1adabf61eb3def10bdd59c70e9bb522d16bff23d0c89e61ecb02f7f6456afc23ac6fb7f1743ac87b3a8e0e66aa3bc4f1359ee0b98da0
7
- data.tar.gz: 8751ecd3fe496a94f9de979543b724fd171eab819dc404af2aa3f8382acad3628d96abf3f116a9a7d90085a24e15f8f83ad1158a4da42189e80215e451d65979
6
+ metadata.gz: bfd3d4b9748a3bb76a8de2869e108f1f1a61bf28b69a012c8c6a3b9cb49992b4d291ccc94e8ba6b23e0b8934ed30c115f94dada91840149bcf1af05f85b0adb1
7
+ data.tar.gz: eadd84bae67d01c0feabd53ed45b957efd4751de7496c4ac44b881bfc8462a58d3e66f65468b9b57531955d20ffaff2ab83e9bc8020bee2cce205bf900d09376
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  [![Build Status](https://travis-ci.org/apiology/quality.png)](https://travis-ci.org/apiology/quality)
2
+ [![Coverage Status](https://coveralls.io/repos/apiology/quality/badge.png?branch=master)](https://coveralls.io/r/apiology/quality?branch=master)
3
+
2
4
 
3
5
  # Quality -- code quality ratchet for Ruby
4
6
 
@@ -12,7 +14,20 @@ worse over time.
12
14
  $ gem install quality
13
15
  ```
14
16
 
15
- and add it to your Rakefile like this:
17
+ or in your Gemfile:
18
+
19
+ ```ruby
20
+ group :development do
21
+ gem 'quality'
22
+ end
23
+ ```
24
+ and then:
25
+
26
+ ```bash
27
+ $ bundle install
28
+ ```
29
+
30
+ Once you have the gem, configure your Rakefile like this:
16
31
 
17
32
  ```ruby
18
33
  require 'quality/rake/task'
@@ -52,22 +67,36 @@ Quality::Rake::Task.new { |t|
52
67
 
53
68
  # Array of directory names which contain ruby files to analyze.
54
69
  #
55
- # Defaults to %w{lib test spec feature}, which translates to *.rb in the base directory, as well as lib, test, spec, and feature.
56
- t.ruby_dirs = %w{lib test spec feature}
70
+ # Defaults to %w{app lib test spec feature}, which translates to *.rb in the base directory, as well as those directories.
71
+ t.ruby_dirs = %w{app lib test spec feature}
57
72
 
58
73
  # Relative path to output directory where *_high_water_mark
59
74
  # files will be read/written
60
75
  #
61
- # Defaults to .
62
- t.output_dir = '.'
76
+ # Defaults to 'metrics'
77
+ t.output_dir = 'metrics'
63
78
  }
64
79
  ```
65
80
 
81
+ ## Why
82
+
83
+ See [this post for more information](http://blog.apiology.cc/2014/06/scalable-quality-part-1.html) on the problem the quality gem solves.
84
+
85
+ ## Maturity
86
+
87
+ Quality is rapidly evolving, but uses [semantic versioning](http://semver.org/)--any incompatible changes will come out as major number updates.
88
+
89
+ ## Supported Ruby Versions
90
+
91
+ Tested against Ruby 1.9.3 and 2.1.2. Feel free to submit issues if problems are found elsewhere.
92
+
66
93
  ## Contributing
67
94
 
68
95
  * Fork the repo
69
96
  * Create a feature branch
70
- * Submit a pull request
97
+ * Submit a github pull request
98
+
99
+ Many thanks to all contributors, especially [@andyw8](https://github.com/andyw8), who has contributed some great improvements.
71
100
 
72
101
  ### Dependencies
73
102
 
@@ -82,3 +111,7 @@ Quality makes use of the following other gems, which do the actual checking:
82
111
  ### Learn More
83
112
 
84
113
  * Browse the code or install the latest development version from [https://github.com/apiology/quality/tree](https://github.com/apiology/quality/tree)
114
+
115
+ ## License
116
+
117
+ Licensed under the MIT license.
@@ -0,0 +1,19 @@
1
+ require 'English'
2
+
3
+ module Quality
4
+ # Wrapper around IO.popen that allows exit status to be mocked in tests.
5
+ class ProcessRunner
6
+ def initialize(full_cmd,
7
+ dependencies = {})
8
+ @full_cmd = full_cmd
9
+ @popener = dependencies[:popener] || IO
10
+ end
11
+
12
+ def run
13
+ @popener.popen(@full_cmd) do |file|
14
+ yield file
15
+ end
16
+ $CHILD_STATUS.exitstatus
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  require_relative 'command_output_processor'
2
- require 'English'
2
+ require_relative 'process_runner'
3
3
 
4
4
  module Quality
5
5
  # Runs a quality-checking, command, checks it agaist the existing
@@ -7,7 +7,6 @@ module Quality
7
7
  # if possible, or outputs data if the number of violations increased.
8
8
  class QualityChecker
9
9
  def initialize(cmd, command_options, output_dir, dependencies = {})
10
- @popener = dependencies[:popener] || IO
11
10
  @count_file = dependencies[:count_file] || File
12
11
  @count_io = dependencies[:count_io] || IO
13
12
  @command_output_processor_class =
@@ -15,7 +14,11 @@ module Quality
15
14
  Quality::CommandOutputProcessor
16
15
  @cmd = cmd
17
16
  @command_options = command_options
17
+ @count_dir = dependencies[:count_dir] || Dir
18
+ @count_dir.mkdir(output_dir) unless @count_file.exists?(output_dir)
18
19
  @filename = File.join(output_dir, "#{cmd}_high_water_mark")
20
+ @process_runner_class =
21
+ dependencies[:process_runner_class] || ProcessRunner
19
22
  end
20
23
 
21
24
  def execute(&count_violations_on_line)
@@ -35,11 +38,12 @@ module Quality
35
38
  end
36
39
 
37
40
  def run_command(processor, &count_violations_on_line)
38
- @popener.popen(full_cmd) do |file|
41
+ runner = @process_runner_class.new(full_cmd)
42
+
43
+ runner.run do |file|
39
44
  processor.file = file
40
45
  @command_output = processor.process(&count_violations_on_line)
41
46
  end
42
- $CHILD_STATUS.exitstatus
43
47
  end
44
48
 
45
49
  def check_exit_status(exit_status)
@@ -102,7 +106,7 @@ module Quality
102
106
 
103
107
  def write_violations(new_violations)
104
108
  @count_file.open(@filename, 'w') do |file|
105
- file.write(new_violations.to_s)
109
+ file.write(new_violations.to_s + "\n")
106
110
  end
107
111
  end
108
112
  end
@@ -50,8 +50,8 @@ module Quality
50
50
 
51
51
  # Array of directory names which contain ruby files to analyze.
52
52
  #
53
- # Defaults to %w(lib test spec feature), which translates to *.rb in
54
- # the base directory, as well as lib, test, and feature.
53
+ # Defaults to %w(app lib test spec feature), which translates to *.rb in
54
+ # the base directory, as well as those directories.
55
55
  attr_writer :ruby_dirs
56
56
 
57
57
  # Relative path to output directory where *_high_water_mark
@@ -66,7 +66,7 @@ module Quality
66
66
 
67
67
  @skip_tools = []
68
68
 
69
- @output_dir = '.'
69
+ @output_dir = 'metrics'
70
70
 
71
71
  yield self if block_given?
72
72
 
@@ -143,12 +143,10 @@ module Quality
143
143
  installed = @gem_spec.find_all_by_name(tool).any?
144
144
  suppressed = @skip_tools.include? tool
145
145
 
146
- if !installed
147
- puts "#{tool} not installed"
148
- elsif suppressed
149
- puts "Suppressing use of #{tool}"
150
- else
146
+ if installed && !suppressed
151
147
  method("quality_#{tool}".to_sym).call
148
+ elsif !installed
149
+ puts "#{tool} not installed"
152
150
  end
153
151
  end
154
152
 
@@ -163,12 +161,11 @@ module Quality
163
161
  existing_violations = count_existing_violations(filename)
164
162
  new_violations = [0, existing_violations - 1].max
165
163
  write_violations(filename, new_violations)
166
- tighten_standard(filename) if new_violations != existing_violations
167
164
  end
168
165
 
169
166
  def write_violations(filename, new_violations)
170
167
  @count_file.open(filename, 'w') do |file|
171
- file.write(new_violations.to_s)
168
+ file.write(new_violations.to_s + "\n")
172
169
  end
173
170
  end
174
171
 
@@ -178,11 +175,6 @@ module Quality
178
175
  existing_violations
179
176
  end
180
177
 
181
- def tighten_standard(filename)
182
- @cmd_runner
183
- .system("git commit -m 'tighten quality standard' #{filename}")
184
- end
185
-
186
178
  def ratchet_quality_cmd(cmd,
187
179
  command_options,
188
180
  &count_violations_on_line)
@@ -193,7 +185,7 @@ module Quality
193
185
  end
194
186
 
195
187
  def ruby_dirs
196
- @ruby_dirs ||= %w(lib test spec feature)
188
+ @ruby_dirs ||= %w(app lib test spec feature)
197
189
  end
198
190
 
199
191
  def ruby_files_glob
@@ -2,5 +2,5 @@
2
2
  # reek, flog, flay and rubocop and makes sure your numbers don't get
3
3
  # any worse over time.
4
4
  module Quality
5
- VERSION = '1.3.1'
5
+ VERSION = '2.0.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quality
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cane
@@ -179,6 +179,7 @@ files:
179
179
  - README.md
180
180
  - Rakefile
181
181
  - lib/quality/command_output_processor.rb
182
+ - lib/quality/process_runner.rb
182
183
  - lib/quality/quality_checker.rb
183
184
  - lib/quality/rake/task.rb
184
185
  - lib/quality/tools/cane.rb
@@ -208,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  version: '0'
209
210
  requirements: []
210
211
  rubyforge_project:
211
- rubygems_version: 2.2.2
212
+ rubygems_version: 2.4.3
212
213
  signing_key:
213
214
  specification_version: 4
214
215
  summary: Code quality tools for Ruby