Skip to content

Commit

Permalink
Remove parameter, Add checks for shield
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Aug 22, 2017
1 parent f789de8 commit d11b41e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/badge/base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Badge

VERSION = "0.8.4"
VERSION = "0.8.5"
DESCRIPTION = "Add a badge overlay to your app icon"

def self.root
Expand Down
5 changes: 0 additions & 5 deletions lib/badge/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ def self.available_options
type: Integer,
optional: true),

FastlaneCore::ConfigItem.new(key: :shield_io_retry_count,
description: "The number of retries if shield.io error occures. Default: 10",
type: Integer,
optional: true),

FastlaneCore::ConfigItem.new(key: :shield_geometry,
description: "Position of shield on icon, relative to gravity e.g, +50+10%",
optional: true),
Expand Down
23 changes: 12 additions & 11 deletions lib/badge/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ def run(path, options)
UI.verbose error if FastlaneCore::Globals.verbose?
end

retry_limit = options[:shield_io_retry_count] || Badge.shield_io_retries
if @@retry_attemps >= retry_limit
UI.error "Cannot load image from shield.io skipping it...".red
else
UI.message "Waiting for #{timeout.to_i}s and retry to load image from shield.io tries remaining: #{retry_limit - @@retry_attemps}".red
sleep timeout.to_i
@@retry_attemps += 1
return run(path, options)
if options[:shield] && shield == nil
if @@retry_attemps >= Badge.shield_io_retries
UI.error "Cannot load image from shield.io skipping it...".red
else
UI.message "Waiting for #{timeout.to_i}s and retry to load image from shield.io tries remaining: #{Badge.shield_io_retries - @@retry_attemps}".red
sleep timeout.to_i
@@retry_attemps += 1
return run(path, options)
end
end

icon_changed = false
Expand Down Expand Up @@ -125,15 +126,15 @@ def load_shield(shield_string)
UI.verbose "Trying to load image from shield.io. Timeout: #{Badge.shield_io_timeout}s".blue
UI.verbose "URL: #{url}".blue

#Curl::Easy.download(url, file_name)
MiniMagick::Image.open(file_name)
Curl::Easy.download(url, file_name)
MiniMagick::Image.open(file_name) unless @@rsvg_enabled

File.open(file_name)
end

def check_tools!
if !`which rsvg-convert`.include?('rsvg-convert')
UI.important("Install RSVG to get better results for shields ontop of your icon")
UI.important("Install RSVG to get better results for shields on top of your icon")
UI.important("")
UI.important("Install it using (RSVG):")
UI.command("brew install librsvg")
Expand Down

0 comments on commit d11b41e

Please sign in to comment.