badge 0.0.4 → 0.0.5

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
2
  SHA1:
3
- metadata.gz: 2e4b80828cf2bcd428d6344d5dc0e4a7a1cb038f
4
- data.tar.gz: 8a7306236d06b72aac255b34ce0884d45c7351de
3
+ metadata.gz: 5471e4b0fee8baf9b8e99c1e891044e33433f50f
4
+ data.tar.gz: 11de942104fe046d5b25e684ba5eb01770cef749
5
5
  SHA512:
6
- metadata.gz: e7d068d9d17eb171a79b4cf44c366a2950eb2d5e518bc8154930f8f5f405e1411661ed54af34d443fc5b7ea855515e47bb34b0987daf61399880ff1994471db0
7
- data.tar.gz: f24ce3adf0490c1349c2b8136b4dcf8c835a43c295fd556e51c11a60f7fbdd8f6d4fd56d23e2f4e6b8f50062909123a42e1b16e21dd75300c89dbcc52054d97b
6
+ metadata.gz: ef726a36b21c52e2559e78193d19bf9253e7fa1fda9d64cc6428a5d12141044560edfc800bb1121a9cd1ae3e8240a6f9863807a05ecbd050f839671522c0654c
7
+ data.tar.gz: 3688b3a0572c3724fd697391a63a13ac37b27f76372b01622e83110f4b4877d0076f2fd8e3e78830f44e80d740da492f4c841ecefcfbca31ace691a997ea35d4
data/README.md CHANGED
@@ -14,19 +14,23 @@ It's built to easily integrate with [fastlane](https://github.com/fastlane/fastl
14
14
 
15
15
  ![assets/icon175x175.png](assets/icon175x175.png?raw=1) ![assets/icon175x175_fitrack.png](assets/icon175x175_fitrack.png?raw=1)
16
16
 
17
- ```badge```
17
+ badge
18
18
 
19
19
  ![assets/icon175x175_light_badged.png](assets/icon175x175_light_badged.png?raw=1) ![assets/icon175x175_fitrack_light_badged.png](assets/icon175x175_fitrack_light_badged.png?raw=1)
20
20
 
21
- ```badge --dark```
21
+ badge --dark
22
22
 
23
23
  ![assets/icon175x175_dark_badged.png](assets/icon175x175_dark_badged.png?raw=1) ![assets/icon175x175_fitrack_dark_badged.png](assets/icon175x175_fitrack_dark_badged.png?raw=1)
24
24
 
25
- ```badge --shield="1.2-2031-orange" --no_badge```
25
+ badge --alpha
26
+
27
+ ![assets/icon175x175_alpha_light_badged.png](assets/icon175x175_alpha_light_badged.png?raw=1) ![assets/icon175x175_fitrack_alpha_light_badged.png](assets/icon175x175_fitrack_alpha_light_badged.png?raw=1)
28
+
29
+ badge --shield="1.2-2031-orange" --no_badge
26
30
 
27
31
  ![assets/icon175x175_shield_1.2-2031-orange.png](assets/icon175x175_shield_1.2-2031-orange.png?raw=1) ![assets/icon175x175_fitrack_shield_1.2-2031-orange.png](assets/icon175x175_fitrack_shield_1.2-2031-orange.png?raw=1)
28
32
 
29
- ```badge --shield="Version-0.0.3-blue" --dark```
33
+ badge --shield="Version-0.0.3-blue" --dark
30
34
 
31
35
  ![assets/icon175x175_shield_Version-0.0.3-blue.png](assets/icon175x175_shield_Version-0.0.3-blue.png?raw=1) ![assets/icon175x175_fitrack_shield_Version-0.0.3-blue.png](assets/icon175x175_fitrack_shield_Version-0.0.3-blue.png?raw=1)
32
36
 
@@ -45,7 +49,7 @@ Call ```badge``` in your iOS projects root folder
45
49
  It will search all subfolders for your asset catalog app icon set and add the badge to the icon.
46
50
  *Be careful, it actually overwrites the icon files because this gem is meant to be used in and automated build environment.*
47
51
 
48
- Here is the dark option:
52
+ Here is the dark option (also available in combination with ```--alpha```):
49
53
 
50
54
  badge --dark
51
55
 
@@ -65,11 +69,11 @@ Add ```--no_badge``` as an option to hide the beta badge completely if you just
65
69
  lane :appstore do
66
70
  increment_build_number
67
71
  cocoapods
68
-
69
- sh "cd ..; badge --dark --shield="Version-0.0.3-blue""
70
- #badge(dark: true) ... coming soon after pull request is merged
71
- #badge(custom: "/Users/HazA/Desktop/badge.png") ... coming soon after pull request is merged
72
- #badge(shield: "Version-0.0.3-blue", no_badge: true) ... coming soon after pull request is merged
72
+
73
+ badge(dark: true) #or
74
+ #badge(alpha: true) #or
75
+ #badge(custom: "/Users/HazA/Desktop/badge.png") #or
76
+ #badge(shield: "Version-0.0.3-blue", no_badge: true)
73
77
 
74
78
  xctool
75
79
  snapshot
data/bin/badge CHANGED
@@ -18,6 +18,8 @@ class BadgeApplication
18
18
  program :help, 'GitHub', 'https://github.com/HazAT/badge'
19
19
  program :help_formatter, :compact
20
20
 
21
+ global_option('--verbose', 'Shows a more verbose output') { $verbose = true }
22
+
21
23
  always_trace!
22
24
 
23
25
  default_command :existing_project
@@ -26,12 +28,13 @@ class BadgeApplication
26
28
  c.syntax = 'badge'
27
29
  c.description = "adds a beta badge to your app icon"
28
30
  c.option '--dark', 'adds a dark badge instead of the white'
31
+ c.option '--alpha', 'uses the word alpha instead of beta'
29
32
  c.option '--custom STRING', String, 'overlay a custom image on your icon'
30
33
  c.option '--no_badge', 'removes the beta badge'
31
34
  c.option '--shield STRING', String, 'overlay a shield from shield.io on your icon, eg: Version-1.2-green'
32
35
 
33
36
  c.action do |args, options|
34
- Badge::Runner.new.run('.', options.dark, options.custom, options.no_badge, options.shield)
37
+ Badge::Runner.new.run('.', options.dark, options.custom, options.no_badge, options.shield, options.alpha)
35
38
  end
36
39
  end
37
40
 
@@ -1,6 +1,6 @@
1
1
  module Badge
2
2
 
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  DESCRIPTION = "Add a badge overlay to your app icon"
5
5
 
6
6
  def self.root
@@ -11,14 +11,22 @@ module Badge
11
11
  File.join root, 'assets'
12
12
  end
13
13
 
14
- def self.light_badge
14
+ def self.beta_light_badge
15
15
  File.join assets, 'beta_badge_light.png'
16
16
  end
17
17
 
18
- def self.dark_badge
18
+ def self.beta_dark_badge
19
19
  File.join assets, 'beta_badge_dark.png'
20
20
  end
21
21
 
22
+ def self.alpha_light_badge
23
+ File.join assets, 'alpha_badge_light.png'
24
+ end
25
+
26
+ def self.alpha_dark_badge
27
+ File.join assets, 'alpha_badge_dark.png'
28
+ end
29
+
22
30
  def self.shield_base_url
23
31
  'https://img.shields.io'
24
32
  end
@@ -27,4 +35,8 @@ module Badge
27
35
  '/badge/'
28
36
  end
29
37
 
38
+ def self.shield_io_timeout
39
+ 10
40
+ end
41
+
30
42
  end
@@ -1,16 +1,26 @@
1
1
  require 'fastimage'
2
+ require 'timeout'
2
3
  require 'mini_magick'
3
4
 
4
5
  module Badge
5
6
  class Runner
6
7
 
7
- def run(path, dark_badge, custom_badge, no_badge, shield_string)
8
+ def run(path, dark_badge, custom_badge, no_badge, shield_string, alpha_badge)
8
9
  app_icons = Dir.glob("#{path}/**/*.appiconset/*.{png,PNG}")
9
10
 
11
+ Helper.log.info "Verbose active...".blue unless not $verbose
12
+
10
13
  if app_icons.count > 0
11
14
  Helper.log.info "Start adding badges...".green
12
15
 
13
- shield = load_shield(shield_string) unless not shield_string
16
+ shield = nil
17
+ begin
18
+ Timeout.timeout(Badge.shield_io_timeout) do
19
+ shield = load_shield(shield_string) unless not shield_string
20
+ end
21
+ rescue Timeout::Error
22
+ Helper.log.error "Error loading image from shield.io timeout reached. Skipping Shield. Use --verbose for more info".red
23
+ end
14
24
 
15
25
  app_icons.each do |full_path|
16
26
  Helper.log.info "'#{full_path}'"
@@ -18,9 +28,9 @@ module Badge
18
28
  icon = MiniMagick::Image.new(full_path)
19
29
 
20
30
  result = MiniMagick::Image.new(full_path)
21
- result = add_beta_badge(custom_badge, dark_badge, icon) unless no_badge
31
+ result = add_badge(custom_badge, dark_badge, icon, alpha_badge) unless no_badge
22
32
 
23
- result = add_shield(icon, result, shield) unless not shield_string
33
+ result = add_shield(icon, result, shield) unless not shield
24
34
 
25
35
  result.format "png"
26
36
  result.write full_path
@@ -33,6 +43,8 @@ module Badge
33
43
  end
34
44
 
35
45
  def add_shield(icon, result, shield)
46
+ Helper.log.info "Adding shield.io image ontop of icon".blue unless not $verbose
47
+
36
48
  current_shield = MiniMagick::Image.open(shield.path)
37
49
  current_shield.resize "#{icon.width}x#{icon.height}>"
38
50
  result = result.composite(current_shield) do |c|
@@ -45,20 +57,26 @@ module Badge
45
57
  url = Badge.shield_base_url + Badge.shield_path + shield_string + ".png"
46
58
  file_name = shield_string + ".png"
47
59
 
60
+ Helper.log.info "Trying to load image from shield.io. Timeout: ".blue unless not $verbose
61
+ Helper.log.info "URL: #{url}".blue unless not $verbose
62
+
48
63
  shield = Tempfile.new(file_name).tap do |file|
49
64
  file.binmode
50
65
  file.write(open(url).read)
51
66
  file.close
52
67
  end
53
-
54
- shield
55
68
  end
56
69
 
57
- def add_beta_badge(custom_badge, dark_badge, icon)
70
+ def add_badge(custom_badge, dark_badge, icon, alpha_badge)
71
+ Helper.log.info "Adding beta badge image ontop of icon".blue unless not $verbose
58
72
  if custom_badge && File.exist?(custom_badge) # check if custom image is provided
59
73
  badge = MiniMagick::Image.open(custom_badge)
60
74
  else
61
- badge = MiniMagick::Image.open(dark_badge ? Badge.dark_badge : Badge.light_badge)
75
+ if alpha_badge
76
+ badge = MiniMagick::Image.open(dark_badge ? Badge.alpha_dark_badge : Badge.alpha_light_badge)
77
+ else
78
+ badge = MiniMagick::Image.open(dark_badge ? Badge.beta_dark_badge : Badge.beta_light_badge)
79
+ end
62
80
  end
63
81
 
64
82
  badge.resize "#{icon.width}x#{icon.height}"
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.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Griesser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-07 00:00:00.000000000 Z
11
+ date: 2016-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane_core
@@ -58,7 +58,7 @@ dependencies:
58
58
  - - ~>
59
59
  - !ruby/object:Gem::Version
60
60
  version: 4.0.2
61
- description: 0.0.4
61
+ description: 0.0.5
62
62
  email:
63
63
  - daniel.griesser.86@gmail.com
64
64
  executables:
@@ -74,6 +74,8 @@ files:
74
74
  - LICENSE
75
75
  - assets/beta_badge_dark.png
76
76
  - assets/beta_badge_light.png
77
+ - assets/alpha_badge_dark.png
78
+ - assets/alpha_badge_light.png
77
79
  homepage: https://github.com/HazAT/badge
78
80
  licenses:
79
81
  - MIT