repo-small-badge 0.2.7 → 0.2.10
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 +5 -4
- data/spec/repo_small_badge_spec.rb +17 -0
- data/spec/spec_helper.rb +5 -5
- data/spec/support/mocks.rb +12 -11
- metadata +12 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a3d10318659a9c6740c02c1c2273106a589dd0c69eb6aaafba3fbd7686fd763
|
4
|
+
data.tar.gz: 8be0b8fdfb997b3932b624b915d68a958667ffbffeb02ef660050f4c22d9619f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a780cbe150f26b7fda43e3ef6cd1eb955df0bf19dde70ec4b718a43244ee34f23b56686079da8d0b890bd5fd29927cc996dd6303615902facf4c854a16f7d012
|
7
|
+
data.tar.gz: 46e3b2ae0f353733ba6b277c6367c35fb51223af562b56e52dee0c87105d00a0c6d4f21de86047eca95df98a7dba4c6a82a64d5c436f8bc6f1ae5f678e372cbc
|
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.2'
|
7
8
|
s.name = 'repo-small-badge'
|
8
9
|
s.version = RepoSmallBadge::VERSION
|
9
10
|
s.platform = Gem::Platform::RUBY
|
@@ -17,13 +18,13 @@ Examples rubycritic and simplecov.)
|
|
17
18
|
|
18
19
|
s.rubyforge_project = 'repo-small-badge'
|
19
20
|
|
20
|
-
s.add_dependency 'victor', '~> 0.
|
21
|
-
s.add_development_dependency 'rake', '~>
|
21
|
+
s.add_dependency 'victor', '~> 0.3.0' # to create the svg
|
22
|
+
s.add_development_dependency 'rake', '~> 13'
|
22
23
|
s.add_development_dependency 'rspec', '~> 3.8'
|
23
|
-
s.add_development_dependency 'rubocop', '~> 0
|
24
|
+
s.add_development_dependency 'rubocop', '~> 1.0'
|
24
25
|
s.add_development_dependency 'rubycritic', '~> 4.1'
|
25
26
|
s.add_development_dependency 'rubycritic-small-badge', '~> 0'
|
26
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
27
|
+
s.add_development_dependency 'simplecov', '~> 0.18'
|
27
28
|
s.add_development_dependency 'simplecov-small-badge', '~> 0.2.2'
|
28
29
|
|
29
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.10
|
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: 0.
|
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: 0.
|
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
|
@@ -58,14 +58,14 @@ dependencies:
|
|
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
|
@@ -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
|
@@ -166,15 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
166
|
requirements:
|
167
167
|
- - ">="
|
168
168
|
- !ruby/object:Gem::Version
|
169
|
-
version: '
|
169
|
+
version: '3.2'
|
170
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
172
|
- - ">="
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
|
-
|
177
|
-
rubygems_version: 2.7.8
|
176
|
+
rubygems_version: 3.4.10
|
178
177
|
signing_key:
|
179
178
|
specification_version: 4
|
180
179
|
summary: Small Badge generator to be used for different tools 4 ruby
|