motion-splash_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: 8877ef4a19fb6bf5c2658fffc055a682dd76f142
4
+ data.tar.gz: b10af83a5a4dda66f10791a91dfa0e109ad28e88
5
+ SHA512:
6
+ metadata.gz: 545fd26422c61b08e5f4dda30edc139371aa6b11598c791af76ca24a39d6377ad5f4a02bee68b3e5e25f405a0bcdd6ef900558f4e42665bb01d4c1ae6d9b392e
7
+ data.tar.gz: ee282e41602f838b38ece553938272d8dc4ecaa88a55d75503f9436a540085990fda3c76dcf7ac7e8afb81e9286130fbd07ac7dfac4f971803d1d4fec0742df9
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-splash_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,77 @@
1
+ # Motion::SplashGenerator
2
+
3
+ Are you tired of spending hours creating all of the different splash image versions you need for your app?
4
+
5
+ motion-splash_generator effortlessly generates all of the iOS icon versions you'll ever need.
6
+
7
+ Need icons? We gots them here: https://github.com/KatanaCode/motion-icon_generator
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-splash_generator'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install motion-splash_generator
30
+
31
+ and add it to your `Rakefile`:
32
+
33
+ require 'motion/splash_generator'
34
+
35
+ ## Usage
36
+
37
+ Usage is super-easy:
38
+
39
+ 1. Create a template icon image and save it as resources/splash-template.png. This should be about 2048x2048 pixels.
40
+ 2. run this rake task to create your icons `rake splashes:generate`. After a few glorious seconds you should see a new directory filled with icons called simply "splashes/"
41
+
42
+
43
+ ## Configuration
44
+
45
+ You can also set the following environment variables to change the default behaviour:
46
+
47
+ ### Template image name/path
48
+
49
+ rake splashes:generate TEMPLATE="~/Desktop/my_template.png"
50
+
51
+ ### Target directory name
52
+
53
+ rake splashes:generate TARGET="resources" # we do this, but it's well bad!
54
+
55
+ ### Device types supported
56
+
57
+ rake splashes:generate DEVICES="iphone"
58
+ rake splashes:generate DEVICES="ipad"
59
+ rake splashes:generate DEVICES="universal" # creates all splash sizes
60
+
61
+ ### Adding extra splash sizes types.
62
+
63
+ Icons are defined in [splashes.yaml](lib/motion/splash_generator/splashes.yaml). If you'd like to add your own custom splash sizes on a per-app basis, create a file named `config/splashes.yaml` in your app and stick some YAML in there.
64
+
65
+ If you see an icon type that we're missing, please create a pull request or an issue.
66
+
67
+ ## Contributing
68
+
69
+ 1. Fork it ( https://github.com/KatanaCode/motion-splash_generator/fork )
70
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
71
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
72
+ 4. Push to the branch (`git push origin my-new-feature`)
73
+ 5. Create a new Pull Request
74
+
75
+
76
+ By [Katana Code: web developers, mobile app developers, nice guys](katanacode.com/tools?utm_source=GitHub&utm_medium=README&utm_campaign=motion-splash_generator
77
+ )
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,16 @@
1
+
2
+
3
+ require "motion/splash_generator/version"
4
+
5
+
6
+ module Motion
7
+ module SplashGenerator
8
+ def self.root
9
+ @root ||= File.join(File.dirname(__FILE__), '..', '..')
10
+ end
11
+ end
12
+ end
13
+
14
+ $LOAD_PATH.unshift(Motion::SplashGenerator.root)
15
+
16
+ load "lib/tasks/splashes.rake"
@@ -0,0 +1,76 @@
1
+ module Motion
2
+ module SplashGenerator
3
+ class Image
4
+
5
+ include Magick
6
+
7
+ attr_reader :size
8
+
9
+
10
+ def initialize(size)
11
+ @size = size
12
+ end
13
+
14
+ def report
15
+ if File.exist?(filename)
16
+ puts("Created #{filename.ljust(50)}\t(#{size.actual_width}x#{size.actual_height} for #{size.idiom})")
17
+ end
18
+ end
19
+
20
+ def write!
21
+ create_target_directory
22
+ if requested_splash_for_size_idiom?(size)
23
+ begin
24
+ scaled_image.write(filename)
25
+ rescue
26
+ warn("Couldn't write #{filename}")
27
+ end
28
+ else
29
+ puts "Skipping #{size.idiom}"
30
+ end
31
+ end
32
+
33
+
34
+ private
35
+
36
+
37
+ def scaled_image
38
+ template_image.resize_to_fill(size.actual_width, size.actual_height)
39
+ end
40
+
41
+ def filename
42
+ "#{target}/#{size.name}"
43
+ end
44
+
45
+ def requested_splash_for_size_idiom?(size)
46
+ device == 'universal' || size.idiom.start_with?(device)
47
+ end
48
+
49
+ def template_image
50
+ if File.exist?(img_name)
51
+ ImageList.new(img_name)
52
+ else
53
+ raise LoadError, "Can't find resources/splash-template.png. Did you even RTFM?"
54
+ end
55
+ end
56
+
57
+ def create_target_directory
58
+ FileUtils.mkdir(target) unless Dir.exist?(target)
59
+ end
60
+
61
+ def img_name
62
+ ENV['TEMPLATE'] || "resources/splash-templ.png"
63
+ end
64
+
65
+ def device
66
+ ENV['DEVICES'] || 'iphone'
67
+ end
68
+
69
+ def target
70
+ ENV['TARGET'] || 'splashes'
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,33 @@
1
+ module Motion
2
+
3
+ module SplashGenerator
4
+
5
+ class Size
6
+
7
+ attr_reader :name
8
+ attr_reader :orientation
9
+ attr_reader :width
10
+ attr_reader :height
11
+ attr_reader :idiom
12
+ attr_accessor :scale
13
+ attr_reader :orientation
14
+
15
+ def initialize(attributes)
16
+ for key, value in attributes
17
+ instance_variable_set("@#{key}", value)
18
+ end
19
+ end
20
+
21
+ def actual_width
22
+ scale * width
23
+ end
24
+
25
+ def actual_height
26
+ scale * height
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,71 @@
1
+ - # iPhone:
2
+ idiom: 'iphone < 4 portrait'
3
+ name: 'Default.png'
4
+ width: 320
5
+ height: 480
6
+ scale: 1
7
+ orientation: portrait
8
+
9
+ - # iPhone-Retina:
10
+ idiom: 'iphone 4 portrait'
11
+ name: 'Default@2x~iphone.png'
12
+ width: 320
13
+ height: 480
14
+ scale: 2
15
+ orientation: portrait
16
+
17
+ - # iPhone5:
18
+ idiom: 'iphone 5 portrait'
19
+ name: 'Default-568h@2x~iphone.png'
20
+ width: 320
21
+ height: 568
22
+ scale: 2
23
+ orientation: portrait
24
+
25
+ - # iPhone6:
26
+ idiom: 'iphone 6 portrait'
27
+ name: 'Default-667h@2x~iphone.png'
28
+ width: 375
29
+ height: 667
30
+ scale: 2
31
+ orientation: portrait
32
+
33
+ - # iPhone6Plus:
34
+ idiom: 'iphone 6 plus portrait'
35
+ name: 'Default-736h@3x~iphone.png'
36
+ width: 414
37
+ height: 736
38
+ scale: 3
39
+ orientation: portrait
40
+
41
+ - # iPad-portrait:
42
+ idiom: 'ipad 1/2 portrait'
43
+ name: 'Default-Portrait~ipad.png'
44
+ width: 768
45
+ height: 1024
46
+ scale: 1
47
+ orientation: portrait
48
+
49
+ - # iPad-landscape:
50
+ idiom: 'ipad 1/2 landscape'
51
+ name: 'Default-Landscape~ipad.png'
52
+ orientation: 'landscape'
53
+ width: 1024
54
+ height: 768
55
+ scale: 1
56
+
57
+ - # iPad3-portrait:
58
+ idiom: 'ipad 3/4/Air portrait'
59
+ name: 'Default-Portrait@2x~ipad.png'
60
+ width: 768
61
+ height: 1024
62
+ orientation: portrait
63
+ scale: 2
64
+
65
+ - # iPad3-landscape:
66
+ idiom: 'ipad 3/4/Air landscape'
67
+ name: 'Default-Landscape@2x~ipad.png'
68
+ orientation: 'landscape'
69
+ width: 1024
70
+ height: 768
71
+ scale: 2
@@ -0,0 +1,5 @@
1
+ module Motion
2
+ module SplashGenerator
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ # encoding : utf-8
2
+ require 'lib/motion/splash_generator/size'
3
+ require 'lib/motion/splash_generator/image'
4
+
5
+ namespace :splashes do
6
+
7
+ desc "Creates splash images for all devices"
8
+
9
+ task :generate do
10
+ splash_image_sizes.each do |size|
11
+ Motion::SplashGenerator::Image.new(size).tap do |splash_image|
12
+ splash_image.write!
13
+ splash_image.report
14
+ end
15
+ end
16
+ end
17
+
18
+
19
+ private
20
+
21
+
22
+ def splash_image_sizes
23
+ @splash_image_sizes ||= default_splash_image_sizes + local_splash_image_sizes
24
+ end
25
+
26
+ def default_splash_image_sizes
27
+ filename = File.join(Motion::SplashGenerator.root,
28
+ "lib/motion/splash_generator/splashes.yaml").to_s
29
+ splash_image_sizes_from_file(filename)
30
+ end
31
+
32
+ def local_splash_image_sizes
33
+ splash_image_sizes_from_file("config/splashes.yaml")
34
+ end
35
+
36
+ def splash_image_sizes_from_file(filename)
37
+ begin
38
+ YAML.load(File.read(filename)).map do |attributes|
39
+ Motion::SplashGenerator::Size.new(attributes)
40
+ end.flatten
41
+ rescue Errno::ENOENT
42
+ []
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'motion/splash_generator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "motion-splash_generator"
8
+ spec.version = Motion::SplashGenerator::VERSION
9
+ spec.authors = ["Bodacious"]
10
+ spec.email = ["gavin@katanacode.com"]
11
+ spec.summary = %q{Automatically generates all of the iOS splash images you'll never need}
12
+ spec.description = <<-DESC
13
+ Simple gem that adds a rake task to create all of the versions of iOS splash images you'll need to launch. Simply create a template splash file and let the app do the rest.
14
+ DESC
15
+
16
+ spec.homepage = ""
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
+ spec.add_dependency 'rmagick', '~> 2.15.0'
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-splash_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: 2.15.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.15.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: |2
56
+ Simple gem that adds a rake task to create all of the versions of iOS splash images you'll need to launch. Simply create a template splash file and let the app do the rest.
57
+ email:
58
+ - gavin@katanacode.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/motion/splash_generator.rb
69
+ - lib/motion/splash_generator/image.rb
70
+ - lib/motion/splash_generator/size.rb
71
+ - lib/motion/splash_generator/splashes.yaml
72
+ - lib/motion/splash_generator/version.rb
73
+ - lib/tasks/splashes.rake
74
+ - motion-splash_generator.gemspec
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.5
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Automatically generates all of the iOS splash images you'll never need
99
+ test_files: []