badge 0.0.3 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be2e729a2f8de29dad2bd39940c05ef49ff8eb96
4
- data.tar.gz: bb7e287059f560ceaefd4285f03d72244aa43f2e
3
+ metadata.gz: 2e4b80828cf2bcd428d6344d5dc0e4a7a1cb038f
4
+ data.tar.gz: 8a7306236d06b72aac255b34ce0884d45c7351de
5
5
  SHA512:
6
- metadata.gz: ff56db6c86979fc83d12ad8daadb4a4f04cc98b2ab648e2d22bfbe02160d4df54881153b8b8923748b4eb4dafdf58d7ac08d02a452dae7c69be3dad0d5a9948f
7
- data.tar.gz: 75071b83cd40be4d62034a6157236cdd9eb60a7418bab5c7dbe36396af53770fa6d6827242c90682806f298618bafe5d827890f3143021ab4b1c39bf579d1a3c
6
+ metadata.gz: e7d068d9d17eb171a79b4cf44c366a2950eb2d5e518bc8154930f8f5f405e1411661ed54af34d443fc5b7ea855515e47bb34b0987daf61399880ff1994471db0
7
+ data.tar.gz: f24ce3adf0490c1349c2b8136b4dcf8c835a43c295fd556e51c11a60f7fbdd8f6d4fd56d23e2f4e6b8f50062909123a42e1b16e21dd75300c89dbcc52054d97b
data/README.md CHANGED
@@ -14,14 +14,22 @@ 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
- becomes
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
- or with ```--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```
26
+
27
+ ![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
+
29
+ ```badge --shield="Version-0.0.3-blue" --dark```
30
+
31
+ ![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
+
25
33
  # Installation
26
34
 
27
35
  Install the gem
@@ -44,6 +52,12 @@ Here is the dark option:
44
52
  You can also use your custom overlay/badge image
45
53
 
46
54
  badge --custom="path_to/custom_badge.png"
55
+
56
+ Add a shield at the top of your icon for all possibilites head over to: [shields.io](http://shields.io/). You just have to add the string of shield (copied from the URL)
57
+
58
+ badge --shield="Version-0.0.3-blue"
59
+
60
+ Add ```--no_badge``` as an option to hide the beta badge completely if you just want to add a shield.
47
61
 
48
62
  # Usage with fastlane
49
63
 
@@ -52,8 +66,11 @@ lane :appstore do
52
66
  increment_build_number
53
67
  cocoapods
54
68
 
55
- sh "cd ..; badge --dark"
56
-
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
73
+
57
74
  xctool
58
75
  snapshot
59
76
  sigh
data/bin/badge CHANGED
@@ -27,9 +27,11 @@ class BadgeApplication
27
27
  c.description = "adds a beta badge to your app icon"
28
28
  c.option '--dark', 'adds a dark badge instead of the white'
29
29
  c.option '--custom STRING', String, 'overlay a custom image on your icon'
30
+ c.option '--no_badge', 'removes the beta badge'
31
+ c.option '--shield STRING', String, 'overlay a shield from shield.io on your icon, eg: Version-1.2-green'
30
32
 
31
33
  c.action do |args, options|
32
- Badge::Runner.new.run('.', options.dark, options.custom)
34
+ Badge::Runner.new.run('.', options.dark, options.custom, options.no_badge, options.shield)
33
35
  end
34
36
  end
35
37
 
data/lib/badge/base.rb CHANGED
@@ -1,22 +1,30 @@
1
1
  module Badge
2
2
 
3
- VERSION = "0.0.3"
4
- DESCRIPTION = "Add a badge overlay to your app icon"
5
-
6
- def self.root
7
- File.dirname __dir__ + "/../../../"
8
- end
9
-
10
- def self.assets
11
- File.join root, 'assets'
12
- end
13
-
14
- def self.light_badge
15
- File.join assets, 'beta_badge_light.png'
16
- end
17
-
18
- def self.dark_badge
19
- File.join assets, 'beta_badge_dark.png'
20
- end
3
+ VERSION = "0.0.4"
4
+ DESCRIPTION = "Add a badge overlay to your app icon"
5
+
6
+ def self.root
7
+ File.dirname __dir__ + "/../../../"
8
+ end
9
+
10
+ def self.assets
11
+ File.join root, 'assets'
12
+ end
13
+
14
+ def self.light_badge
15
+ File.join assets, 'beta_badge_light.png'
16
+ end
17
+
18
+ def self.dark_badge
19
+ File.join assets, 'beta_badge_dark.png'
20
+ end
21
+
22
+ def self.shield_base_url
23
+ 'https://img.shields.io'
24
+ end
25
+
26
+ def self.shield_path
27
+ '/badge/'
28
+ end
21
29
 
22
30
  end
data/lib/badge/runner.rb CHANGED
@@ -4,27 +4,24 @@ require 'mini_magick'
4
4
  module Badge
5
5
  class Runner
6
6
 
7
- def run(path, dark_badge, custom_badge)
7
+ def run(path, dark_badge, custom_badge, no_badge, shield_string)
8
8
  app_icons = Dir.glob("#{path}/**/*.appiconset/*.{png,PNG}")
9
9
 
10
10
  if app_icons.count > 0
11
11
  Helper.log.info "Start adding badges...".green
12
12
 
13
+ shield = load_shield(shield_string) unless not shield_string
14
+
13
15
  app_icons.each do |full_path|
14
16
  Helper.log.info "'#{full_path}'"
15
17
  icon_path = Pathname.new(full_path)
16
18
  icon = MiniMagick::Image.new(full_path)
17
-
18
- if custom_badge && File.exist?(custom_badge) # check if custom image is provided
19
- badge = MiniMagick::Image.open(custom_badge)
20
- else
21
- badge = MiniMagick::Image.open(dark_badge ? Badge.dark_badge : Badge.light_badge)
22
- end
23
-
24
- badge.resize "#{icon.width}x#{icon.height}"
25
- result = icon.composite(badge) do |c|
26
- c.compose "Over"
27
- end
19
+
20
+ result = MiniMagick::Image.new(full_path)
21
+ result = add_beta_badge(custom_badge, dark_badge, icon) unless no_badge
22
+
23
+ result = add_shield(icon, result, shield) unless not shield_string
24
+
28
25
  result.format "png"
29
26
  result.write full_path
30
27
  end
@@ -34,5 +31,40 @@ module Badge
34
31
  Helper.log.error "Could not find any app icons...".red
35
32
  end
36
33
  end
34
+
35
+ def add_shield(icon, result, shield)
36
+ current_shield = MiniMagick::Image.open(shield.path)
37
+ current_shield.resize "#{icon.width}x#{icon.height}>"
38
+ result = result.composite(current_shield) do |c|
39
+ c.compose "Over"
40
+ c.gravity "north"
41
+ end
42
+ end
43
+
44
+ def load_shield(shield_string)
45
+ url = Badge.shield_base_url + Badge.shield_path + shield_string + ".png"
46
+ file_name = shield_string + ".png"
47
+
48
+ shield = Tempfile.new(file_name).tap do |file|
49
+ file.binmode
50
+ file.write(open(url).read)
51
+ file.close
52
+ end
53
+
54
+ shield
55
+ end
56
+
57
+ def add_beta_badge(custom_badge, dark_badge, icon)
58
+ if custom_badge && File.exist?(custom_badge) # check if custom image is provided
59
+ badge = MiniMagick::Image.open(custom_badge)
60
+ else
61
+ badge = MiniMagick::Image.open(dark_badge ? Badge.dark_badge : Badge.light_badge)
62
+ end
63
+
64
+ badge.resize "#{icon.width}x#{icon.height}"
65
+ result = icon.composite(badge) do |c|
66
+ c.compose "Over"
67
+ end
68
+ end
37
69
  end
38
70
  end
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.3
4
+ version: 0.0.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: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-07 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.3
61
+ description: 0.0.4
62
62
  email:
63
63
  - daniel.griesser.86@gmail.com
64
64
  executables: