motion-assets 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +59 -0
- data/lib/motion/project/assets.rb +88 -0
- data/lib/motion/project/version.rb +5 -0
- data/lib/motion-assets.rb +2 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f0d79b4ca17c0c92858a404e3678d39d5abe8ed
|
4
|
+
data.tar.gz: 8259ef292cb6edece1883c7f5966374b6c474451
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82f7c3b750301d55c06f5ea60286d7c2ff127154276921b04f372befbfe91ddce86faaa5f502b7d23f6b420fc54230f6cb6f298ca5890f4f97f2ea68258229a0
|
7
|
+
data.tar.gz: 19253e2be55fb04edcd92d3496f469a4f09a47e1fe6f42c50967033f8a226497a59491c145e62b27ed5d3f92422ce1c56ff98ac0281ba02668290b076487c494
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Joffrey Jaffeux
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# motion-assets
|
2
|
+
|
3
|
+
motion-assets allows RubyMotion projects to use ImageMagick to generate all the icons sizes.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
You need to have ImageMagick installed:
|
9
|
+
|
10
|
+
```
|
11
|
+
$ brew install imagemagick
|
12
|
+
```
|
13
|
+
|
14
|
+
And the gem installed:
|
15
|
+
|
16
|
+
```
|
17
|
+
$ [sudo] gem install motion-assets
|
18
|
+
```
|
19
|
+
|
20
|
+
Or if you use Bundler:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'motion-assets'
|
24
|
+
```
|
25
|
+
|
26
|
+
|
27
|
+
## Setup
|
28
|
+
|
29
|
+
In the `Rakefile`, set the path your base image :
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Motion::Project::App.setup do |app|
|
33
|
+
# ...
|
34
|
+
app.assets.base_icon = "./src_images/icon-1024x1024.png"
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
|
40
|
+
You can add or remove icons :
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
Motion::Project::App.setup do |app|
|
44
|
+
# ...
|
45
|
+
app.assets.icons << 'CustomSize.png|32x32'
|
46
|
+
app.assets.icons.delete('Icon-60@2x.png|120x120')
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
## Tasks
|
51
|
+
|
52
|
+
To tell motion-assets to generate the assets :
|
53
|
+
|
54
|
+
```
|
55
|
+
$ [bundle exec] rake assets:generate
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
note : the sample icon comes from the greal Pixemaltor tool, http://www.pixelmator.com/
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'mini_magick'
|
2
|
+
|
3
|
+
unless defined?(Motion::Project::Config)
|
4
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
5
|
+
end
|
6
|
+
|
7
|
+
module Motion::Project
|
8
|
+
class Config
|
9
|
+
variable :assets
|
10
|
+
|
11
|
+
def assets(&block)
|
12
|
+
@assets ||= Motion::Project::Assets.new(self)
|
13
|
+
if block
|
14
|
+
@assets.instance_eval(&block)
|
15
|
+
end
|
16
|
+
@assets
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Assets
|
21
|
+
IOS_ICONS = %w{
|
22
|
+
Icon-Small.png|29x29
|
23
|
+
Icon-Small@2x.png|58x58
|
24
|
+
Icon-Small@3x.png|87x87
|
25
|
+
Icon-40.png|40x40
|
26
|
+
Icon-40@2x.png|80x80
|
27
|
+
Icon-40@3x.png|120x120
|
28
|
+
Icon-60@2x.png|120x120
|
29
|
+
Icon-60@3x.png|180x180
|
30
|
+
Icon-76.png|76x76
|
31
|
+
Icon-76@2x.png|152x152
|
32
|
+
Icon-120.png|120x120
|
33
|
+
iTunesArtwork.png|512x512
|
34
|
+
iTunesArtwork@2x.png|1024x1024
|
35
|
+
}
|
36
|
+
|
37
|
+
ANDROID_ICONS = %w{
|
38
|
+
drawable-xxxhdpi/icon.png|192x192x
|
39
|
+
drawable-xxhdpi/icon.png|144x144x
|
40
|
+
drawable-xhdpi/icon.png|96x96x
|
41
|
+
drawable-hdpi/icon.png|72x72x
|
42
|
+
drawable-mdpi/icon.png|48x48x
|
43
|
+
drawable-ldpi/icon.png|36x36x
|
44
|
+
}
|
45
|
+
|
46
|
+
def initialize(config)
|
47
|
+
@config = config
|
48
|
+
if Motion::Project::App.template != :android
|
49
|
+
@icons = IOS_ICONS
|
50
|
+
else
|
51
|
+
@icons = ANDROID_ICONS
|
52
|
+
end
|
53
|
+
@base_icon = "./src_images/base_icon.png"
|
54
|
+
end
|
55
|
+
|
56
|
+
def base_icon=(base_icon)
|
57
|
+
@base_icon = base_icon
|
58
|
+
end
|
59
|
+
|
60
|
+
def icons
|
61
|
+
@icons
|
62
|
+
end
|
63
|
+
|
64
|
+
def generate!
|
65
|
+
unless File.exist?(@base_icon)
|
66
|
+
App.fail "You have to provide a valid base icon in your rakefile : app.assets.base_icon = './some/path/image.png"
|
67
|
+
end
|
68
|
+
|
69
|
+
@icons.each do |icon|
|
70
|
+
parts = icon.split('|')
|
71
|
+
image = MiniMagick::Image.open(@base_icon)
|
72
|
+
image.resize(parts[1])
|
73
|
+
image.format("png")
|
74
|
+
destination = File.join(@config.resources_dirs.first, parts[0])
|
75
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
76
|
+
image.write(destination)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
namespace :assets do
|
83
|
+
desc "Download and build dependencies"
|
84
|
+
task :generate do
|
85
|
+
assets = App.config.assets
|
86
|
+
assets.generate!
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joffrey Jaffeux
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mini_magick
|
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
|
+
description: motion-assets leverages the power of ImageMagick to generate all icon
|
28
|
+
sizes for your app.
|
29
|
+
email: j.jaffeux@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- lib/motion-assets.rb
|
37
|
+
- lib/motion/project/assets.rb
|
38
|
+
- lib/motion/project/version.rb
|
39
|
+
homepage: http://www.rubymotion.com
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.2.2
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: Generate icons from a base image
|
63
|
+
test_files: []
|