appicon_generate 0.1.0

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: b2c71b2b93e24441615889935e21398ad0cdedc0
4
+ data.tar.gz: 7f56d70dbdc6b9b9d28b10b4a32ea2bc50d866a3
5
+ SHA512:
6
+ metadata.gz: 7f9b9bfce7d4db3916ab62c3f8ca338fe9dc9686ceb9180bd7c21b9bda952bfb0e77b111f8a208eee725396ef4a7a46add19ad0e920be897ff4da7d63de1264c
7
+ data.tar.gz: 911660f1d434564ef5abbd5072f4c4d2a00bbd0be82c0789976514ee5c62e273e441bf288e37d486b982371876c1892b39ab2526528aaa9c7c0d06e74918a5ed
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in appicon_generate.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 midnightSuyama
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,39 @@
1
+ # AppiconGenerate
2
+
3
+ Generate icon of iOS, Android
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'appicon_generate'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install appicon_generate
18
+
19
+ ## Usage
20
+
21
+ $ appicon_generate [file] [options]
22
+
23
+ ### Options
24
+
25
+ * `-i`, `--ios` Generate icon of iOS
26
+ * `-a`, `--android` Generate icon of Android
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/midnightSuyama/appicon_generate/fork )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
35
+
36
+ ## Reference
37
+
38
+ * [iOS App Programming Guide: App-Related Resources](https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html)
39
+ * [Iconography | Android Developers](http://developer.android.com/design/style/iconography.html)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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 'appicon_generate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "appicon_generate"
8
+ spec.version = AppiconGenerate::VERSION
9
+ spec.authors = ["midnightSuyama"]
10
+ spec.email = ["midnightSuyama@gmail.com"]
11
+ spec.summary = "Generate icon of iOS, Android"
12
+ spec.description = "Generate icon of iOS, Android"
13
+ spec.homepage = "https://github.com/midnightSuyama/appicon_generate"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "image_size"
25
+
26
+ spec.add_runtime_dependency "rmagick"
27
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'appicon_generate'
4
+ require 'appicon_generate/version'
5
+ require 'optparse'
6
+
7
+ options = {}
8
+ OptionParser.new do |opt|
9
+ Version = AppiconGenerate::VERSION
10
+ opt.banner = "Usage: #{File.basename($0)} [file] [options]"
11
+ opt.on('-i', '--ios', 'Generate icon of iOS') {|v| options[:ios] = v }
12
+ opt.on('-a', '--android', 'Generate icon of Android') {|v| options[:android] = v }
13
+ opt.parse!
14
+
15
+ if ARGV.empty?
16
+ puts opt.help
17
+ exit
18
+ end
19
+ end
20
+ options = {:ios => true, :android => true} if options.empty?
21
+
22
+ AppiconGenerate.run(ARGV.first, options)
@@ -0,0 +1,3 @@
1
+ module AppiconGenerate
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,60 @@
1
+ require 'fileutils'
2
+ require 'RMagick'
3
+
4
+ module AppiconGenerate
5
+ DEST_PATH = 'icons'
6
+ Icon = Struct.new(:path, :px)
7
+
8
+ class << self
9
+ def run(file, options)
10
+ icons = []
11
+ icons += icons_ios if options[:ios]
12
+ icons += icons_android if options[:android]
13
+
14
+ img = Magick::Image.read(file).first
15
+ icons.each do |icon|
16
+ path = "#{DEST_PATH}/#{icon.path}"
17
+ FileUtils.mkdir_p(File.dirname(path))
18
+ img.resize(icon.px, icon.px).write(path)
19
+ end
20
+ img.destroy!
21
+ end
22
+
23
+ private
24
+
25
+ def icons_ios
26
+ path = 'ios'
27
+ [
28
+ Icon.new("#{path}/Icon.png", 57),
29
+ Icon.new("#{path}/Icon@2x.png", 114),
30
+ Icon.new("#{path}/Icon-60.png", 60),
31
+ Icon.new("#{path}/Icon-60@2x.png", 120),
32
+ Icon.new("#{path}/Icon-72.png", 72),
33
+ Icon.new("#{path}/Icon-72@2x.png", 144),
34
+ Icon.new("#{path}/Icon-76.png", 76),
35
+ Icon.new("#{path}/Icon-76@2x.png", 152),
36
+ Icon.new("#{path}/Icon-Small.png", 29),
37
+ Icon.new("#{path}/Icon-Small@2x.png", 58),
38
+ Icon.new("#{path}/Icon-Small-50.png", 50),
39
+ Icon.new("#{path}/Icon-Small-50@2x.png", 100),
40
+ Icon.new("#{path}/Icon-40.png", 40),
41
+ Icon.new("#{path}/Icon-40@2x.png", 80),
42
+ Icon.new("#{path}/iTunesArtwork.png", 512),
43
+ Icon.new("#{path}/iTunesArtwork@2x.png", 1024),
44
+ ]
45
+ end
46
+
47
+ def icons_android
48
+ path = 'android'
49
+ [
50
+ Icon.new("#{path}/drawable-ldpi/ic_launcher.png", 36),
51
+ Icon.new("#{path}/drawable-mdpi/ic_launcher.png", 48),
52
+ Icon.new("#{path}/drawable-hdpi/ic_launcher.png", 72),
53
+ Icon.new("#{path}/drawable-xhdpi/ic_launcher.png", 96),
54
+ Icon.new("#{path}/drawable-xxhdpi/ic_launcher.png", 144),
55
+ Icon.new("#{path}/drawable-xxxhdpi/ic_launcher.png", 192),
56
+ Icon.new("#{path}/store.png", 512),
57
+ ]
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,111 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'fileutils'
5
+ require 'image_size'
6
+
7
+ describe AppiconGenerate do
8
+ before :all do
9
+ Dir.mkdir('tmp') unless Dir.exists?('tmp')
10
+ Dir.chdir('tmp')
11
+ end
12
+
13
+ # iOS
14
+ context 'when generate icon of iOS' do
15
+ before(:all) do
16
+ AppiconGenerate.run("#{File.dirname(__FILE__)}/fixtures/source.png", {:ios => true})
17
+ end
18
+
19
+ after(:all) do
20
+ FileUtils.rm_r(AppiconGenerate::DEST_PATH)
21
+ end
22
+
23
+ [
24
+ ['Icon.png', 57],
25
+ ['Icon@2x.png', 114],
26
+ ['Icon-60.png', 60],
27
+ ['Icon-60@2x.png', 120],
28
+ ['Icon-72.png', 72],
29
+ ['Icon-72@2x.png', 144],
30
+ ['Icon-76.png', 76],
31
+ ['Icon-76@2x.png', 152],
32
+ ['Icon-Small.png', 29],
33
+ ['Icon-Small@2x.png', 58],
34
+ ['Icon-Small-50.png', 50],
35
+ ['Icon-Small-50@2x.png', 100],
36
+ ['Icon-40.png', 40],
37
+ ['Icon-40@2x.png', 80],
38
+ ['iTunesArtwork.png', 512],
39
+ ['iTunesArtwork@2x.png', 1024],
40
+ ].each do |path, px|
41
+ path = "#{AppiconGenerate::DEST_PATH}/ios/#{path}"
42
+
43
+ context "'#{path}'" do
44
+ before(:all) do
45
+ @image_size = ImageSize.path(path)
46
+ end
47
+
48
+ it 'should exist' do
49
+ File.exists?(path).should be_true
50
+ end
51
+
52
+ it 'format should be png' do
53
+ @image_size.format.should eq :png
54
+ end
55
+
56
+ it "width should be #{px}px" do
57
+ @image_size.width.should eq px
58
+ end
59
+
60
+ it "height should be #{px}px" do
61
+ @image_size.height.should eq px
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ # Android
68
+ context 'when generate icon of Android' do
69
+ before(:all) do
70
+ AppiconGenerate.run("#{File.dirname(__FILE__)}/fixtures/source.png", {:android => true})
71
+ end
72
+
73
+ after(:all) do
74
+ FileUtils.rm_r(AppiconGenerate::DEST_PATH)
75
+ end
76
+
77
+ [
78
+ ['drawable-ldpi/ic_launcher.png', 36],
79
+ ['drawable-mdpi/ic_launcher.png', 48],
80
+ ['drawable-hdpi/ic_launcher.png', 72],
81
+ ['drawable-xhdpi/ic_launcher.png', 96],
82
+ ['drawable-xxhdpi/ic_launcher.png', 144],
83
+ ['drawable-xxxhdpi/ic_launcher.png', 192],
84
+ ['store.png', 512],
85
+ ].each do |path, px|
86
+ path = "#{AppiconGenerate::DEST_PATH}/android/#{path}"
87
+
88
+ context "'#{path}'" do
89
+ before(:all) do
90
+ @image_size = ImageSize.path(path)
91
+ end
92
+
93
+ it 'should exist' do
94
+ File.exists?(path).should be_true
95
+ end
96
+
97
+ it 'format should be png' do
98
+ @image_size.format.should eq :png
99
+ end
100
+
101
+ it "width should be #{px}px" do
102
+ @image_size.width.should eq px
103
+ end
104
+
105
+ it "height should be #{px}px" do
106
+ @image_size.height.should eq px
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
Binary file
@@ -0,0 +1 @@
1
+ Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each {|f| require f}
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appicon_generate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - midnightSuyama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: image_size
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rmagick
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Generate icon of iOS, Android
84
+ email:
85
+ - midnightSuyama@gmail.com
86
+ executables:
87
+ - appicon_generate
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - appicon_generate.gemspec
98
+ - bin/appicon_generate
99
+ - lib/appicon_generate.rb
100
+ - lib/appicon_generate/version.rb
101
+ - spec/appicon_generate_spec.rb
102
+ - spec/fixtures/source.png
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/midnightSuyama/appicon_generate
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.1
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: Generate icon of iOS, Android
128
+ test_files:
129
+ - spec/appicon_generate_spec.rb
130
+ - spec/fixtures/source.png
131
+ - spec/spec_helper.rb