badge 0.8.3 → 0.8.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/badge/base.rb +1 -1
  3. data/lib/badge/runner.rb +23 -11
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 634c171444367823ade8b25dd57d5acc3f1db205
4
- data.tar.gz: d15327718aa5ca6f9fdbb16c467c7d0860b06c15
3
+ metadata.gz: 822c906789564ef26e5abed06f3e8845404e1f68
4
+ data.tar.gz: 7f095560ba04b4dec08b23ab2aeb38cc6794f9d9
5
5
  SHA512:
6
- metadata.gz: 2c99091527da163c04b70464725917f7959b25ee6b0f541f713ea8cd33f1e1a282a21fcc4172dd9ce279ae083fca8247745e9eb2cf46391c9b491b2786e13dfd
7
- data.tar.gz: 2db03ee2d24680fc6a51cb459ec65ce4c153574101bb1612dd49c944e4b2b6a1759b9fbb1814013b516385a576a6a797d2c0f097f1ed805a4454bccb0208b1e4
6
+ metadata.gz: 442d51f3e18a91b18f3943c1f083bbfe940f685e1e1c5afa5638b0e1436408aff766118abf72f3de0058e33187a68ba20df9b536b8d79cae8afe5580ecc2bd9f
7
+ data.tar.gz: 2f1950e78e67c15e030165dce7e16f97511365f445da152e9dafb200fc61e9a976ed7ea50902739a1a396c11a41a6e49f01600cb0a58ee65029781398d2140d1
@@ -1,6 +1,6 @@
1
1
  module Badge
2
2
 
3
- VERSION = "0.8.3"
3
+ VERSION = "0.8.4"
4
4
  DESCRIPTION = "Add a badge overlay to your app icon"
5
5
 
6
6
  def self.root
@@ -6,6 +6,7 @@ require 'curb'
6
6
  module Badge
7
7
  class Runner
8
8
  @@retry_count = Badge.shield_io_retries
9
+ @@rsvg_enabled = true
9
10
 
10
11
  def run(path, options)
11
12
  check_tools!
@@ -91,21 +92,31 @@ module Badge
91
92
  UI.message "'#{icon.path}'"
92
93
  UI.verbose "Adding shield.io image ontop of icon".blue
93
94
 
94
- new_path = "#{shield.path}.png"
95
95
  shield_scale = shield_scale ? shield_scale.to_f : 1.0
96
96
 
97
- if shield_no_resize
98
- `rsvg-convert #{shield.path} -z #{shield_scale} -o #{new_path}`
97
+ if @@rsvg_enabled
98
+ new_path = "#{shield.path}.png"
99
+ if shield_no_resize
100
+ `rsvg-convert #{shield.path} -z #{shield_scale} -o #{new_path}`
101
+ else
102
+ `rsvg-convert #{shield.path} -w #{(icon.width * shield_scale).to_i} -a -o #{new_path}`
103
+ end
104
+ new_shield = MiniMagick::Image.open(new_path)
99
105
  else
100
- `rsvg-convert #{shield.path} -w #{(icon.width * shield_scale).to_i} -a -o #{new_path}`
106
+ new_shield = MiniMagick::Image.open(shield.path)
107
+ if icon.width > new_shield.width && !shield_no_resize
108
+ new_shield.resize "#{(icon.width * shield_scale).to_i}x#{icon.height}<"
109
+ else
110
+ new_shield.resize "#{icon.width}x#{icon.height}>"
111
+ end
101
112
  end
102
113
 
103
- result = composite(result, MiniMagick::Image.open(new_path), alpha_channel, shield_gravity || "north", shield_geometry)
114
+ result = composite(result, new_shield, alpha_channel, shield_gravity || "north", shield_geometry)
104
115
  end
105
116
 
106
117
  def load_shield(shield_string)
107
- url = Badge.shield_base_url + Badge.shield_path + shield_string + ".svg"
108
- file_name = shield_string + ".svg"
118
+ url = Badge.shield_base_url + Badge.shield_path + shield_string + (@@rsvg_enabled ? ".svg" : ".png")
119
+ file_name = shield_string + (@@rsvg_enabled ? ".svg" : ".png")
109
120
 
110
121
  UI.verbose "Trying to load image from shield.io. Timeout: #{Badge.shield_io_timeout}s".blue
111
122
  UI.verbose "URL: #{url}".blue
@@ -117,11 +128,12 @@ module Badge
117
128
 
118
129
  def check_tools!
119
130
  if !`which rsvg-convert`.include?('rsvg-convert')
120
- UI.error("You have to install RSVG to use `badge`")
121
- UI.error("")
122
- UI.error("Install it using (RSVG):")
131
+ UI.important("Install RSVG to get better results for shields ontop of your icon")
132
+ UI.important("")
133
+ UI.important("Install it using (RSVG):")
123
134
  UI.command("brew install librsvg")
124
- UI.user_error!("Install RSVG and start your lane again!")
135
+ UI.important("")
136
+ @@rsvg_enabled = false
125
137
  end
126
138
  return if `which convert`.include?('convert')
127
139
  return if `which gm`.include?('gm')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Griesser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.5'
69
- description: 0.8.3
69
+ description: 0.8.4
70
70
  email:
71
71
  - daniel.griesser.86@gmail.com
72
72
  executables: