fastlane-plugin-icon_versioning 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82d1d032b7ce422d1fb0d748d3a158bd9e7dcad9
4
- data.tar.gz: 0b12e1a6604c765f1e8b08dd4c930c4451db73e8
3
+ metadata.gz: bf27a15124530480184b11d4e63cbd67f65ca1b0
4
+ data.tar.gz: e7afc502693ea1df9c8a0e72895d5fdad51458c6
5
5
  SHA512:
6
- metadata.gz: 969bc76c0919823f4e236232ffd4b68101b239207257affa314c5e7b8b75e8ad91776584d2336deba4c802f509f16be01e5130ae500dc1b253f5036eeae06114
7
- data.tar.gz: 9f0b38c180c88bf57df4b87604be79bf4e73c897b981db30bf2777d0bcbacd0d1b486090754a63bf140f17f8b7ac5178dd49f480eca76644f0d3ee0f85ae95c6
6
+ metadata.gz: 74b1aff17607afb43a670c1245f50acbaa2646525bf601fd12ad7f872a439c165268b91da5fe91b6b3bdee6b7ef22988d346703791452917a01082a99efb2d6a
7
+ data.tar.gz: 43e9188b61677dad1fc283c86e27642957aebe9fe55502b9dc7101cb2c0b5eadef623f4f118d0da3050b9539787b05f4a27fcec325bf172b7fda8c5d3821e19c
data/README.md CHANGED
@@ -54,7 +54,7 @@ export FASTLANE_DISABLE_COLORS=1 # optional, to remove from the build log the AN
54
54
  export FASTLANE_SKIP_UPDATE_CHECK=1 # optional, to make sure that the versioning finishes as fast as possible in case there is an available update
55
55
  export FASTLANE_HIDE_GITHUB_ISSUES=1 # optional, to make sure that the versioning finishes as fast as possible in case the plugin crashes
56
56
 
57
- bundle exec fastlane run icon_versioning appiconset_path:'/path/to/AppIcon.appiconset' text:'1.2.3 (11.03.2018)\n[ead76f1] {Staging}\nmaster'
57
+ bundle exec fastlane run version_icon appiconset_path:'/path/to/AppIcon.appiconset' text:'1.2.3 (11.03.2018)\n[ead76f1] {Staging}\nmaster'
58
58
  ```
59
59
 
60
60
  _Make sure the script is executable by running `chmod +x /scripts/icon_versioning.sh`_
@@ -39,6 +39,19 @@ module Fastlane
39
39
  description: 'The text to overlay over the icon images',
40
40
  type: String
41
41
  ),
42
+ FastlaneCore::ConfigItem.new(
43
+ key: :text_margins_percentages,
44
+ env_name: 'VERSION_ICON_TEXT_MARGINS_PERCENTAGES',
45
+ description: 'The percentages of the text margins relative to the image\'s size. The array must have all four margins: `text_margins_percentages: [top, right, bottom, left]`, two values: `text_margins_percentages: [vertical, horizontal]` or one value for all of them `text_margins: [all]`',
46
+ default_value: [0.06],
47
+ verify_block: proc do |value|
48
+ UI.user_error!('The number of margins is not equal to 1, 2 or 4') unless value.length == 1 || value.length == 2 || value.length == 4
49
+ UI.user_error!('At least one margin percentage is less than 0') if value.any? { |percentage| percentage < 0 }
50
+ UI.user_error!('At least one margin percentage is greater than 1') if value.any? { |percentage| percentage > 1 }
51
+ end,
52
+ optional: true,
53
+ type: Array
54
+ ),
42
55
  FastlaneCore::ConfigItem.new(
43
56
  key: :band_height_percentage,
44
57
  env_name: 'VERSION_ICON_BAND_HEIGHT_PERCENTAGE',
@@ -11,29 +11,31 @@ module Fastlane
11
11
  module Helper
12
12
  class VersionIconHelper
13
13
  CACHE_FILE_NAME = 'cache.yml'.freeze
14
+ CONTENTS_JSON_FILE_NAME = 'Contents.json'.freeze
14
15
 
15
- attr_accessor :appiconset_path
16
- attr_accessor :text
16
+ def initialize(params)
17
+ @appiconset_path = File.expand_path(params[:appiconset_path])
18
+ @text = params[:text]
17
19
 
18
- attr_accessor :band_height_percentage
19
- attr_accessor :band_blur_radius_percentage
20
- attr_accessor :band_blur_sigma_percentage
20
+ text_margins_percentages = params[:text_margins_percentages]
21
21
 
22
- attr_accessor :ignored_icons_regex
22
+ text_margins_percentages *= 4 if text_margins_percentages.length == 1
23
+ text_margins_percentages *= 2 if text_margins_percentages.length == 2
23
24
 
24
- def initialize(params)
25
- self.appiconset_path = File.expand_path(params[:appiconset_path])
26
- self.text = params[:text]
25
+ @text_top_margin_percentage = text_margins_percentages[0]
26
+ @text_right_margin_percentage = text_margins_percentages[1]
27
+ @text_bottom_margin_percentage = text_margins_percentages[2]
28
+ @text_left_margin_percentage = text_margins_percentages[3]
27
29
 
28
- self.band_height_percentage = params[:band_height_percentage]
29
- self.band_blur_radius_percentage = params[:band_blur_radius_percentage]
30
- self.band_blur_sigma_percentage = params[:band_blur_sigma_percentage]
30
+ @band_height_percentage = params[:band_height_percentage]
31
+ @band_blur_radius_percentage = params[:band_blur_radius_percentage]
32
+ @band_blur_sigma_percentage = params[:band_blur_sigma_percentage]
31
33
 
32
- self.ignored_icons_regex = params[:ignored_icons_regex]
34
+ @ignored_icons_regex = params[:ignored_icons_regex]
33
35
  end
34
36
 
35
37
  def run()
36
- versioned_appiconset_path = self.class.get_versioned_path(self.appiconset_path)
38
+ versioned_appiconset_path = self.class.get_versioned_path(@appiconset_path)
37
39
 
38
40
  Dir.mkdir(versioned_appiconset_path) unless Dir.exist?(versioned_appiconset_path)
39
41
 
@@ -45,10 +47,12 @@ module Fastlane
45
47
  cache = {}
46
48
  end
47
49
 
48
- Dir.glob("#{self.appiconset_path}/*.png").each do |original_icon_path|
50
+ FileUtils.copy("#{@appiconset_path}/#{CONTENTS_JSON_FILE_NAME}", "#{versioned_appiconset_path}/#{CONTENTS_JSON_FILE_NAME}")
51
+
52
+ Dir.glob("#{@appiconset_path}/*.png").each do |original_icon_path|
49
53
  versioned_icon_path = self.class.get_versioned_path(original_icon_path)
50
54
 
51
- text_sha = Digest::SHA2.hexdigest(self.text)
55
+ text_sha = Digest::SHA2.hexdigest(@text)
52
56
 
53
57
  unless cache[original_icon_path].nil?
54
58
  if File.exist?(versioned_icon_path)
@@ -61,7 +65,7 @@ module Fastlane
61
65
  end
62
66
  end
63
67
 
64
- if self.ignored_icons_regex && !(original_icon_path =~ self.ignored_icons_regex).nil?
68
+ if @ignored_icons_regex && !(original_icon_path =~ @ignored_icons_regex).nil?
65
69
  FileUtils.copy(original_icon_path, versioned_icon_path)
66
70
  else
67
71
  version_icon(original_icon_path, versioned_icon_path)
@@ -85,14 +89,19 @@ module Fastlane
85
89
  def version_icon(original_icon_path, versioned_icon_path)
86
90
  image = MiniMagick::Image.open(original_icon_path)
87
91
 
88
- width = image[:width]
89
- height = image[:height]
92
+ image_width = image[:width]
93
+ image_height = image[:height]
90
94
 
91
- band_height = height * self.band_height_percentage
92
- band_blur_radius = width * self.band_blur_radius_percentage
93
- band_blur_sigma = width * self.band_blur_sigma_percentage
95
+ band_height = image_height * @band_height_percentage
96
+ band_blur_radius = image_width * @band_blur_radius_percentage
97
+ band_blur_sigma = image_width * @band_blur_sigma_percentage
94
98
 
95
- band_top_position = height - band_height
99
+ band_top_position = image_height - band_height
100
+
101
+ text_top_margin = image_height * @text_top_margin_percentage
102
+ text_right_margin = image_width * @text_right_margin_percentage
103
+ text_bottom_margin = image_height * @text_bottom_margin_percentage
104
+ text_left_margin = image_width * @text_left_margin_percentage
96
105
 
97
106
  blurred_icon_path = suffix(versioned_icon_path, 'blurred')
98
107
  mask_icon_path = suffix(versioned_icon_path, 'mask')
@@ -110,25 +119,25 @@ module Fastlane
110
119
  convert << blurred_icon_path
111
120
  convert << '-gamma' << '0'
112
121
  convert << '-fill' << 'white'
113
- convert << '-draw' << "rectangle 0, #{band_top_position}, #{width}, #{height}"
122
+ convert << '-draw' << "rectangle 0, #{band_top_position}, #{image_width}, #{image_height}"
114
123
  convert << mask_icon_path
115
124
  end
116
125
 
117
126
  MiniMagick::Tool::Convert.new do |convert|
118
- convert << '-size' << "#{width}x#{band_height}"
127
+ convert << '-size' << "#{image_width}x#{band_height}"
119
128
  convert << 'xc:none'
120
129
  convert << '-fill' << 'rgba(0, 0, 0, 0.2)'
121
- convert << '-draw' << "rectangle 0, 0, #{width}, #{band_height}"
130
+ convert << '-draw' << "rectangle 0, 0, #{image_width}, #{band_height}"
122
131
  convert << text_base_icon_path
123
132
  end
124
133
 
125
134
  MiniMagick::Tool::Convert.new do |convert|
126
135
  convert << '-background' << 'none'
127
- convert << '-size' << "#{width}x#{band_height}"
136
+ convert << '-size' << "#{image_width - (text_left_margin + text_right_margin)}x#{band_height - (text_top_margin + text_bottom_margin)}"
128
137
  convert << '-fill' << 'white'
129
138
  convert << '-gravity' << 'center'
130
139
  # using label instead of caption prevents wrapping long lines
131
- convert << "label:#{self.text}"
140
+ convert << "label:#{@text}"
132
141
  convert << text_icon_path
133
142
  end
134
143
 
@@ -148,7 +157,7 @@ module Fastlane
148
157
  convert << '-geometry' << "+0+#{band_top_position}"
149
158
  convert << '-composite'
150
159
  convert << text_icon_path
151
- convert << '-geometry' << "+0+#{band_top_position}"
160
+ convert << '-geometry' << "+#{text_left_margin}+#{band_top_position + text_top_margin}"
152
161
  convert << '-composite'
153
162
  convert << versioned_icon_path
154
163
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module IconVersioning
3
- VERSION = '1.1.2'
3
+ VERSION = '1.2.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.1.2
4
+ version: 1.2.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-15 00:00:00.000000000 Z
11
+ date: 2018-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pry
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: coveralls
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: fastlane
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec_junit_formatter
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -95,21 +95,21 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rubocop
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 0.49.1
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.49.1
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rubocop-require_tools
112
+ name: rspec_junit_formatter
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: simplecov
126
+ name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,21 +137,21 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: fastlane
140
+ name: rubocop-require_tools
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 2.84.0
145
+ version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 2.84.0
152
+ version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: coveralls
154
+ name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="