ios_icon_generator 0.1.2 → 0.1.3

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: 4243f84a51081da8c4e3e7213d4c68afb325fc34
4
- data.tar.gz: c88f2035019f517cf3c38efa734d1093278202fa
3
+ metadata.gz: d633ae350c09c576e31bd3e65b175496d1cd017f
4
+ data.tar.gz: 242575b699097b858353e9022c287910b9022d1f
5
5
  SHA512:
6
- metadata.gz: 73a7463196407d741a49bf87004d5e2d046a233d90f8fd94db3d7e274962fb5ae2e2c0c11497d6de43816104bcd7fcafe227ae4504321991520f6b304c261556
7
- data.tar.gz: 6985de411ffb1ba85d985de1a2c4add3feb6afd6677bb45d54e0a044bfc37a253fbd1a1de54983cc01300d1e2359a0f619382caac65292236758009c8993ba80
6
+ metadata.gz: f1ae670eed65e4ebe753c4380faacdae7bf1680d837ea70ac97a20ed84bb064f489c784db49d8e3c38cf6447850269ece94745c25d880947e21eb964974d0c79
7
+ data.tar.gz: 2709e7e77982fd356d24f8a59433a43875fcc866e337191a15c6d36cfe107e3540fddc3de185650043108ff417c884ecef8da1c4dfa1ebb3a1d51de40bf66192
@@ -18,7 +18,6 @@ require 'colored2'
18
18
  require 'parallel'
19
19
  require 'ruby-progressbar'
20
20
  require 'ios_icon_generator/helpers/generate_icon'
21
- require 'ios_icon_generator/helpers/check_dependencies'
22
21
  require 'hanami/cli'
23
22
 
24
23
  module IOSIconGenerator
@@ -26,18 +25,13 @@ module IOSIconGenerator
26
25
  module Commands
27
26
  class Generate < Hanami::CLI::Command
28
27
  desc 'Generate app icons'
29
- argument :icon_path, required: true, desc: 'The unmasked pdf icon. The icon must be at least 1024x1024'
28
+ argument :icon_path, required: true, desc: 'The unmasked icon of any image file type. The icon must be at least 1024x1024.'
30
29
  argument :xcasset_folder, default: '.', desc: "The path to your .xcassets folder. \
31
30
  If not specified, the appiconsets will be generated in the current folder and can be draged\'n\'dropped there in xcode"
32
31
  option :type, type: :array, default: %w[iphone], desc: 'Which target to generate the icons for. Can be "iphone", "ipad", "watch", "mac" or "carplay" or a combination of any of them, or "imessage"'
33
32
  option :parallel_processes, type: :integer, default: -1, desc: 'Number of processes to use to process the files. Defaults to -1, meaning the number of cores the machine. \
34
33
  Set to 0 to disable parallel processing.'
35
34
  def call(icon_path:, xcasset_folder:, type:, **options)
36
- Helpers.check_dependencies
37
-
38
- raise "#{'ImageMagick'.blue.bold} is required. It can be installed via #{'homebrew'.bold.underlined} using #{'brew install imagemagick'.blue.bold.underlined}" unless Helpers.which('magick')
39
- raise "#{'GhostScript'.blue.bold} is required. It can be installed via #{'homebrew'.bold.underlined} using #{'brew install ghostscript'.blue.bold.underlined}" unless Helpers.which('gs')
40
-
41
35
  types = type.map(&:to_sym)
42
36
 
43
37
  progress_bar = ProgressBar.create(total: nil)
@@ -49,8 +49,6 @@ module IOSIconGenerator
49
49
  option :parallel_processes, type: :integer, default: -1, desc: 'Number of processes to use to process the files. Defaults to -1, meaning the number of cores the machine. \
50
50
  Set to 0 to disable parallel processing.'
51
51
  def call(appiconset_path:, output_path:, **options)
52
- Helpers.check_dependencies
53
-
54
52
  raise 'There is no App icon set at the path specified.' unless Dir.exist?(appiconset_path)
55
53
 
56
54
  progress_bar = ProgressBar.create(total: nil)
@@ -42,8 +42,6 @@ module IOSIconGenerator
42
42
  option :parallel_processes, type: :integer, default: -1, desc: 'Number of processes to use to process the files. Defaults to -1, meaning the number of cores the machine. \
43
43
  Set to 0 to disable parallel processing.'
44
44
  def call(text:, xcasset_folder:, type:, **options)
45
- Helpers.check_dependencies
46
-
47
45
  types = type.map(&:to_sym)
48
46
 
49
47
  progress_bar = ProgressBar.create(total: nil)
@@ -18,9 +18,10 @@ require 'ios_icon_generator/helpers/which'
18
18
 
19
19
  module IOSIconGenerator
20
20
  module Helpers
21
- def self.check_dependencies
21
+ def self.check_dependencies(requires_ghostscript: false)
22
22
  raise "#{'ImageMagick'.blue.bold} is required. It can be installed via #{'homebrew'.bold.underlined} using #{'brew install imagemagick'.blue.bold.underlined}" unless Helpers.which('magick')
23
- raise "#{'GhostScript'.blue.bold} is required. It can be installed via #{'homebrew'.bold.underlined} using #{'brew install ghostscript'.blue.bold.underlined}" unless Helpers.which('gs')
23
+ raise "#{'GhostScript'.blue.bold} is required. It can be installed via #{'homebrew'.bold.underlined} using #{'brew install ghostscript'.blue.bold.underlined}" \
24
+ if requires_ghostscript && !Helpers.which('gs')
24
25
  end
25
26
  end
26
27
  end
@@ -17,6 +17,7 @@
17
17
  require 'json'
18
18
  require 'fileutils'
19
19
  require 'ios_icon_generator/helpers/image_sets_definition'
20
+ require 'ios_icon_generator/helpers/check_dependencies'
20
21
 
21
22
  module IOSIconGenerator
22
23
  module Helpers
@@ -26,7 +27,7 @@ module IOSIconGenerator
26
27
  # If +icon_path+ is set to +nil+, the function expects +generate_icon+ to be set or the function will raise.
27
28
  #
28
29
  # @param [String, #read] icon_path The path to the icon to use as the base icon.
29
- # If specified, it must point to a valid pdf file (with a .pdf extension), with a resolution over 1024x1024.
30
+ # If specified, it must point to a valid image file, with a resolution over 1024x1024 when applicable.
30
31
  # If not specified, +generate_icon+ must be specified.
31
32
  # @param [String, #read] output_folder The folder to create the app icon set in.
32
33
  # @param [Array<Symbol>, #read] types The types to generate the sets of images for. Each type must be one of +:iphone+, +:ipad+, +:watch+, +mac+ or +carplay+, or it can be an array of just +:imessage+.
@@ -47,21 +48,24 @@ module IOSIconGenerator
47
48
  #
48
49
  # @return [String] Return the path to the generated app icon set.
49
50
  def self.generate_icon(icon_path:, output_folder:, types:, parallel_processes: nil, generate_icon: nil, progress: nil)
51
+ is_pdf = icon_path && File.extname(icon_path) == '.pdf'
52
+
53
+ Helpers.check_dependencies(requires_ghostscript: is_pdf)
54
+
50
55
  if icon_path
51
56
  raise "There is no icon at #{icon_path}." unless File.exist?(icon_path)
52
57
 
53
- raise 'The icon specified must be .pdf.' if File.extname(icon_path) != '.pdf'
54
-
55
58
  matches = /(\d+)x(\d+)/.match(`magick identify "#{icon_path}"`)
56
- raise 'Unable to verify icon. Please make sure it\'s a valid pdf file and try again.' if matches.nil?
59
+ raise 'Unable to verify icon. Please make sure it\'s a valid image file and try again.' if matches.nil?
57
60
 
58
61
  width, height = matches.captures
59
- raise 'Invalid pdf specified.' if width.nil? || height.nil?
62
+ raise 'Invalid image specified.' if width.nil? || height.nil?
60
63
 
61
64
  raise "The icon must at least be 1024x1024, it currently is #{width}x#{height}." unless width.to_i >= 1024 && height.to_i >= 1024
62
65
  elsif generate_icon.nil?
63
66
  raise 'icon_path has been set to nil, generate_icon must be specified'
64
67
  end
68
+
65
69
  appiconset_path = File.join(output_folder, "#{types.include?(:imessage) ? 'iMessage App Icon' : 'AppIcon'}.#{types.include?(:imessage) ? 'stickersiconset' : 'appiconset'}")
66
70
 
67
71
  FileUtils.mkdir_p(appiconset_path)
@@ -128,7 +132,7 @@ module IOSIconGenerator
128
132
  progress&.call(nil, total)
129
133
 
130
134
  max_size = smaller_sizes.flatten.max
131
- temp_icon_path = File.join(output_folder, '.temp_icon.pdf')
135
+ temp_icon_path = File.join(output_folder, ".temp_icon#{is_pdf ? '.pdf' : '.png'}")
132
136
  begin
133
137
  system('magick', 'convert', '-density', '400', icon_path, '-colorspace', 'sRGB', '-type', 'truecolor', '-scale', "#{max_size}x#{max_size}", temp_icon_path) if icon_path
134
138
  progress&.call(1, total)
@@ -17,6 +17,7 @@
17
17
  require 'json'
18
18
  require 'base64'
19
19
  require 'fileutils'
20
+ require 'ios_icon_generator/helpers/check_dependencies'
20
21
 
21
22
  module IOSIconGenerator
22
23
  module Helpers
@@ -74,6 +75,8 @@ module IOSIconGenerator
74
75
  parallel_processes: nil,
75
76
  progress: nil
76
77
  )
78
+ Helpers.check_dependencies
79
+
77
80
  extension = File.extname(appiconset_path)
78
81
  output_folder = File.join(output_folder, "#{File.basename(appiconset_path, extension)}-#{mask[:suffix]}#{extension}")
79
82
 
@@ -18,5 +18,5 @@ module IOSIconGenerator
18
18
  ##
19
19
  # The current version of the gem.
20
20
  #
21
- VERSION = '0.1.2'
21
+ VERSION = '0.1.3'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios_icon_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stéphane Copin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-21 00:00:00.000000000 Z
11
+ date: 2019-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: debase
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 0.2.2
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: '0'
152
+ version: 0.2.2
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: phashion
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -224,16 +224,16 @@ dependencies:
224
224
  name: ruby-debug-ide
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ">="
227
+ - - '='
228
228
  - !ruby/object:Gem::Version
229
- version: '0'
229
+ version: 0.6.1
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">="
234
+ - - '='
235
235
  - !ruby/object:Gem::Version
236
- version: '0'
236
+ version: 0.6.1
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: simplecov
239
239
  requirement: !ruby/object:Gem::Requirement