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 +4 -4
 - data/README.md +21 -4
 - data/bin/badge +3 -1
 - data/lib/badge/base.rb +26 -18
 - data/lib/badge/runner.rb +44 -12
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2e4b80828cf2bcd428d6344d5dc0e4a7a1cb038f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8a7306236d06b72aac255b34ce0884d45c7351de
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 
     | 
    
         
             
             
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            ```badge```
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
             
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
            ```badge --dark```
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
             
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
      
 25 
     | 
    
         
            +
            ```badge --shield="1.2-2031-orange" --no_badge```
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
             
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            ```badge --shield="Version-0.0.3-blue" --dark```
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
             
         
     | 
| 
      
 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 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
                       
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       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. 
     | 
| 
      
 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- 
     | 
| 
      
 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. 
     | 
| 
      
 61 
     | 
    
         
            +
            description: 0.0.4
         
     | 
| 
       62 
62 
     | 
    
         
             
            email:
         
     | 
| 
       63 
63 
     | 
    
         
             
            - daniel.griesser.86@gmail.com
         
     | 
| 
       64 
64 
     | 
    
         
             
            executables:
         
     |