rein 0.5.2 → 0.6.0
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/lib/rein.rb +3 -0
- data/lib/rein/version.rb +1 -1
- data/lib/rein/view.rb +13 -0
- data/lib/verify_rcov.rb +56 -0
- metadata +9 -7
data/lib/rein.rb
CHANGED
@@ -12,11 +12,13 @@ require 'rein/constraint/foreign_key'
|
|
12
12
|
require 'rein/constraint/primary_key'
|
13
13
|
require 'rein/constraint/inclusion'
|
14
14
|
require 'rein/constraint/numericality'
|
15
|
+
require 'rein/view'
|
15
16
|
|
16
17
|
module ActiveRecord::ConnectionAdapters
|
17
18
|
class MysqlAdapter < AbstractAdapter
|
18
19
|
include RC::PrimaryKey
|
19
20
|
include RC::ForeignKey
|
21
|
+
include Rein::View
|
20
22
|
end
|
21
23
|
|
22
24
|
class PostgreSQLAdapter < AbstractAdapter
|
@@ -24,5 +26,6 @@ module ActiveRecord::ConnectionAdapters
|
|
24
26
|
include RC::ForeignKey
|
25
27
|
include RC::Inclusion
|
26
28
|
include RC::Numericality
|
29
|
+
include Rein::View
|
27
30
|
end
|
28
31
|
end
|
data/lib/rein/version.rb
CHANGED
data/lib/rein/view.rb
ADDED
data/lib/verify_rcov.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module RCov
|
2
|
+
# A task that can verify that the RCov coverage doesn't
|
3
|
+
# drop below a certain threshold. It should be run after
|
4
|
+
# running Spec::Rake::SpecTask.
|
5
|
+
class VerifyTask < Rake::TaskLib
|
6
|
+
# Name of the task. Defaults to :verify_rcov
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
# Path to the index.html file generated by RCov, which
|
10
|
+
# is the file containing the total coverage.
|
11
|
+
# Defaults to 'coverage/index.html'
|
12
|
+
attr_accessor :index_html
|
13
|
+
|
14
|
+
# Whether or not to output details. Defaults to true.
|
15
|
+
attr_accessor :verbose
|
16
|
+
|
17
|
+
# The threshold value (in percent) for coverage. If the
|
18
|
+
# actual coverage is not equal to this value, the task will raise an
|
19
|
+
# exception.
|
20
|
+
attr_accessor :threshold
|
21
|
+
|
22
|
+
# Require the threshold value be met exactly. This is the default.
|
23
|
+
attr_accessor :require_exact_threshold
|
24
|
+
|
25
|
+
def initialize(name=:verify_rcov)
|
26
|
+
@name = name
|
27
|
+
@index_html = 'coverage/index.html'
|
28
|
+
@verbose = true
|
29
|
+
@require_exact_threshold = true
|
30
|
+
yield self if block_given?
|
31
|
+
raise "Threshold must be set" if @threshold.nil?
|
32
|
+
define
|
33
|
+
end
|
34
|
+
|
35
|
+
def define
|
36
|
+
desc "Verify that rcov coverage is at least #{threshold}%"
|
37
|
+
task @name do
|
38
|
+
total_coverage = 0
|
39
|
+
|
40
|
+
File.open(index_html).each_line do |line|
|
41
|
+
if line =~ /<tt class='coverage_total'>\s*(\d+\.\d+)%\s*<\/tt>/
|
42
|
+
total_coverage = $1.to_f
|
43
|
+
break
|
44
|
+
end
|
45
|
+
end
|
46
|
+
output_coverage(total_coverage)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def output_coverage(total_coverage)
|
51
|
+
puts "Coverage: #{total_coverage}% (threshold: #{threshold}%)" if verbose
|
52
|
+
raise "Coverage must be at least #{threshold}% but was #{total_coverage}%" if total_coverage < threshold
|
53
|
+
raise "Coverage has increased above the threshold of #{threshold}% to #{total_coverage}%. You should update your threshold value." if (total_coverage > threshold) and require_exact_threshold
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Josh Bassett
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-19 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
segments:
|
102
|
-
-
|
103
|
-
-
|
102
|
+
- 2
|
103
|
+
- 0
|
104
104
|
- 0
|
105
|
-
version:
|
105
|
+
version: 2.0.0
|
106
106
|
type: :development
|
107
107
|
version_requirements: *id006
|
108
108
|
- !ruby/object:Gem::Dependency
|
@@ -150,7 +150,9 @@ files:
|
|
150
150
|
- lib/rein/constraint/numericality.rb
|
151
151
|
- lib/rein/constraint/primary_key.rb
|
152
152
|
- lib/rein/version.rb
|
153
|
+
- lib/rein/view.rb
|
153
154
|
- lib/rein.rb
|
155
|
+
- lib/verify_rcov.rb
|
154
156
|
- LICENSE
|
155
157
|
- README.md
|
156
158
|
has_rdoc: true
|