cane 2.5.0 → 2.5.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.
data/HISTORY.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Cane History
2
2
 
3
+ ## 2.5.1 - 26 January 2013 (93819f19)
4
+
5
+ * Feature: documentation check supports `.mdown` and `.rdoc` extensions.
6
+ * Feature: expanded threshold regex to support `coverage/.last_run.json` from
7
+ `SimpleCov`.
8
+ * Compat: Ruby 2.0 compatibility.
9
+
3
10
  ## 2.5.0 - 17 November 2012 (628cc1e9)
4
11
 
5
12
  * Feature: `--doc-exclude` option to exclude globs from documentation checks.
data/README.md CHANGED
@@ -112,26 +112,13 @@ recommended).
112
112
 
113
113
  Any value in a file can be used as a threshold:
114
114
 
115
- > echo "89" > coverage/covered_percent
116
- > cane --gte 'coverage/covered_percent,90'
115
+ > echo "89" > coverage/.last_run.json
116
+ > cane --gte 'coverage/.last_run.json,90'
117
117
 
118
118
  Quality threshold crossed
119
119
 
120
120
  coverage/covered_percent is 89, should be >= 90
121
121
 
122
- You can use a `SimpleCov` formatter to create the required file:
123
-
124
- class SimpleCov::Formatter::QualityFormatter
125
- def format(result)
126
- SimpleCov::Formatter::HTMLFormatter.new.format(result)
127
- File.open("coverage/covered_percent", "w") do |f|
128
- f.puts result.source_files.covered_percent.to_f
129
- end
130
- end
131
- end
132
-
133
- SimpleCov.formatter = SimpleCov::Formatter::QualityFormatter
134
-
135
122
  ## Implementing your own checks
136
123
 
137
124
  Checks must implement:
@@ -209,7 +196,7 @@ A good README should include at a minimum:
209
196
  * Status of the project (spike, active development, stable in production).
210
197
  * Compatibility notes (1.8, 1.9, JRuby).
211
198
  * Any interesting technical or architectural decisions made on the project
212
- (this could be as simple as a to an external design document).
199
+ (this could be as simple as a link to an external design document).
213
200
 
214
201
  ## Compatibility
215
202
 
@@ -62,7 +62,7 @@ module Cane
62
62
  return result if opts[:no_readme]
63
63
 
64
64
  filenames = ['README', 'readme']
65
- extensions = ['', '.txt', '.md']
65
+ extensions = ['', '.txt', '.md', '.mdown', '.rdoc']
66
66
  combinations = filenames.product(extensions)
67
67
 
68
68
  if combinations.none? {|n, x| Cane::File.exists?(n + x) }
@@ -7,7 +7,7 @@ module Cane
7
7
  class File
8
8
  class << self
9
9
  def iterator(path)
10
- EncodingAwareIterator.new(open(path).lines)
10
+ EncodingAwareIterator.new(open(path).each_line)
11
11
  end
12
12
 
13
13
  def contents(path)
@@ -47,7 +47,7 @@ module Cane
47
47
 
48
48
  def value_from_file(file)
49
49
  begin
50
- contents = Cane::File.contents(file).chomp.to_f
50
+ contents = Cane::File.contents(file).scan(/\d+\.?\d*/).first.to_f
51
51
  rescue Errno::ENOENT
52
52
  UnavailableValue.new
53
53
  end
@@ -1,3 +1,3 @@
1
1
  module Cane
2
- VERSION = '2.5.0'
2
+ VERSION = '2.5.1'
3
3
  end
@@ -59,10 +59,14 @@ class Doc; end
59
59
  stub_const("Cane::File", file)
60
60
  file.should_receive(:exists?).with("README").and_return(false)
61
61
  file.should_receive(:exists?).with("README.md").and_return(false)
62
+ file.should_receive(:exists?).with("README.mdown").and_return(false)
62
63
  file.should_receive(:exists?).with("README.txt").and_return(false)
64
+ file.should_receive(:exists?).with("README.rdoc").and_return(false)
63
65
  file.should_receive(:exists?).with("readme").and_return(false)
64
66
  file.should_receive(:exists?).with("readme.md").and_return(false)
67
+ file.should_receive(:exists?).with("readme.mdown").and_return(false)
65
68
  file.should_receive(:exists?).with("readme.txt").and_return(false)
69
+ file.should_receive(:exists?).with("readme.rdoc").and_return(false)
66
70
 
67
71
  violations = check("").violations
68
72
  violations.length.should == 1
@@ -4,6 +4,16 @@ require 'cane/threshold_check'
4
4
 
5
5
  describe Cane::ThresholdCheck do
6
6
 
7
+ let(:simplecov_last_run) do
8
+ <<-ENDL
9
+ {
10
+ "result": {
11
+ "covered_percent": 93.88
12
+ }
13
+ }
14
+ ENDL
15
+ end
16
+
7
17
  context "checking violations" do
8
18
 
9
19
  context "when the current coverage cannot be read" do
@@ -45,6 +55,12 @@ describe Cane::ThresholdCheck do
45
55
  limit = subject.normalized_limit("/File.does.not.exist")
46
56
  limit.should be_a Cane::ThresholdCheck::UnavailableValue
47
57
  end
58
+
59
+
60
+ it 'normalizes a json file to a float' do
61
+ subject.normalized_limit(make_file(simplecov_last_run)).should == 93.88
62
+ end
63
+
48
64
  end
49
65
 
50
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-17 00:00:00.000000000 Z
12
+ date: 2013-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parallel
16
- requirement: &2156715960 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156715960
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &2156715440 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '2.0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2156715440
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &2156715000 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2156715000
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: simplecov
49
- requirement: &2156714520 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2156714520
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rspec-fire
60
- requirement: &2156714100 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,7 +85,12 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *2156714100
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  description: Fails your build if code quality thresholds are not met
70
95
  email:
71
96
  - xavier@squareup.com
@@ -129,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
154
  version: '0'
130
155
  requirements: []
131
156
  rubyforge_project:
132
- rubygems_version: 1.8.6
157
+ rubygems_version: 1.8.23
133
158
  signing_key:
134
159
  specification_version: 3
135
160
  summary: Fails your build if code quality thresholds are not met. Provides complexity