motion-icon_generator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 98e2326be8a9b0141b4ff2a9441412caded0fe3b
4
+ data.tar.gz: fd5c7ddb226ec0c231af4801bd5bb63658fe2efa
5
+ SHA512:
6
+ metadata.gz: e0b6f890a240a6e186ad3786e8b45adda0af65aff2b9ac92dd687aba268b4cc2282770e72d42f7b0d30fe8eb8254d9139ad097617dd627e68b277bf5de90e94f
7
+ data.tar.gz: ccc92b84ab2dcc48528255915c6c179365fe10d84aa74b4b867347d9ed2e40bb4d00f27b383e9df3a49f0d78ffa3e1a0896a78e451a7fd6dc6e1304bd2291b93
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in motion-icon_generator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Bodacious
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Motion::IconGenerator
2
+
3
+ Are you tired of spending hours creating all of the different icon versions you need for your app?
4
+
5
+ **Well, dry your eyes little-one**.
6
+
7
+ motion-icon_generator effortlessly generates all of the iOS icon versions you'll ever need.
8
+
9
+ ## Installation
10
+
11
+ You'll need to install imagemagick first:
12
+
13
+ ``` bash
14
+ brew install imagemagick
15
+ ```
16
+
17
+ Then add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'motion-icon_generator'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install motion-icon_generator
30
+
31
+ and add it to your `Rakefile`:
32
+
33
+ require 'motion/icon_generator'
34
+
35
+ ## Usage
36
+
37
+ Usage is super-easy:
38
+
39
+ 1. Create a template icon image and save it as resources/icon-template.png. This should be about 1024x1024 pixels.
40
+ 2. run this rake task to create your icons `rake icons:generate`. After a few glorious seconds you should see a new directory filled with icons called simply "icons/"
41
+
42
+ ## Configuration
43
+
44
+ You can also set the following environment variables to change the default behaviour:
45
+
46
+ ### Template image name/path
47
+
48
+ rake icons:generate TEMPLATE="~/Desktop/my_template.png"
49
+
50
+ ### Target directory name
51
+
52
+ rake icons:generate TARGET="resources" # we do this, but it's naughty!
53
+
54
+ ### Adding extra icon types.
55
+
56
+ Icons are defined in [icons.yaml](lib/motion/icon_generator/icons.yaml). If you'd like to add your own custom icons on a per-app basis, create a file named `config/icons.yaml` and stick some YAML in there.
57
+
58
+ If you see an icon type that we're missing, please create a pull request or an issue.
59
+
60
+ ## Contributing
61
+
62
+ We would really appreciate if someone could contribute the default icon sizes for Android.
63
+
64
+ 1. Fork it ( https://github.com/KatanaCode/motion-icon_generator/fork )
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create a new Pull Request
69
+
70
+ By [Katana Code, web developers, mobile app developers, nice guys](http://katanacode.com/tools?utm_source=GitHub&utm_medium=README&utm_campaign=motion-icon_generator
71
+ )
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,95 @@
1
+ -
2
+ name: "iTunesConnect.png"
3
+ size: 1024
4
+ scale: 1
5
+
6
+ -
7
+ name: "Icon.png"
8
+ size: 57
9
+ scale: 1
10
+ -
11
+ name: "Icon@2x.png"
12
+ size: 57
13
+ scale: 2
14
+ -
15
+ name: "Icon@3x.png"
16
+ size: 57
17
+ scale: 3
18
+ # ============================
19
+ -
20
+ name: "Icon-Small.png"
21
+ size: 29
22
+ scale: 1
23
+ -
24
+ name: "Icon-Small@2x.png"
25
+ size: 29
26
+ scale: 2
27
+ -
28
+ name: "Icon-Small@3x.png"
29
+ size: 29
30
+ scale: 3
31
+ # ============================
32
+ -
33
+ name: "Icon-Small-40.png"
34
+ size: 40
35
+ scale: 1
36
+ -
37
+ name: "Icon-Small-40@2x.png"
38
+ size: 40
39
+ scale: 2
40
+ -
41
+ name: "Icon-Small-40@3x.png"
42
+ size: 40
43
+ scale: 3
44
+ # ============================
45
+ -
46
+ name: "Icon-Small-50.png"
47
+ size: 50
48
+ scale: 1
49
+ -
50
+ name: "Icon-Small-50@2x.png"
51
+ size: 50
52
+ scale: 2
53
+ -
54
+ name: "Icon-Small-50@3x.png"
55
+ size: 50
56
+ scale: 3
57
+ # ============================
58
+ -
59
+ name: "Icon-60.png"
60
+ size: 60
61
+ scale: 1
62
+ -
63
+ name: "Icon-60@2x.png"
64
+ size: 60
65
+ scale: 2
66
+ -
67
+ name: "Icon-60@3x.png"
68
+ size: 60
69
+ scale: 3
70
+ # ============================
71
+ -
72
+ name: "Icon-72.png"
73
+ size: 72
74
+ scale: 1
75
+ -
76
+ name: "Icon-72@2x.png"
77
+ size: 72
78
+ scale: 2
79
+ -
80
+ name: "Icon-72@3x.png"
81
+ size: 72
82
+ scale: 3
83
+ # ============================
84
+ -
85
+ name: "Icon-76.png"
86
+ size: 76
87
+ scale: 1
88
+ -
89
+ name: "Icon-76@2x.png"
90
+ size: 76
91
+ scale: 2
92
+ -
93
+ name: "Icon-76@3x.png"
94
+ size: 76
95
+ scale: 3
@@ -0,0 +1,69 @@
1
+ module Motion
2
+ module IconGenerator
3
+ class Image
4
+
5
+ require 'rmagick'
6
+
7
+ include Magick
8
+
9
+ attr_reader :size
10
+
11
+
12
+ # Create a new Image
13
+ #
14
+ # size - An ImageSize to specifcy the size and name of image.
15
+ def initialize(size)
16
+ @size = size
17
+ end
18
+
19
+ # Writes this image to disk
20
+ def write!
21
+ create_target_directory
22
+ scaled_image.write(filename)
23
+ end
24
+
25
+ # Prints feedback to STDOUT
26
+ def report
27
+ if File.exist?(filename)
28
+ puts("Created #{filename.ljust(50)}\t(#{size.actual_width}x#{size.actual_height})")
29
+ else
30
+ warn("Couldn't write #{filename}")
31
+ end
32
+ end
33
+
34
+
35
+ private
36
+
37
+
38
+ def scaled_image
39
+ template_image.resize_to_fill(size.actual_width, size.actual_height)
40
+ end
41
+
42
+ def filename
43
+ "#{target}/#{size.name}"
44
+ end
45
+
46
+ def template_image
47
+ if File.exist?(img_name)
48
+ ImageList.new(img_name)
49
+ else
50
+ raise "No template image specified. Did you create resources/icon-template.png?"
51
+ end
52
+ end
53
+
54
+ def create_target_directory
55
+ FileUtils.mkdir(target) unless Dir.exist?(target)
56
+ end
57
+
58
+ def img_name
59
+ ENV['TEMPLATE'] || "resources/icon-template.png"
60
+ end
61
+
62
+ def target
63
+ ENV['TARGET'] || 'icons'
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,31 @@
1
+ module Motion
2
+
3
+ module IconGenerator
4
+
5
+ class Size
6
+
7
+ attr_reader :name
8
+ attr_reader :size
9
+ attr_reader :scale
10
+
11
+
12
+ def initialize(attributes)
13
+ for key, value in attributes
14
+ instance_variable_set("@#{key}", value)
15
+ end
16
+ end
17
+
18
+ def actual_width
19
+ scale * size
20
+ end
21
+
22
+ def actual_height
23
+ scale * size
24
+ end
25
+
26
+ end
27
+
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,5 @@
1
+ module Motion
2
+ module IconGenerator
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ GEM_ROOT = File.join(File.dirname(__FILE__), '..', '..')
2
+
3
+ $LOAD_PATH.unshift(GEM_ROOT)
4
+
5
+ require "motion/icon_generator/version"
6
+
7
+ load "tasks/icons.rake"
8
+
9
+ module Motion
10
+ module IconGenerator
11
+
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ # encoding : utf-8
2
+ require 'motion/icon_generator/image'
3
+ require 'motion/icon_generator/size'
4
+ require 'yaml'
5
+
6
+ namespace :icons do
7
+
8
+ desc "Creates splash images for all devices"
9
+
10
+ task :generate do
11
+ icon_image_sizes.each do |size|
12
+ Motion::IconGenerator::Image.new(size).tap do |icon_image|
13
+ icon_image.write!
14
+ icon_image.report
15
+ end
16
+ end
17
+ end
18
+
19
+
20
+ private
21
+
22
+
23
+ def icon_image_sizes
24
+ @icon_image_sizes ||= begin
25
+ default_icon_image_sizes + local_icon_image_sizes
26
+ end
27
+ end
28
+
29
+ def default_icon_image_sizes
30
+ load_icon_image_sizes_from_file("#{GEM_ROOT}/lib/motion/icon_generator/icons.yaml")
31
+ end
32
+
33
+ def local_icon_image_sizes
34
+ load_icon_image_sizes_from_file("config/icons.yaml")
35
+ end
36
+
37
+ def load_icon_image_sizes_from_file(filename)
38
+ begin
39
+ YAML.load(File.read(filename)).map do |attributes|
40
+ Motion::IconGenerator::Size.new(attributes)
41
+ end.flatten
42
+ rescue Errno::ENOENT
43
+ []
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'motion/icon_generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "motion-icon_generator"
8
+ spec.version = Motion::IconGenerator::VERSION
9
+ spec.authors = ["Bodacious"]
10
+ spec.email = ["gavin@katanacode.com"]
11
+ spec.summary = %q{Automatically generates all of the iOS icons you'll never need}
12
+ spec.description = <<-DESC
13
+ Simple gem that adds a rake task to create all of the versions of iOS icons you'll need to launch. Simply create a template image file and let the app do the rest.
14
+ DESC
15
+
16
+ spec.homepage = "http://github.com/katanacode/motion-icon_generator"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+
25
+ spec.add_dependency 'rmagick'
26
+
27
+ spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "bundler", "~> 1.7"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-icon_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Bodacious
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: |2
70
+ Simple gem that adds a rake task to create all of the versions of iOS icons you'll need to launch. Simply create a template image file and let the app do the rest.
71
+ email:
72
+ - gavin@katanacode.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/motion/icon_generator.rb
83
+ - lib/motion/icon_generator/icons.yaml
84
+ - lib/motion/icon_generator/image.rb
85
+ - lib/motion/icon_generator/size.rb
86
+ - lib/motion/icon_generator/version.rb
87
+ - lib/tasks/icons.rake
88
+ - motion-icon_generator.gemspec
89
+ homepage: http://github.com/katanacode/motion-icon_generator
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Automatically generates all of the iOS icons you'll never need
113
+ test_files: []