fastlane-plugin-icon_versioning 1.0.0 → 1.1.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: af2fe2215c9a6960451b947740164d389b17117b
4
- data.tar.gz: c4b6fbbce95d470bcee7162b8d91f8feb4ad8fa1
3
+ metadata.gz: 31cce154dfee7397c16e0e1295b5c1770b3425e4
4
+ data.tar.gz: e30ab7f0478bf482830e97fe6aab54d2526b95e9
5
5
  SHA512:
6
- metadata.gz: 229ab7bda6fbad805756bfcbc7c059d5ecc2c204324e9e4b70405453c8394d4260d9b677ffe88a7b2902990cdf09bd05f603181614c110d3cfcaf06fa003c597
7
- data.tar.gz: 53591f678340f55755aa926c51bac51706a3d21fba775a7ccaec25b320d0b9aa0cf4813c54fbd909c59fd5e1bbbfd8aad745aa5a9c133ff09e9b30121a4b65b0
6
+ metadata.gz: 65ea28e3206d72be7d9d25a58dabb5f40971345e1df0bed1e5649052a471dafb38d92fa5bb769b763854b9d084b4ff1bfa474fb80ce862ed55d60422bd7a529f
7
+ data.tar.gz: af218c9e33c31c1abb032698afbeb568c614c0c16fe12c9a288ca648fd90e9f5d84754fe32afe31b5aa3b1edeb030726f2149f6e2f0d48884afe984cad8b66b2
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # icon_versioning plugin
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-icon_versioning)
4
+ [![Build Status](https://travis-ci.org/revolter/fastlane-plugin-icon_versioning.svg?branch=master)](https://travis-ci.org/revolter/fastlane-plugin-icon_versioning)
5
+ [![Coverage Status](https://coveralls.io/repos/github/revolter/fastlane-plugin-icon_versioning/badge.svg)](https://coveralls.io/github/revolter/fastlane-plugin-icon_versioning)
4
6
 
5
7
  ## Getting Started
6
8
 
@@ -14,6 +16,15 @@ fastlane add_plugin icon_versioning
14
16
 
15
17
  Overlay build information on top of your app icon. Based on original work by Krzysztof Zabłocki (https://github.com/krzysztofzablocki/Bootstrap).
16
18
 
19
+ ### Improvements
20
+
21
+ Over the original implementation by Krzysztof, I also added:
22
+ - automatic font scaling and blur spreading that ensures a consistent look between different sized icons
23
+ - text lines preservation that doesn't break long lines to prevent unexpected results
24
+ - possibility to specify custom text, band height, blur spread that remain responsive to the icon sizes
25
+
26
+ ### Integrating
27
+
17
28
  This copies the specified `.appiconset` folder to a new folder named `OriginalName-Versioned.appiconset` and overlays the specified `text` over the icon images inside it.
18
29
 
19
30
  To automatically run this on every build, you can add a new `Run Script` `Build Phase` before the `Compile Sources` one and point it to a script that calls this plugin:
@@ -45,6 +56,8 @@ export FASTLANE_HIDE_GITHUB_ISSUES=1 # optional, to make sure that the versionin
45
56
  bundle exec fastlane run icon_versioning appiconset_path:'/path/to/AppIcon.appiconset' text:'1.2.3 (11.03.2018)\n[ead76f1] {Staging}\nmaster'
46
57
  ```
47
58
 
59
+ _Make sure the script is executable by running `chmod +x /scripts/icon_versioning.sh`_
60
+
48
61
  In order for the new versioned icon to be actually used by the app, you have to point the `Asset Catalog App Icon Set Name` (`ASSETCATALOG_COMPILER_APPICON_NAME`) build setting to this new versioned one:
49
62
 
50
63
  ![Build setting](./assets/build_setting.jpg)
@@ -55,6 +68,8 @@ Lastly, you should ignore the `-Versioned` folders using:
55
68
  /path/to/*-Versioned.appiconset/*
56
69
  ```
57
70
 
71
+ If running it automatically on every build is not what you need, you can also call it from wherever you want, as long as you specify the correct parameters.
72
+
58
73
  In the end, it should look like this:
59
74
 
60
75
  ![App icon](./assets/app_icon.jpg)
@@ -63,6 +78,8 @@ In the end, it should look like this:
63
78
 
64
79
  Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
65
80
 
81
+ You can also check out the [example Xcode project](example) to see it in action, and all the required changes [here](https://github.com/revolter/fastlane-plugin-icon_versioning/compare/30f5447...aa4d743).
82
+
66
83
  ## Run tests for this plugin
67
84
 
68
85
  To run both the tests, and code style validation, run
@@ -1,11 +1,17 @@
1
- require 'fastlane_core/ui/ui'
1
+ require 'digest'
2
+ require 'fileutils'
2
3
  require 'mini_magick'
4
+ require 'yaml'
5
+
6
+ require 'fastlane_core/ui/ui'
3
7
 
4
8
  module Fastlane
5
9
  UI = FastlaneCore::UI unless Fastlane.const_defined?('UI')
6
10
 
7
11
  module Helper
8
12
  class IconVersioningHelper
13
+ CACHE_FILE_NAME = 'cache.yml'.freeze
14
+
9
15
  attr_accessor :appiconset_path
10
16
  attr_accessor :text
11
17
 
@@ -29,22 +35,46 @@ module Fastlane
29
35
  def run()
30
36
  versioned_appiconset_path = self.class.get_versioned_path(self.appiconset_path)
31
37
 
32
- FileUtils.remove_entry(versioned_appiconset_path, force: true)
33
- FileUtils.copy_entry(self.appiconset_path, versioned_appiconset_path)
38
+ Dir.mkdir(versioned_appiconset_path) unless Dir.exist?(versioned_appiconset_path)
34
39
 
35
- Dir.glob("#{versioned_appiconset_path}/*.png").each do |icon_path|
36
- next if self.ignored_icons_regex && !(icon_path =~ self.ignored_icons_regex).nil?
40
+ cache_file_path = File.join(versioned_appiconset_path, CACHE_FILE_NAME)
37
41
 
38
- version_icon(icon_path)
42
+ if File.exist?(cache_file_path)
43
+ cache = YAML.load_file(cache_file_path)
44
+ else
45
+ cache = {}
39
46
  end
47
+
48
+ Dir.glob("#{self.appiconset_path}/*.png").each do |original_icon_path|
49
+ versioned_icon_path = self.class.get_versioned_path(original_icon_path)
50
+
51
+ unless cache[original_icon_path].nil?
52
+ if File.exist?(versioned_icon_path)
53
+ versioned_icon_sha = Digest::SHA2.file(versioned_icon_path).hexdigest
54
+ cached_icon_sha = cache[original_icon_path]
55
+
56
+ next if versioned_icon_sha == cached_icon_sha
57
+ end
58
+ end
59
+
60
+ if self.ignored_icons_regex && !(original_icon_path =~ self.ignored_icons_regex).nil?
61
+ FileUtils.copy(original_icon_path, versioned_icon_path)
62
+ else
63
+ version_icon(original_icon_path, versioned_icon_path)
64
+ end
65
+
66
+ cache[original_icon_path] = Digest::SHA2.file(versioned_icon_path).hexdigest
67
+ end
68
+
69
+ File.open(cache_file_path, 'w') { |file| file.write(cache.to_yaml) }
40
70
  end
41
71
 
42
72
  def self.get_versioned_path(path)
43
73
  return path.gsub(/([^.]+)(\.appiconset)/, '\1-Versioned\2')
44
74
  end
45
75
 
46
- private def version_icon(icon_path)
47
- image = MiniMagick::Image.open(icon_path)
76
+ private def version_icon(original_icon_path, versioned_icon_path)
77
+ image = MiniMagick::Image.open(original_icon_path)
48
78
 
49
79
  width = image[:width]
50
80
  height = image[:height]
@@ -55,14 +85,14 @@ module Fastlane
55
85
 
56
86
  band_top_position = height - band_height
57
87
 
58
- blurred_icon_path = suffix(icon_path, 'blurred')
59
- mask_icon_path = suffix(icon_path, 'mask')
60
- text_base_icon_path = suffix(icon_path, 'text_base')
61
- text_icon_path = suffix(icon_path, 'text')
62
- temp_icon_path = suffix(icon_path, 'temp')
88
+ blurred_icon_path = suffix(versioned_icon_path, 'blurred')
89
+ mask_icon_path = suffix(versioned_icon_path, 'mask')
90
+ text_base_icon_path = suffix(versioned_icon_path, 'text_base')
91
+ text_icon_path = suffix(versioned_icon_path, 'text')
92
+ temp_icon_path = suffix(versioned_icon_path, 'temp')
63
93
 
64
94
  MiniMagick::Tool::Convert.new do |convert|
65
- convert << icon_path
95
+ convert << original_icon_path
66
96
  convert << '-blur' << "#{band_blur_radius}x#{band_blur_sigma}"
67
97
  convert << blurred_icon_path
68
98
  end
@@ -94,7 +124,7 @@ module Fastlane
94
124
  end
95
125
 
96
126
  MiniMagick::Tool::Convert.new do |convert|
97
- convert << icon_path
127
+ convert << original_icon_path
98
128
  convert << blurred_icon_path
99
129
  convert << mask_icon_path
100
130
  convert << '-composite'
@@ -111,7 +141,7 @@ module Fastlane
111
141
  convert << text_icon_path
112
142
  convert << '-geometry' << "+0+#{band_top_position}"
113
143
  convert << '-composite'
114
- convert << icon_path
144
+ convert << versioned_icon_path
115
145
  end
116
146
 
117
147
  File.delete(text_base_icon_path, text_icon_path, temp_icon_path)
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module IconVersioning
3
- VERSION = "1.0.0"
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-icon_versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iulian Onofrei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-11 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 2.84.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: coveralls
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  description:
154
168
  email: 6d0847b9@opayq.com
155
169
  executables: []
@@ -182,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
196
  version: '0'
183
197
  requirements: []
184
198
  rubyforge_project:
185
- rubygems_version: 2.6.13
199
+ rubygems_version: 2.5.2
186
200
  signing_key:
187
201
  specification_version: 4
188
202
  summary: Overlay build information on top of your app icon