picon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8da695750f607ff1465b53f4e163e410acf06ffb
4
+ data.tar.gz: 1d0d378cae9eb5ce597e71b52ec135d52087534a
5
+ SHA512:
6
+ metadata.gz: 02761bce783bf2a15a91f5b242abccf4aaaaf8047b96d06227afe1b6d236c167760d66117964ecfe2b212b02e0a2421a4caed97fd34e7f321c51faae2f4fb32a
7
+ data.tar.gz: ffada1f9cad45ca510af8a2d273e4d1b029d23aa62e0244d7e32fa718b6855a966f40594773d8d9cac41fbb4e85530fdd9edbe06c250a0855c7396ae27002674
@@ -0,0 +1,19 @@
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
18
+
19
+ vendor/bundle/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in picon.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Naoto Kaneko
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.
@@ -0,0 +1,27 @@
1
+ # Picon
2
+
3
+ This gem generates [identicons](http://en.wikipedia.org/wiki/Identicon) for iOS apps. It is helpful for developers who cannot create icons with tools such as Adobe Illustrator. Apps under development are usually have the save default icon, and so cannot be tell apart at a glance. However, apps with identicons generated by this gem are can be identified by their icons.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ $ gem install picon
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ At the root of Xcode project,
14
+
15
+ ```
16
+ $ picon generate
17
+ ```
18
+
19
+ this command generates identicons for each resolutions, and places them at right place in your project.
20
+
21
+ ## Contributing
22
+
23
+ 1. Fork it
24
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
25
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
26
+ 4. Push to the branch (`git push origin my-new-feature`)
27
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "picon"
4
+ Picon::Command.run(ARGV)
@@ -0,0 +1,4 @@
1
+ module Picon
2
+ autoload :Command, "picon/command"
3
+ autoload :Generator, "picon/generator"
4
+ end
@@ -0,0 +1,30 @@
1
+ require "picon/version"
2
+
3
+ module Picon
4
+ class Command
5
+ def self.run(argv)
6
+ new(argv).run
7
+ end
8
+
9
+ def initialize(argv)
10
+ @argv = argv
11
+ end
12
+
13
+ def run
14
+ case subcommand
15
+ when "generate"
16
+ Generator.run
17
+ when "version"
18
+ puts VERSION
19
+ else
20
+ abort "Usage: picon {generate|version}"
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def subcommand
27
+ @argv[0]
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,104 @@
1
+ require "pathname"
2
+ require "yaml"
3
+ require "json"
4
+ require "plist"
5
+ require "ruby_identicon"
6
+
7
+ module Picon
8
+ class Generator
9
+ RESOLUTIONS_LIST_PATH = File.expand_path("./resolutions.yml", __dir__)
10
+
11
+ def self.run
12
+ new.run
13
+ end
14
+
15
+ def initialize
16
+ @appiconset_path = get_appiconset_path
17
+ @bundle_identifier = get_bundle_identifier
18
+ end
19
+
20
+ def run
21
+ generate_identicons
22
+ generate_contents_json
23
+ edit_project_pbxproj
24
+ end
25
+
26
+ private
27
+
28
+ def get_appiconset_path
29
+ path = Pathname.glob("**/*.xcassets").first
30
+ path = path.join("Picon.appiconset")
31
+ path.mkdir unless path.exist?
32
+ path
33
+ end
34
+
35
+ def get_bundle_identifier
36
+ xcodeproj_path = Pathname.glob("**/*.xcodeproj").first
37
+ product_name = File.basename(xcodeproj_path.to_s, ".xcodeproj")
38
+
39
+ pathnames = Pathname.glob("**/*-Info.plist")
40
+ pathnames.reject! { |pathname| pathname.to_s =~ /Test/ }
41
+ pathname = pathnames.first
42
+ plist = Plist.parse_xml(pathname.to_s)
43
+ plist["CFBundleIdentifier"].gsub!(/\${PRODUCT_NAME.*}$/) { product_name }
44
+ end
45
+
46
+ def generate_identicons
47
+ resolutions = YAML.load_file(RESOLUTIONS_LIST_PATH)
48
+ resolutions.each do |device, images|
49
+ images.each do |image|
50
+ filepath = @appiconset_path.join(image["filename"])
51
+ next if filepath.exist?
52
+
53
+ grid_size = 7
54
+ square_size = image["size"].to_i / grid_size
55
+ border_size = ((image["size"].to_i - grid_size * square_size).to_f / 2).ceil
56
+ RubyIdenticon.create_and_save(@bundle_identifier, filepath, border_size: border_size, grid_size: grid_size, square_size: square_size)
57
+ end
58
+ end
59
+ end
60
+
61
+ def generate_contents_json
62
+ contents = { "images" => [] }
63
+
64
+ resolutions = YAML.load_file(RESOLUTIONS_LIST_PATH)
65
+ resolutions.each do |device, properties|
66
+ properties.each do |property|
67
+ size = property["size"].to_i
68
+ size /= 2 if property["scale"] == "2x"
69
+
70
+ image = {}
71
+ image["idiom"] = device
72
+ image["filename"] = property["filename"]
73
+ image["size"] = "#{size}x#{size}"
74
+ image["scale"] = property["scale"]
75
+ contents["images"] << image
76
+ end
77
+ end
78
+
79
+ contents["info"] = { "version" => 1, "author" => "picon" }
80
+
81
+ filepath = @appiconset_path.join("Contents.json")
82
+ filepath.open("wb") do |file|
83
+ file << JSON.pretty_generate(contents)
84
+ end
85
+ end
86
+
87
+ def edit_project_pbxproj
88
+ data = ""
89
+
90
+ pbxproj_path = Pathname.glob("**/project.pbxproj").first
91
+ pbxproj_path.open("rb") do |file|
92
+ data = file.read
93
+ end
94
+
95
+ data.gsub!(/(ASSETCATALOG_COMPILER_APPICON_NAME = )AppIcon/) { "#{$1}Picon" }
96
+
97
+ pbxproj_path.open("wb") do |file|
98
+ file.flush
99
+ file << data
100
+ end
101
+ end
102
+ end
103
+ end
104
+
@@ -0,0 +1,31 @@
1
+ iphone:
2
+ - size: 58
3
+ filename: "Icon-29@2x.png"
4
+ scale: "2x"
5
+ - size: 80
6
+ filename: "Icon-40@2x.png"
7
+ scale: "2x"
8
+ - size: 120
9
+ filename: "Icon-60@2x.png"
10
+ scale: "2x"
11
+
12
+ ipad:
13
+ - size: 29
14
+ filename: "Icon-29.png"
15
+ scale: "1x"
16
+ - size: 58
17
+ filename: "Icon-29@2x.png"
18
+ scale: "2x"
19
+ - size: 40
20
+ filename: "Icon-40.png"
21
+ scale: "1x"
22
+ - size: 80
23
+ filename: "Icon-40@2x.png"
24
+ scale: "2x"
25
+ - size: 76
26
+ filename: "Icon-76.png"
27
+ scale: "1x"
28
+ - size: 152
29
+ filename: "Icon-76@2x.png"
30
+ scale: "2x"
31
+
@@ -0,0 +1,3 @@
1
+ module Picon
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'picon/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "picon"
8
+ spec.version = Picon::VERSION
9
+ spec.authors = ["Naoto Kaneko"]
10
+ spec.email = ["naoty.k@gmail.com"]
11
+ spec.description = %q{This gem generates identicons for iOS apps. It is helpful for developers who cannot create icons with tools such as Adobe Illustrator. Apps under development are usually have the save default icon, and so cannot be tell apart at a glance. However, apps with identicons generated by this gem are can be identified by their icons.}
12
+ spec.summary = %q{Generator of identicon for iOS apps}
13
+ spec.homepage = "https://github.com/naoty/picon"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = %w{picon}
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "plist", "~> 3.1.0"
22
+ spec.add_dependency "ruby_identicon", "~> 0.0.1"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "pry"
28
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: picon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naoto Kaneko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: plist
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby_identicon
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.1
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.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: This gem generates identicons for iOS apps. It is helpful for developers
98
+ who cannot create icons with tools such as Adobe Illustrator. Apps under development
99
+ are usually have the save default icon, and so cannot be tell apart at a glance.
100
+ However, apps with identicons generated by this gem are can be identified by their
101
+ icons.
102
+ email:
103
+ - naoty.k@gmail.com
104
+ executables:
105
+ - picon
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - .gitignore
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/picon
115
+ - lib/picon.rb
116
+ - lib/picon/command.rb
117
+ - lib/picon/generator.rb
118
+ - lib/picon/resolutions.yml
119
+ - lib/picon/version.rb
120
+ - picon.gemspec
121
+ homepage: https://github.com/naoty/picon
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.0.3
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Generator of identicon for iOS apps
145
+ test_files: []