repo-small-badge 0.2.6 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/lib/repo_small_badge/configuration.rb +9 -1
- data/lib/repo_small_badge/image.rb +4 -6
- data/lib/repo_small_badge/version.rb +1 -1
- data/repo-small-badge.gemspec +8 -6
- data/spec/repo_small_badge_spec.rb +17 -0
- data/spec/spec_helper.rb +5 -5
- data/spec/support/mocks.rb +12 -11
- metadata +19 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49b692823b94b8bbc9baf0f0f44a2a38888a40795559b3f0528de86ef8963ba
|
4
|
+
data.tar.gz: 53561928b440f2b4f43d4cd431658dfcd300d184c67c6980cf4ac3bbbe68f4c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20eacb2b61b3e58affbbe5a873a93d0b8ca6c543850a7c34d240d4ca15a3e4e28043e5a0245ef371ff1144c9b2a69e5fcde538c421a9216d1302910ec904ad26
|
7
|
+
data.tar.gz: 3aa31e9f4e554f574c6a6a5173d92caeec4337bb84ce2eb1b1d686030526c5c773063f576c38c14f6a2b83e607510f795ddbecece88a0c5823acfea5e6697800
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
3.2.2
|
data/.travis.yml
CHANGED
@@ -72,7 +72,15 @@ module RepoSmallBadge
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def badge_middle
|
75
|
-
badge_width / 2
|
75
|
+
@config.fetch(:badge_middle, badge_width / 2).to_i
|
76
|
+
end
|
77
|
+
|
78
|
+
def title_middle
|
79
|
+
badge_middle / 2
|
80
|
+
end
|
81
|
+
|
82
|
+
def value_middle
|
83
|
+
badge_middle + (badge_width - badge_middle) / 2
|
76
84
|
end
|
77
85
|
|
78
86
|
def filename(suffix = '')
|
@@ -69,16 +69,15 @@ module RepoSmallBadge
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
# rubocop:disable Metrics/AbcSize
|
73
72
|
def svg_title(title)
|
74
73
|
element :g, fill: @config.title_color, 'text-anchor': 'middle',
|
75
74
|
'font-family': @config.title_font,
|
76
75
|
'font-size': @config.title_font_size do |_svg|
|
77
76
|
element :text, @config.title(title),
|
78
|
-
x: @config.
|
77
|
+
x: @config.title_middle, y: @config.badge_height - 5,
|
79
78
|
fill: '#010101', 'fill-opacity': '0.3'
|
80
79
|
element :text, @config.title(title),
|
81
|
-
x: @config.
|
80
|
+
x: @config.title_middle, y: @config.badge_height - 6
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
@@ -88,15 +87,14 @@ module RepoSmallBadge
|
|
88
87
|
'font-family': @config.value_font,
|
89
88
|
'font-size': @config.value_font_size do |_svg|
|
90
89
|
element :text, value,
|
91
|
-
x: @config.
|
90
|
+
x: @config.value_middle,
|
92
91
|
y: @config.badge_height - 5,
|
93
92
|
fill: '#010101', 'fill-opacity': '0.3'
|
94
93
|
element :text, value,
|
95
|
-
x: @config.
|
94
|
+
x: @config.value_middle,
|
96
95
|
y: @config.badge_height - 6
|
97
96
|
end
|
98
97
|
end
|
99
98
|
# rubocop:enable Metrics/MethodLength
|
100
|
-
# rubocop:enable Metrics/AbcSize
|
101
99
|
end
|
102
100
|
end
|
data/repo-small-badge.gemspec
CHANGED
@@ -4,6 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
|
|
4
4
|
require 'repo_small_badge/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
+
s.required_ruby_version = '>=3.0.0'
|
7
8
|
s.name = 'repo-small-badge'
|
8
9
|
s.version = RepoSmallBadge::VERSION
|
9
10
|
s.platform = Gem::Platform::RUBY
|
@@ -12,17 +13,18 @@ Gem::Specification.new do |s|
|
|
12
13
|
s.license = 'MIT'
|
13
14
|
s.homepage = 'https://github.com/marcgrimme/repo-small-badge'
|
14
15
|
s.summary = %(Small Badge generator to be used for different tools 4 ruby)
|
15
|
-
s.description = %(Small Badge generator to be used for different tools 4 ruby
|
16
|
+
s.description = %(Small Badge generator to be used for different tools 4 ruby.
|
17
|
+
Examples rubycritic and simplecov.)
|
16
18
|
|
17
19
|
s.rubyforge_project = 'repo-small-badge'
|
18
20
|
|
19
|
-
s.add_dependency 'victor', '~> 0.
|
20
|
-
s.add_development_dependency 'rake', '~>
|
21
|
+
s.add_dependency 'victor', '~> 0.3.0' # to create the svg
|
22
|
+
s.add_development_dependency 'rake', '~> 13'
|
21
23
|
s.add_development_dependency 'rspec', '~> 3.8'
|
22
|
-
s.add_development_dependency 'rubocop'
|
24
|
+
s.add_development_dependency 'rubocop', '~> 1.0'
|
23
25
|
s.add_development_dependency 'rubycritic', '~> 4.1'
|
24
|
-
s.add_development_dependency 'rubycritic-small-badge'
|
25
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
26
|
+
s.add_development_dependency 'rubycritic-small-badge', '~> 0'
|
27
|
+
s.add_development_dependency 'simplecov', '~> 0.18'
|
26
28
|
s.add_development_dependency 'simplecov-small-badge', '~> 0.2.2'
|
27
29
|
|
28
30
|
s.files = `git ls-files`.split("\n")
|
@@ -41,6 +41,23 @@ describe RepoSmallBadge::Image do
|
|
41
41
|
expect(subject.config_merge(badge_height: 10)[:badge_height]).to eq 10
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
context 'with different middle' do
|
46
|
+
subject do
|
47
|
+
described_class
|
48
|
+
.new(badge_width: 250, badge_middle: 190)
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:svg) { rounded_svg_string(width: 250, middle: 190) }
|
52
|
+
|
53
|
+
it 'will write a file' do
|
54
|
+
allow(File).to receive(:write)
|
55
|
+
.with('./badge_total.svg', svg)
|
56
|
+
.and_return(true)
|
57
|
+
expect(subject.badge('total', 'Total', '100%'))
|
58
|
+
.to be_truthy
|
59
|
+
end
|
60
|
+
end
|
44
61
|
end
|
45
62
|
end
|
46
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
require 'simplecov'
|
4
4
|
require 'byebug'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
class Formatter
|
9
|
-
end
|
6
|
+
module SimpleCovSmallBadge
|
7
|
+
class Formatter
|
10
8
|
end
|
9
|
+
end
|
11
10
|
|
11
|
+
SimpleCov.start do
|
12
12
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
13
13
|
[
|
14
14
|
SimpleCov::Formatter::HTMLFormatter,
|
@@ -25,7 +25,7 @@ require 'simplecov_small_badge'
|
|
25
25
|
require 'rubygems'
|
26
26
|
require 'bundler/setup'
|
27
27
|
|
28
|
-
Dir[File.join('./spec/support/*.rb')].each { |f| require f }
|
28
|
+
Dir[File.join('./spec/support/*.rb')].sort.each { |f| require f }
|
29
29
|
|
30
30
|
RSpec.configure do |config|
|
31
31
|
# some (optional) config here
|
data/spec/support/mocks.rb
CHANGED
@@ -3,37 +3,38 @@
|
|
3
3
|
module TestRepoSmallBadge
|
4
4
|
# rubocop:disable Metrics/MethodLength,Metrics/LineLength,Metrics/ParameterLists
|
5
5
|
def rounded_svg_string(title_color: '#fff', title_font: 'Verdana,sans-serif', title_font_size: 11,
|
6
|
-
value_color: '#fff', value_font: 'Verdana,sans-serif', value_font_size: 11
|
7
|
-
|
6
|
+
value_color: '#fff', value_font: 'Verdana,sans-serif', value_font_size: 11,
|
7
|
+
width: 120, middle: 60)
|
8
|
+
%(<svg contentScriptType="text/ecmascript" contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" version="1.0" height="20" width="#{width}"
|
8
9
|
xmlns="http://www.w3.org/2000/svg"
|
9
10
|
xmlns:xlink="http://www.w3.org/1999/xlink">
|
10
11
|
|
11
12
|
|
12
|
-
<linearGradient id="smooth" x2="0" y2="
|
13
|
+
<linearGradient id="smooth" x2="0" y2="#{width}">
|
13
14
|
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
14
15
|
<stop offset="1" stop-opacity=".1"/>
|
15
16
|
</linearGradient>
|
16
17
|
<clipPath id="round">
|
17
|
-
<rect height="20" width="
|
18
|
+
<rect height="20" width="#{width}" rx="3" fill="#fff"/>
|
18
19
|
</clipPath>
|
19
20
|
<g clip-path="url(#round)">
|
20
|
-
<rect height="20" width="
|
21
|
-
<rect x="
|
22
|
-
<rect height="20" width="
|
21
|
+
<rect height="20" width="#{middle}" fill="#555"/>
|
22
|
+
<rect x="#{middle}" height="20" width="#{middle}" fill="#4c1"/>
|
23
|
+
<rect height="20" width="#{width}" fill="url(#smooth)"/>
|
23
24
|
</g>
|
24
25
|
<g fill="#{title_color}" text-anchor="middle" font-family="#{title_font}" font-size="#{title_font_size}">
|
25
|
-
<text x="
|
26
|
+
<text x="#{middle / 2}" y="15" fill="#010101" fill-opacity="0.3">
|
26
27
|
Total
|
27
28
|
</text>
|
28
|
-
<text x="
|
29
|
+
<text x="#{middle / 2}" y="14">
|
29
30
|
Total
|
30
31
|
</text>
|
31
32
|
</g>
|
32
33
|
<g fill="#{value_color}" text-anchor="middle" font-family="#{value_font}" font-size="#{value_font_size}">
|
33
|
-
<text x="
|
34
|
+
<text x="#{middle + (width - middle) / 2}" y="15" fill="#010101" fill-opacity="0.3">
|
34
35
|
100%
|
35
36
|
</text>
|
36
|
-
<text x="
|
37
|
+
<text x="#{middle + (width - middle) / 2}" y="14">
|
37
38
|
100%
|
38
39
|
</text>
|
39
40
|
</g>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repo-small-badge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Grimme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: victor
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '1.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubycritic
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: rubycritic-small-badge
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0.
|
103
|
+
version: '0.18'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0.
|
110
|
+
version: '0.18'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov-small-badge
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,9 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.2.2
|
125
|
-
description:
|
125
|
+
description: |-
|
126
|
+
Small Badge generator to be used for different tools 4 ruby.
|
127
|
+
Examples rubycritic and simplecov.
|
126
128
|
email:
|
127
129
|
- marc.grimme at gmail dot com
|
128
130
|
executables:
|
@@ -164,15 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
166
|
requirements:
|
165
167
|
- - ">="
|
166
168
|
- !ruby/object:Gem::Version
|
167
|
-
version:
|
169
|
+
version: 3.0.0
|
168
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
171
|
requirements:
|
170
172
|
- - ">="
|
171
173
|
- !ruby/object:Gem::Version
|
172
174
|
version: '0'
|
173
175
|
requirements: []
|
174
|
-
|
175
|
-
rubygems_version: 2.7.8
|
176
|
+
rubygems_version: 3.4.10
|
176
177
|
signing_key:
|
177
178
|
specification_version: 4
|
178
179
|
summary: Small Badge generator to be used for different tools 4 ruby
|