badge 0.9.0 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0d501aaf87aefbb2c0b0cf15b5b0aa72612a7008
4
- data.tar.gz: 795a37d2fea3c8900806c73eef04a22d4459076d
2
+ SHA256:
3
+ metadata.gz: cde282fe94dedab5bdc9545d4e9b1519268a3cef9b1653b23bd7356c6cd03c89
4
+ data.tar.gz: 86bc387e9bdddf2d7015f13917895db8d12f0608db2e1543b2b69d90fca485e2
5
5
  SHA512:
6
- metadata.gz: 958509781bdf8f9131da9bbd46c5406aaece814c398bb12640664744cb1e92be26e075dc0080aa2fb1e6a7a14b1f000e887fcb7ca4e44118d123ee20e24f41f3
7
- data.tar.gz: b4a3a0c5fb4c358ad9302085883eb676678d4373f167c92b0ee1934f7722fa1ba55eea6bbd7c75a4bffcb82bfdd26e76683632f0faff0afc38e6da7c6b8b96ad
6
+ metadata.gz: 1da1500396eaf05ffb16208af5dc5d48f269f43254cff36f59ec8adfab7ba650866ef4af8ea88d6dad779e707ebd65448b0d259c9b62bf62ef216ab7a16ebd61
7
+ data.tar.gz: 9ebfcdd75567fbddf15a4c72c9e8e6b1e65b13aff0e66bfb3a7274a947ef189cce38f886f4843d4c49e4e2f5f32c37eda3890ce31a64d084e8294ae5d48bff0b
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Daniel Griesser <daniel.griesser.86@gmail.com>
3
+ Copyright (c) 2019 Daniel Griesser <daniel.griesser.86@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -104,7 +104,9 @@ Sometimes the response from shields.io takes a long time and can timeout. You ca
104
104
 
105
105
  `--shield_gravity North` changes the postion of the shield on the icon. Choices include: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast.
106
106
 
107
- In version [0.4.0](https://github.com/HazAT/badge/releases/tag/0.4.0) the default behavior of the shield graphic has been changed. The shield graphic will always be resized to **aspect fill** the icon instead of just adding the shield on the icon. The disable to new behaviour use `--shield_no_resize` which now only puts the shield on the icon again.
107
+ `--shield_parameters "colorA=abcdef&style=flat"` changes the parameters of the shield image. It uses a string of key-value pairs separated by ampersand as specified on shields.io, eg: colorA=abcdef&style=flat.
108
+
109
+ In version [0.4.0](https://github.com/HazAT/badge/releases/tag/0.4.0) the default behavior of the shield graphic has been changed. The shield graphic will always be resized to **aspect fill** the icon instead of just adding the shield on the icon. To disable the new behaviour use `--shield_no_resize` which now only puts the shield on the icon again.
108
110
 
109
111
  Add ```--no_badge``` as an option to hide the beta badge completely if you just want to add a shield.
110
112
 
Binary file
data/lib/badge/base.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Badge
2
2
 
3
- VERSION = "0.9.0"
3
+ VERSION = "0.13.0"
4
4
  DESCRIPTION = "Add a badge overlay to your app icon"
5
5
 
6
6
  def self.root
@@ -28,6 +28,10 @@ module Badge
28
28
  end
29
29
 
30
30
  def self.shield_base_url
31
+ 'https://raster.shields.io'
32
+ end
33
+
34
+ def self.shield_svg_base_url
31
35
  'https://img.shields.io'
32
36
  end
33
37
 
data/lib/badge/options.rb CHANGED
@@ -11,7 +11,7 @@ module Badge
11
11
  optional: true),
12
12
 
13
13
  FastlaneCore::ConfigItem.new(key: :alpha,
14
- description: "Uses the work alpha instead of beta",
14
+ description: "Uses the word alpha instead of beta",
15
15
  is_string: false,
16
16
  optional: true),
17
17
 
@@ -32,7 +32,7 @@ module Badge
32
32
  FastlaneCore::ConfigItem.new(key: :badge_gravity,
33
33
  description: "Position of the badge on icon. Default: SouthEast - Choices include: #{AVAILABLE_GRAVITIES.join(', ')}",
34
34
  verify_block: proc do |value|
35
- UI.user_error!("badge_gravity #{value} is invalid") unless AVAILABLE_GRAVITIES.include?
35
+ UI.user_error!("badge_gravity #{value} is invalid") unless AVAILABLE_GRAVITIES.map(&:upcase).include? value.upcase
36
36
  end,
37
37
  optional: true),
38
38
 
@@ -40,8 +40,12 @@ module Badge
40
40
  description: "Overlay a shield from shields.io on your icon, eg: Version-1.2-green",
41
41
  optional: true),
42
42
 
43
+ FastlaneCore::ConfigItem.new(key: :shield_parameters,
44
+ description: "Parameters of the shield image. String of key-value pairs separated by ampersand as specified on shields.io, eg: colorA=abcdef&style=flat",
45
+ optional: true),
46
+
43
47
  FastlaneCore::ConfigItem.new(key: :shield_io_timeout,
44
- description: "The timeout in seconds we should wait the get a response from shields.io",
48
+ description: "The timeout in seconds we should wait to get a response from shields.io",
45
49
  type: Integer,
46
50
  optional: true),
47
51
 
@@ -50,7 +54,10 @@ module Badge
50
54
  optional: true),
51
55
 
52
56
  FastlaneCore::ConfigItem.new(key: :shield_gravity,
53
- description: "Position of shield on icon. Default: North - Choices include: NorthWest, North, NorthEast, West, Center, East, South, West, South, SouthEast",
57
+ description: "Position of shield on icon. Default: North - Choices include: #{AVAILABLE_GRAVITIES.join(', ')}",
58
+ verify_block: proc do |value|
59
+ UI.user_error!("badge_gravity #{value} is invalid") unless AVAILABLE_GRAVITIES.map(&:upcase).include? value.upcase
60
+ end,
54
61
  optional: true),
55
62
 
56
63
  FastlaneCore::ConfigItem.new(key: :shield_scale,
@@ -58,12 +65,12 @@ module Badge
58
65
  optional: true),
59
66
 
60
67
  FastlaneCore::ConfigItem.new(key: :shield_no_resize,
61
- 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",
68
+ description: "Shield image will no longer be resized to aspect fill the full icon. Instead it will only be shrunk to not exceed the icon graphic",
62
69
  is_string: false,
63
70
  optional: true),
64
71
 
65
72
  FastlaneCore::ConfigItem.new(key: :glob,
66
- description: "Glob pattern for finding image files Default: CURRENT_PATH/**/*.appiconset/*.{png,PNG}",
73
+ description: "Glob pattern for finding image files. Default: CURRENT_PATH/**/*.appiconset/*.{png,PNG}",
67
74
  optional: true),
68
75
 
69
76
  FastlaneCore::ConfigItem.new(key: :grayscale,
data/lib/badge/runner.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fastimage'
2
2
  require 'timeout'
3
3
  require 'mini_magick'
4
- require 'curb'
4
+ require 'open-uri'
5
5
 
6
6
  module Badge
7
7
  class Runner
@@ -35,11 +35,11 @@ module Badge
35
35
  timeout = Badge.shield_io_timeout
36
36
  timeout = options[:shield_io_timeout] if options[:shield_io_timeout]
37
37
  Timeout.timeout(timeout.to_i) do
38
- shield = load_shield(options[:shield]) if options[:shield]
38
+ shield = load_shield(options[:shield], options[:shield_parameters]) if options[:shield]
39
39
  end
40
40
  rescue Timeout::Error
41
41
  UI.error "Error loading image from shields.io timeout reached. Use --verbose for more info".red
42
- rescue Curl::Err::CurlError => error
42
+ rescue OpenURI::HTTPError => error
43
43
  response = error.io
44
44
  UI.error "Error loading image from shields.io response Error. Use --verbose for more info".red
45
45
  UI.verbose response.status if FastlaneCore::Globals.verbose?
@@ -90,12 +90,6 @@ module Badge
90
90
  else
91
91
  UI.message "Did nothing... Enable --verbose for more info.".red
92
92
  end
93
-
94
- if shield
95
- File.delete(shield) if File.exist?(shield)
96
- File.delete("#{shield.path}.png") if File.exist?("#{shield.path}.png")
97
- end
98
-
99
93
  else
100
94
  UI.error "Could not find any app icons...".red
101
95
  end
@@ -109,10 +103,15 @@ module Badge
109
103
 
110
104
  if @@rsvg_enabled
111
105
  new_path = "#{shield.path}.png"
112
- if shield_no_resize
113
- `rsvg-convert #{shield.path} -z #{shield_scale} -o #{new_path}`
114
- else
115
- `rsvg-convert #{shield.path} -w #{(icon.width * shield_scale).to_i} -a -o #{new_path}`
106
+ begin
107
+ if shield_no_resize
108
+ `rsvg-convert #{shield.path} -z #{shield_scale} -o #{new_path}`
109
+ else
110
+ `rsvg-convert #{shield.path} -w #{(icon.width * shield_scale).to_i} -a -o #{new_path}`
111
+ end
112
+ rescue Exception => error
113
+ UI.error "Other error occured. Use --verbose for more info".red
114
+ UI.verbose error if FastlaneCore::Globals.verbose?
116
115
  end
117
116
  new_shield = MiniMagick::Image.open(new_path)
118
117
  else
@@ -127,17 +126,16 @@ module Badge
127
126
  result = composite(result, new_shield, alpha_channel, shield_gravity || "north", shield_geometry)
128
127
  end
129
128
 
130
- def load_shield(shield_string)
131
- url = Badge.shield_base_url + Badge.shield_path + shield_string + (@@rsvg_enabled ? ".svg" : ".png")
132
- file_name = shield_string + (@@rsvg_enabled ? ".svg" : ".png")
129
+ def load_shield(shield_string, shield_parameters)
130
+ url = (@@rsvg_enabled ? Badge.shield_svg_base_url : Badge.shield_base_url) + Badge.shield_path + shield_string + (@@rsvg_enabled ? ".svg" : ".png")
131
+ if shield_parameters
132
+ url = url + "?" + shield_parameters
133
+ end
133
134
 
134
135
  UI.verbose "Trying to load image from shields.io. Timeout: #{Badge.shield_io_timeout}s".blue
135
136
  UI.verbose "URL: #{url}".blue
136
137
 
137
- Curl::Easy.download(url, file_name)
138
- MiniMagick::Image.open(file_name) unless @@rsvg_enabled
139
-
140
- File.open(file_name)
138
+ MiniMagick::Image.open(url)
141
139
  end
142
140
 
143
141
  def check_tools!
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.13.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: 2018-04-04 00:00:00.000000000 Z
11
+ date: 2021-03-31 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'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: fastlane
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -58,15 +44,21 @@ dependencies:
58
44
  requirements:
59
45
  - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: '4.5'
47
+ version: 4.9.4
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 5.0.0
62
51
  type: :runtime
63
52
  prerelease: false
64
53
  version_requirements: !ruby/object:Gem::Requirement
65
54
  requirements:
66
55
  - - ">="
67
56
  - !ruby/object:Gem::Version
68
- version: '4.5'
69
- description: 0.9.0
57
+ version: 4.9.4
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 5.0.0
61
+ description: 0.13.0
70
62
  email:
71
63
  - daniel.griesser.86@gmail.com
72
64
  executables:
@@ -105,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
97
  - !ruby/object:Gem::Version
106
98
  version: '0'
107
99
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 2.5.2
100
+ rubygems_version: 3.0.3
110
101
  signing_key:
111
102
  specification_version: 4
112
103
  summary: Add a badge overlay to your app icon