repo-small-badge 0.2.7 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c54175ade1c8e4022c651dc9856248467031d711bdf8a03457e710f60811c20
4
- data.tar.gz: 79a2f63d68b716eb71be17ba74731a1d020247547e922554729db4e6a0bcdc3f
3
+ metadata.gz: d49b692823b94b8bbc9baf0f0f44a2a38888a40795559b3f0528de86ef8963ba
4
+ data.tar.gz: 53561928b440f2b4f43d4cd431658dfcd300d184c67c6980cf4ac3bbbe68f4c5
5
5
  SHA512:
6
- metadata.gz: e8330acc764d2a27b86345c44f190f37d239a606b405bfdb4b60aad4e97ab241d3264867e11be92f170ebc207c264e3cc5ba9cb96072ae37cd9094873fbd369b
7
- data.tar.gz: 0b61f691845732b811b705ec21683fd7bf20c1fdaafdea8e352806a32ae0630ed2fda4c584dfb318d6d9cf1162974b79b4487b9457012a8ea85b62d882e89001
6
+ metadata.gz: 20eacb2b61b3e58affbbe5a873a93d0b8ca6c543850a7c34d240d4ca15a3e4e28043e5a0245ef371ff1144c9b2a69e5fcde538c421a9216d1302910ec904ad26
7
+ data.tar.gz: 3aa31e9f4e554f574c6a6a5173d92caeec4337bb84ce2eb1b1d686030526c5c773063f576c38c14f6a2b83e607510f795ddbecece88a0c5823acfea5e6697800
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.3
1
+ 3.2.2
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ branches:
3
3
  only:
4
4
  - master
5
5
  rvm:
6
- - 2.5.3
6
+ - 3.2.2
7
7
  cache: bundler
8
8
  bundler_args: "--jobs=3 --retry=3 --without production"
9
9
  matrix:
@@ -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.badge_middle / 2, y: @config.badge_height - 5,
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.badge_middle / 2, y: @config.badge_height - 6
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.badge_middle / 2 + @config.badge_middle,
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.badge_middle / 2 + @config.badge_middle,
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RepoSmallBadge
4
- VERSION = '0.2.7'
4
+ VERSION = '0.2.9'
5
5
  end
@@ -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
@@ -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.2.8' # to create the svg
21
- s.add_development_dependency 'rake', '~> 12'
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.65'
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.16'
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
- SimpleCov.start do
7
- module SimpleCovSmallBadge
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
@@ -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
- %(<svg contentScriptType="text/ecmascript" contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" version="1.0" height="20" width="120"
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="120">
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="120" rx="3" fill="#fff"/>
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="60" fill="#555"/>
21
- <rect x="60" height="20" width="60" fill="#4c1"/>
22
- <rect height="20" width="120" fill="url(#smooth)"/>
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="30" y="15" fill="#010101" fill-opacity="0.3">
26
+ <text x="#{middle / 2}" y="15" fill="#010101" fill-opacity="0.3">
26
27
  Total
27
28
  </text>
28
- <text x="30" y="14">
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="90" y="15" fill="#010101" fill-opacity="0.3">
34
+ <text x="#{middle + (width - middle) / 2}" y="15" fill="#010101" fill-opacity="0.3">
34
35
  100%
35
36
  </text>
36
- <text x="90" y="14">
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.7
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: 2019-08-30 00:00:00.000000000 Z
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.2.8
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.2.8
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: '12'
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: '12'
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.65'
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.65'
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.16'
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.16'
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: '0'
169
+ version: 3.0.0
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
- rubyforge_project: repo-small-badge
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