inch-badge 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/{badge.svg.erb → badge-default.svg.erb} +2 -2
- data/assets/badge-flat.svg.erb +47 -0
- data/bin/inch-badge +6 -1
- data/lib/inch/badge/image/base.rb +4 -1
- data/lib/inch/badge/image/svg.rb +5 -1
- data/lib/inch/badge/image.rb +4 -3
- data/lib/inch/badge/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4caa5a318f4ab464c3dd4b9b9359f32f9ff6a30d
|
4
|
+
data.tar.gz: 98667c4beed28b40a0f18c48490c1d466694669e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b67f82cc5903dc1796989e9b12fa5573a3045517d33ae93ccbdc0772c1894e9d976eb10470e2cc7fa1c4802521f7950d6f35dad9f06c19214bbc444228591f
|
7
|
+
data.tar.gz: 87f34f6c3f7599ad1b70d24213658166aa03918fd3a4512be24123676e0a4cb0c35ad3649a5c6a757cfd7968233d5254b8b8c0fcd793cce0319a33d381fcc281
|
@@ -53,7 +53,7 @@
|
|
53
53
|
|
54
54
|
<rect rx="4" width="80" height="18" fill="url(#bg)"/>
|
55
55
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
56
|
-
<text x="18.5" y="
|
57
|
-
<text x="18.5" y="
|
56
|
+
<text x="18.5" y="14" fill="#010101" fill-opacity=".3">docs</text>
|
57
|
+
<text x="18.5" y="13">docs</text>
|
58
58
|
</g>
|
59
59
|
</svg>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="18">
|
2
|
+
<rect width="80" height="18" fill="#555"/>
|
3
|
+
|
4
|
+
<linearGradient id="gradA" x2="0" y2="100%">
|
5
|
+
<stop offset="0" stop-color="#46b01e" />
|
6
|
+
<stop offset=".1" stop-color="#46b01e" />
|
7
|
+
<stop offset=".5" stop-color="#46b01e" />
|
8
|
+
<stop offset=".9" stop-color="#46b01e" />
|
9
|
+
<stop offset="1" stop-color="#46b01e" />
|
10
|
+
</linearGradient>
|
11
|
+
<linearGradient id="gradB" x2="0" y2="100%">
|
12
|
+
<stop offset="0" stop-color="#87ae10" />
|
13
|
+
<stop offset=".1" stop-color="#87ae10" />
|
14
|
+
<stop offset=".5" stop-color="#87ae10" />
|
15
|
+
<stop offset=".9" stop-color="#87ae10" />
|
16
|
+
<stop offset="1" stop-color="#87ae10" />
|
17
|
+
</linearGradient>
|
18
|
+
<linearGradient id="gradC" x2="0" y2="100%">
|
19
|
+
<stop offset="0" stop-color="#c05946" />
|
20
|
+
<stop offset=".1" stop-color="#c05946" />
|
21
|
+
<stop offset=".5" stop-color="#c05946" />
|
22
|
+
<stop offset=".9" stop-color="#c05946" />
|
23
|
+
<stop offset="1" stop-color="#c05946" />
|
24
|
+
</linearGradient>
|
25
|
+
<linearGradient id="gradU" x2="0" y2="100%">
|
26
|
+
<stop offset="0" stop-color="#7a67a0" />
|
27
|
+
<stop offset=".1" stop-color="#7a67a0" />
|
28
|
+
<stop offset=".5" stop-color="#7a67a0" />
|
29
|
+
<stop offset=".9" stop-color="#7a67a0" />
|
30
|
+
<stop offset="1" stop-color="#7a67a0" />
|
31
|
+
</linearGradient>
|
32
|
+
|
33
|
+
<%
|
34
|
+
bar_x = 37 + 3
|
35
|
+
bar_x2 = 73 + 3
|
36
|
+
x = 0
|
37
|
+
%>
|
38
|
+
<% @grades.each do |grade| %>
|
39
|
+
<rect x="<%= bar_x+x %>" y="0" width="<%= grade.width %>" height="18" fill="url(#grad<%= grade.name %>)"/>
|
40
|
+
<% x += grade.width %>
|
41
|
+
<% end %>
|
42
|
+
|
43
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
44
|
+
<text x="18.5" y="14" fill="#010101" fill-opacity=".3">docs</text>
|
45
|
+
<text x="18.5" y="13">docs</text>
|
46
|
+
</g>
|
47
|
+
</svg>
|
data/bin/inch-badge
CHANGED
@@ -13,10 +13,15 @@ $LOAD_PATH.unshift(find_lib_path)
|
|
13
13
|
|
14
14
|
require 'inch/badge'
|
15
15
|
|
16
|
+
style = 'default'
|
17
|
+
if ARGV.delete('--flat')
|
18
|
+
style = 'flat'
|
19
|
+
end
|
20
|
+
|
16
21
|
if ARGV.size != 5
|
17
22
|
order = Inch::Badge::Config::GRADE_ORDER.join(' ')
|
18
23
|
puts "Usage: inch-badge FILENAME #{order}"
|
19
24
|
exit 1
|
20
25
|
end
|
21
26
|
|
22
|
-
Inch::Badge::Image.create(ARGV.shift, ARGV)
|
27
|
+
Inch::Badge::Image.create(ARGV.shift, ARGV, {:style => style})
|
@@ -2,9 +2,12 @@ module Inch
|
|
2
2
|
module Badge
|
3
3
|
module Image
|
4
4
|
class Base
|
5
|
-
|
5
|
+
attr_reader :style
|
6
|
+
|
7
|
+
def initialize(filename, numbers, style = :default)
|
6
8
|
@filename = filename
|
7
9
|
@numbers = numbers.map(&:to_i)
|
10
|
+
@style = style
|
8
11
|
@overall = @numbers.inject(0, :+)
|
9
12
|
@grades = Config::GRADE_ORDER.map.with_index do |name, index|
|
10
13
|
GradeSection.new(name, Config::GRADE_COLOR[index], @numbers[index], @overall)
|
data/lib/inch/badge/image/svg.rb
CHANGED
@@ -5,7 +5,7 @@ module Inch
|
|
5
5
|
module Image
|
6
6
|
class SVG < Base
|
7
7
|
def save
|
8
|
-
template_content = File.read( Config.image_path(
|
8
|
+
template_content = File.read( Config.image_path(badge_template) )
|
9
9
|
renderer = ERB.new(template_content)
|
10
10
|
output = renderer.result(binding)
|
11
11
|
|
@@ -27,6 +27,10 @@ module Inch
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
+
def badge_template
|
31
|
+
"badge-#{style}.svg.erb"
|
32
|
+
end
|
33
|
+
|
30
34
|
def load_image(filename)
|
31
35
|
@cache ||= {}
|
32
36
|
@cache[filename] ||= ChunkyPNG::Image.from_file(filename)
|
data/lib/inch/badge/image.rb
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
module Inch
|
3
3
|
module Badge
|
4
4
|
module Image
|
5
|
-
def self.create(filename, numbers)
|
5
|
+
def self.create(filename, numbers, options = {})
|
6
|
+
style = options.fetch(:style, 'default')
|
6
7
|
if filename =~ /\.png$/
|
7
|
-
PNG.new(filename, numbers).save
|
8
|
+
PNG.new(filename, numbers, style).save
|
8
9
|
elsif filename =~ /\.svg$/
|
9
|
-
SVG.new(filename, numbers).save
|
10
|
+
SVG.new(filename, numbers, style).save
|
10
11
|
else
|
11
12
|
raise "Unknown data format: #{filename}"
|
12
13
|
end
|
data/lib/inch/badge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inch-badge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Föhring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|
@@ -67,7 +67,8 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
-
- assets/badge.svg.erb
|
70
|
+
- assets/badge-default.svg.erb
|
71
|
+
- assets/badge-flat.svg.erb
|
71
72
|
- assets/bg.png
|
72
73
|
- assets/grade-A-begin.png
|
73
74
|
- assets/grade-A-body.png
|