badge 0.7.1 → 0.8.0
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/badge/base.rb +1 -1
- data/lib/badge/options.rb +8 -0
- data/lib/badge/runner.rb +35 -27
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff14105ef1cf3a54cf1bd6e4029aea9cf193da8f
|
4
|
+
data.tar.gz: 5a85c1c81155d8d99c731726e92b5a0e92b02a52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b12697a64cf84ff0167b1bac0451403f6ae52f9721c3e644f82c34edea7920d62e0c9b29fb23c692f2e94d8071c0cd013280e3bc22d9c5a08ec187bec436f02e
|
7
|
+
data.tar.gz: 0dba6d198924d70f24bb0b391c9a91c10c7fc696bf262920d088818d0f335801e5190ecf41dfa109ec7257c57663fbf4e76fb6c3389959ef4d0c06592ff35d6b
|
data/lib/badge/base.rb
CHANGED
data/lib/badge/options.rb
CHANGED
@@ -41,10 +41,18 @@ module Badge
|
|
41
41
|
type: Integer,
|
42
42
|
optional: true),
|
43
43
|
|
44
|
+
FastlaneCore::ConfigItem.new(key: :shield_geometry,
|
45
|
+
description: "Position of shield on icon, relative to gravity e.g, +50+10%",
|
46
|
+
optional: true),
|
47
|
+
|
44
48
|
FastlaneCore::ConfigItem.new(key: :shield_gravity,
|
45
49
|
description: "Position of shield on icon. Default: North - Choices include: NorthWest, North, NorthEast, West, Center, East, South, West, South, SouthEast",
|
46
50
|
optional: true),
|
47
51
|
|
52
|
+
FastlaneCore::ConfigItem.new(key: :shield_scale,
|
53
|
+
description: "Shield image scale factor; e.g, 0.5, 2, etc. - works with --shield_no_resize",
|
54
|
+
optional: true),
|
55
|
+
|
48
56
|
FastlaneCore::ConfigItem.new(key: :shield_no_resize,
|
49
57
|
description: "Shield image will no longer be resized to aspect fill the full icon. Instead it will only be shrinked to not exceed the icon graphic",
|
50
58
|
is_string: false,
|
data/lib/badge/runner.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'fastimage'
|
2
2
|
require 'timeout'
|
3
3
|
require 'mini_magick'
|
4
|
+
require 'curb'
|
4
5
|
|
5
6
|
module Badge
|
6
7
|
class Runner
|
7
8
|
@@retry_count = Badge.shield_io_retries
|
8
9
|
|
9
10
|
def run(path, options)
|
10
|
-
|
11
|
+
check_tools!
|
11
12
|
glob = "/**/*.appiconset/*.{png,PNG}"
|
12
13
|
glob = options[:glob] if options[:glob]
|
13
14
|
|
@@ -33,7 +34,7 @@ module Badge
|
|
33
34
|
end
|
34
35
|
rescue Timeout::Error
|
35
36
|
UI.error "Error loading image from shield.io timeout reached. Skipping Shield. Use --verbose for more info".red
|
36
|
-
rescue
|
37
|
+
rescue Curl::Err::CurlError => error
|
37
38
|
response = error.io
|
38
39
|
UI.error "Error loading image from shield.io response Error. Skipping Shield. Use --verbose for more info".red
|
39
40
|
UI.error response.status if $verbose
|
@@ -55,19 +56,19 @@ module Badge
|
|
55
56
|
icon = MiniMagick::Image.new(full_path)
|
56
57
|
|
57
58
|
result = MiniMagick::Image.new(full_path)
|
58
|
-
|
59
|
+
|
59
60
|
if !options[:no_badge]
|
60
61
|
result = add_badge(options[:custom], options[:dark], icon, options[:alpha], alpha_channel, options[:badge_gravity])
|
61
62
|
icon_changed = true
|
62
63
|
end
|
63
64
|
if shield
|
64
|
-
result = add_shield(icon, result, shield, alpha_channel, options[:shield_gravity], options[:shield_no_resize])
|
65
|
+
result = add_shield(icon, result, shield, alpha_channel, options[:shield_gravity], options[:shield_no_resize], options[:shield_scale], options[:shield_geometry])
|
65
66
|
icon_changed = true
|
66
67
|
end
|
67
|
-
|
68
|
+
|
68
69
|
if icon_changed
|
69
70
|
result.format "png"
|
70
|
-
result.write full_path
|
71
|
+
result.write full_path
|
71
72
|
end
|
72
73
|
end
|
73
74
|
if icon_changed
|
@@ -80,52 +81,58 @@ module Badge
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
83
|
-
def add_shield(icon, result, shield, alpha_channel, shield_gravity, shield_no_resize)
|
84
|
+
def add_shield(icon, result, shield, alpha_channel, shield_gravity, shield_no_resize, shield_scale, shield_geometry)
|
84
85
|
UI.message "'#{icon.path}'"
|
85
86
|
UI.verbose "Adding shield.io image ontop of icon".blue
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
new_path = "#{shield.path}.png"
|
89
|
+
shield_scale = shield_scale ? shield_scale.to_f : 1.0
|
90
|
+
|
91
|
+
if shield_no_resize
|
92
|
+
`rsvg-convert #{shield.path} -z #{shield_scale} -o #{new_path}`
|
91
93
|
else
|
92
|
-
|
94
|
+
`rsvg-convert #{shield.path} -w #{(icon.width * shield_scale).to_i} -a -o #{new_path}`
|
93
95
|
end
|
94
|
-
|
95
|
-
result = composite(result,
|
96
|
+
|
97
|
+
result = composite(result, MiniMagick::Image.open(new_path), alpha_channel, shield_gravity || "north", shield_geometry)
|
96
98
|
end
|
97
99
|
|
98
100
|
def load_shield(shield_string)
|
99
|
-
url = Badge.shield_base_url + Badge.shield_path + shield_string + ".
|
100
|
-
file_name = shield_string + ".
|
101
|
+
url = Badge.shield_base_url + Badge.shield_path + shield_string + ".svg"
|
102
|
+
file_name = shield_string + ".svg"
|
101
103
|
|
102
104
|
UI.verbose "Trying to load image from shield.io. Timeout: #{Badge.shield_io_timeout}s".blue
|
103
105
|
UI.verbose "URL: #{url}".blue
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
file.close
|
109
|
-
end
|
107
|
+
Curl::Easy.download(url, file_name)
|
108
|
+
|
109
|
+
File.open(file_name)
|
110
110
|
end
|
111
|
-
|
112
|
-
def
|
111
|
+
|
112
|
+
def check_tools!
|
113
|
+
if !`which rsvg-convert`.include?('rsvg-convert')
|
114
|
+
UI.error("You have to install RSVG to use `badge`")
|
115
|
+
UI.error("")
|
116
|
+
UI.error("Install it using (RSVG):")
|
117
|
+
UI.command("brew install librsvg")
|
118
|
+
UI.user_error!("Install RSVG and start your lane again!")
|
119
|
+
end
|
113
120
|
return if `which convert`.include?('convert')
|
114
121
|
return if `which gm`.include?('gm')
|
115
122
|
|
116
123
|
UI.error("You have to install ImageMagick or GraphicsMagick to use `badge`")
|
117
124
|
UI.error("")
|
118
125
|
UI.error("Install it using (ImageMagick):")
|
119
|
-
UI.command("brew
|
126
|
+
UI.command("brew install imagemagick")
|
120
127
|
UI.error("")
|
121
128
|
UI.error("Install it using (GraphicsMagick):")
|
122
|
-
UI.command("brew
|
129
|
+
UI.command("brew install graphicsmagick")
|
123
130
|
UI.error("")
|
124
131
|
UI.error("If you don't have homebrew, visit http://brew.sh")
|
125
132
|
|
126
133
|
UI.user_error!("Install ImageMagick and start your lane again!")
|
127
134
|
end
|
128
|
-
|
135
|
+
|
129
136
|
def add_badge(custom_badge, dark_badge, icon, alpha_badge, alpha_channel, badge_gravity)
|
130
137
|
UI.message "'#{icon.path}'"
|
131
138
|
UI.verbose "Adding badge image ontop of icon".blue
|
@@ -143,11 +150,12 @@ module Badge
|
|
143
150
|
result = composite(icon, badge, alpha_channel, badge_gravity || "SouthEast")
|
144
151
|
end
|
145
152
|
|
146
|
-
def composite(image, overlay, alpha_channel, gravity)
|
153
|
+
def composite(image, overlay, alpha_channel, gravity, geometry = nil)
|
147
154
|
image.composite(overlay, 'png') do |c|
|
148
155
|
c.compose "Over"
|
149
156
|
c.alpha 'On' unless !alpha_channel
|
150
157
|
c.gravity gravity
|
158
|
+
c.geometry geometry if geometry
|
151
159
|
end
|
152
160
|
end
|
153
161
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: badge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Griesser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: curb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: fastlane
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +66,7 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '4.5'
|
55
|
-
description: 0.
|
69
|
+
description: 0.8.0
|
56
70
|
email:
|
57
71
|
- daniel.griesser.86@gmail.com
|
58
72
|
executables:
|