badge 0.1.1 → 0.2.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
2
  SHA1:
3
- metadata.gz: d15b282affc1dc423cd7567106fe3c1cabc5de5e
4
- data.tar.gz: e16c8f1de2c2148d24c75fea145bdf2f00f90a3c
3
+ metadata.gz: 7c6ec35356aef97660149f9ca8d347281f49d1f1
4
+ data.tar.gz: 640f410e232eff57730c0ee0601e2d20d6d43886
5
5
  SHA512:
6
- metadata.gz: b427dd466567806f44131ca096e4e2874a1aa348cd172df412f1131c9074bab2b887677cf23bb8412580ed260d601034b74edcc4cbf0a9438d4d282ed242fb76
7
- data.tar.gz: e2ad830e5271496f8da62f1ec29635bf2c4aeba3d4bc3c69e3f16e9d420462fedb577f839ee5f2b4d24b627bc2c8cd903feb67ed7b94d20fa73d9cf80b6139cd
6
+ metadata.gz: 3ef3497ec0dbe826ac158b8c3defe52161ed54d4313927aa7f6996d95f4372c8a3883cf5074b4f9bed87e9a3c7b00a11d9f6afc44ff39180c861a3efc9062897
7
+ data.tar.gz: c71234d740996950a01650f0c984bf019dac0f92359bd18e90320895bf1e905714b307e231307a006d56cd8f5f715aa51317a34c941689fd2da4adfd121b7afb
data/bin/badge CHANGED
@@ -32,6 +32,8 @@ class BadgeApplication
32
32
  c.option '--custom STRING', String, 'Overlay a custom image on your icon'
33
33
  c.option '--no_badge', 'Removes the beta badge'
34
34
  c.option '--shield STRING', String, 'Overlay a shield from shield.io on your icon, eg: Version-1.2-green'
35
+ c.option '--shield_io_timeout INTEGER', Integer, 'The timeout in seconds we should wait the get a response from shield.io'
36
+ c.option '--glob STRING', String, 'Glob pattern for finding image files Default: CURRENT_PATH/**/*.appiconset/*.{png,PNG}'
35
37
 
36
38
  c.action do |args, options|
37
39
  params = {}
@@ -39,7 +41,9 @@ class BadgeApplication
39
41
  params[:custom] = options.custom
40
42
  params[:no_badge] = options.no_badge
41
43
  params[:shield] = options.shield
44
+ params[:shield_io_timeout] = options.shield_io_timeout
42
45
  params[:alpha] = options.alpha
46
+ params[:glob] = options.glob
43
47
  Badge::Runner.new.run('.', params)
44
48
  end
45
49
  end
@@ -1,6 +1,6 @@
1
1
  module Badge
2
2
 
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  DESCRIPTION = "Add a badge overlay to your ios app icon"
5
5
 
6
6
  def self.root
@@ -6,7 +6,10 @@ module Badge
6
6
  class Runner
7
7
 
8
8
  def run(path, options)
9
- app_icons = Dir.glob("#{path}/**/*.appiconset/*.{png,PNG}")
9
+ glob = "/**/*.appiconset/*.{png,PNG}"
10
+ glob = options[:glob] unless not options[:glob]
11
+
12
+ app_icons = Dir.glob("#{path}#{glob}")
10
13
  Helper.log.info "Verbose active...".blue unless not $verbose
11
14
  Helper.log.info "Parameters: #{options.inspect}".blue unless not $verbose
12
15
 
@@ -15,34 +18,48 @@ module Badge
15
18
 
16
19
  shield = nil
17
20
  begin
18
- Timeout.timeout(Badge.shield_io_timeout) do
21
+ timeout = Badge.shield_io_timeout
22
+ timeout = options[:shield_io_timeout] unless not options[:shield_io_timeout]
23
+ Timeout.timeout(timeout.to_i) do
19
24
  shield = load_shield(options[:shield]) unless not options[:shield]
20
25
  end
21
26
  rescue Timeout::Error
22
27
  Helper.log.error "Error loading image from shield.io timeout reached. Skipping Shield. Use --verbose for more info".red
23
28
  end
24
29
 
30
+ icon_changed = false
25
31
  app_icons.each do |full_path|
26
- Helper.log.info "'#{full_path}'"
27
32
  icon_path = Pathname.new(full_path)
28
33
  icon = MiniMagick::Image.new(full_path)
29
34
 
30
35
  result = MiniMagick::Image.new(full_path)
31
- result = add_badge(options[:custom], options[:dark], icon, options[:alpha]) unless options[:no_badge]
32
-
33
- result = add_shield(icon, result, shield) unless not shield
34
-
35
- result.format "png"
36
- result.write full_path
36
+
37
+ if !options[:no_badge]
38
+ result = add_badge(options[:custom], options[:dark], icon, options[:alpha])
39
+ icon_changed = true
40
+ end
41
+ if shield
42
+ result = add_shield(icon, result, shield)
43
+ icon_changed = true
44
+ end
45
+
46
+ if icon_changed
47
+ result.format "png"
48
+ result.write full_path
49
+ end
50
+ end
51
+ if icon_changed
52
+ Helper.log.info "Badged \\o/!".green
53
+ else
54
+ Helper.log.info "Did nothing... Enable --verbose for more info.".red
37
55
  end
38
-
39
- Helper.log.info "Badged \\o/!".green
40
56
  else
41
57
  Helper.log.error "Could not find any app icons...".red
42
58
  end
43
59
  end
44
60
 
45
61
  def add_shield(icon, result, shield)
62
+ Helper.log.info "'#{icon.path}'"
46
63
  Helper.log.info "Adding shield.io image ontop of icon".blue unless not $verbose
47
64
 
48
65
  current_shield = MiniMagick::Image.open(shield.path)
@@ -68,6 +85,7 @@ module Badge
68
85
  end
69
86
 
70
87
  def add_badge(custom_badge, dark_badge, icon, alpha_badge)
88
+ Helper.log.info "'#{icon.path}'"
71
89
  Helper.log.info "Adding badge image ontop of icon".blue unless not $verbose
72
90
  if custom_badge && File.exist?(custom_badge) # check if custom image is provided
73
91
  badge = MiniMagick::Image.open(custom_badge)
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.1.1
4
+ version: 0.2.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: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-12 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.1.1
61
+ description: 0.2.0
62
62
  email:
63
63
  - daniel.griesser.86@gmail.com
64
64
  executables: