shadowbq-simplecov-badge 2.0.4 → 2.0.5
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 +4 -4
- data/lib/shadowbq-simplecov-badge/formatter.rb +19 -19
- data/lib/shadowbq-simplecov-badge/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e2d738c47af96bfe2daa3ab4d33b5915a674efc
|
4
|
+
data.tar.gz: fa8f5dd7136382821bf0b03aabb6ad4510e3f5d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89697b99150927de5abb06192bb7f114af3aa9715086e1f06f7e8f1d232e7ca53c4d5144f2f08505c3185820f461455dc45aa3fd0918f9a01c0c602f5540286d
|
7
|
+
data.tar.gz: afcf3e712e671592496be6355e47d24254d711bbff9bc46d238b22eb77d13c37de999a608a082fbf6a48dd61c94da0c3125b0bf18fa57e7e260d92e6c63d787c
|
@@ -1,6 +1,6 @@
|
|
1
1
|
ImageMagickError = Class.new(StandardError)
|
2
|
-
|
3
|
-
class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
2
|
+
|
3
|
+
class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
4
4
|
# Set up config variables.
|
5
5
|
options = {:badge_title => 'TEST COVERAGE', :generate_groups => true, :timestamp => false, :green => '#4fb151',
|
6
6
|
:yellow => '#ded443', :red => '#a23e3f', :number_font => 'Helvetica-Narrow-Bold',
|
@@ -10,7 +10,7 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
10
10
|
:group_name_font => 'Helvetica-Bold', :group_name_font_size => 15,
|
11
11
|
:group_badge_height => 22, :group_strength_foreground => false, :color_code_title => true,
|
12
12
|
:group_color_code_title => true}
|
13
|
-
|
13
|
+
|
14
14
|
# set up class variables and getters/setters
|
15
15
|
options.each do |opt,v|
|
16
16
|
set = "@@#{opt} = v"
|
@@ -20,11 +20,11 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
20
20
|
eval(getter)
|
21
21
|
eval(setter)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def initialize(output = nil)
|
25
25
|
@output = output || STDOUT
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def format(result)
|
29
29
|
begin
|
30
30
|
check_imagemagick
|
@@ -39,13 +39,13 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
|
-
|
42
|
+
|
43
43
|
def generate_header_badge(result)
|
44
44
|
overall_cov = result.source_files.covered_percent.round(0)
|
45
45
|
overall_strength = result.covered_strength.round(0)
|
46
46
|
generator(overall_cov, overall_strength, false)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def generate_group_badges(result)
|
50
50
|
result.groups.each do |name, files|
|
51
51
|
cov = files.covered_percent.round(0)
|
@@ -53,7 +53,7 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
53
53
|
generator(cov, strength, name)
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def generator(cov, strength, group)
|
58
58
|
command = []
|
59
59
|
command[0] = """
|
@@ -115,18 +115,18 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
115
115
|
system("rm #{output_path}/tmp.png")
|
116
116
|
end
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
def generate_timestamp
|
120
120
|
timestamp_cmd = """
|
121
121
|
convert #{output_path}/coverage-badge.png -alpha set -bordercolor none -border 3 \
|
122
122
|
-gravity North -chop 0x3 \
|
123
123
|
-gravity East -chop 3x0 \
|
124
|
-
-gravity West -chop 3x0 \\( -background none -font 'Helvetica' label:'Generated #{Time.now.strftime('%m-%d-%y %H:%M UTC')}' \\) -background none -gravity center -append #{output_path}/coverage-badge.png
|
124
|
+
-gravity West -chop 3x0 \\( -background none -font 'Helvetica' label:'Generated #{Time.now.utc.strftime('%m-%d-%y %H:%M UTC')}' \\) -background none -gravity center -append #{output_path}/coverage-badge.png
|
125
125
|
"""
|
126
126
|
output = `#{timestamp_cmd}`
|
127
127
|
check_status(output)
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
# getter method for config variables - abstracts group or main badge from generator
|
131
131
|
def get_config(name, group)
|
132
132
|
if group
|
@@ -135,22 +135,22 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
135
135
|
eval("@@#{name}")
|
136
136
|
end
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# checks if imagemagick is installed and working
|
140
140
|
def check_imagemagick
|
141
141
|
output = `convert --version`
|
142
142
|
raise ImageMagickError, "ImageMagick doesn't appear to be installed." unless $?.to_i == 0
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
# Checks exit status after running a command with backtick
|
146
146
|
def check_status(output)
|
147
147
|
raise ImageMagickError, "ImageMagick exited with an error. It said:\n #{output}" unless $?.to_i == 0
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
def output_message(result)
|
151
151
|
"Coverage badge generated for #{result.command_name} to #{output_path}."
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
def output_path
|
155
155
|
SimpleCov.coverage_path
|
156
156
|
end
|
@@ -168,7 +168,7 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
168
168
|
@@red
|
169
169
|
end
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
def title_foreground(cov, strength, foreground, use)
|
173
173
|
if !foreground or !use
|
174
174
|
'white'
|
@@ -180,7 +180,7 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
180
180
|
@@red
|
181
181
|
end
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
def strength_background(strength, foreground)
|
185
185
|
if foreground
|
186
186
|
'transparent'
|
@@ -188,7 +188,7 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
188
188
|
strength_color(strength)
|
189
189
|
end
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
192
|
def strength_foreground(strength, foreground)
|
193
193
|
unless foreground
|
194
194
|
'white'
|
@@ -196,7 +196,7 @@ class SimpleCov::Formatter::ShadowbqBadgeFormatter
|
|
196
196
|
strength_color(strength)
|
197
197
|
end
|
198
198
|
end
|
199
|
-
|
199
|
+
|
200
200
|
def coverage_color(covered_percent)
|
201
201
|
if covered_percent > 90
|
202
202
|
@@green
|