motion-smarticons 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Clay Allsopp (http://clayallsopp.com/)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # motion-smarticons
2
+
3
+ motion-smarticons lets you overlay information text like commit hash and version number on top of RubyMotion app icons:
4
+
5
+ ![Default smarticons](http://i.imgur.com/Is0Cc9i.png)
6
+
7
+ ## Installation
8
+
9
+ - `gem install motion-smarticons`
10
+ - `require 'motion-smarticons'`
11
+
12
+ or add it to your `Gemfile`:
13
+
14
+ - `gem 'motion-smarticons'`
15
+
16
+ ## Usage
17
+
18
+ Add the smarticons commands at the end of your `Motion::Project::App.setup` block to ensure your icons and app info is finalized before generating the new icons.
19
+
20
+ By default, smarticons will display the `app.version` and latest commit hash, using the `#smarticons!` method:
21
+
22
+ ```ruby
23
+ Motion::Project::App.setup do |app|
24
+ # ...
25
+
26
+ app.smarticons!
27
+ end
28
+ ```
29
+
30
+ ![Default smarticons](http://i.imgur.com/GPgwZRv.png)
31
+
32
+ If you want to display a custom string, simply use `#smarticons=`:
33
+
34
+ ```ruby
35
+ Motion::Project::App.setup do |app|
36
+ # ...
37
+
38
+ app.smarticons = "Hello World"
39
+ end
40
+ ```
41
+
42
+ ![Custom smarticons](http://i.imgur.com/v5lDmDq.png)
43
+
44
+ ## Gotchas
45
+
46
+ iOS will cache old app icons, even after a clean build. If your icon hasn't updated, move it in and out of a folder to update it to the latest version.
47
+
48
+ ## Credits
49
+
50
+ Shoutout to [@merowing_](http://twitter.com/merowing_) for his article on [generating app icons](http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon).
51
+
52
+ ## Contact
53
+
54
+ Clay Allsopp ([http://clayallsopp.com](http://clayallsopp.com))
55
+
56
+ - [http://twitter.com/clayallsopp](http://twitter.com/clayallsopp)
57
+ - [clay@usepropeller.com](clay@usepropeller.com)
58
+
59
+ ## License
60
+
61
+ motion-smarticons is available under the MIT license. See the LICENSE file for more info.
@@ -0,0 +1 @@
1
+ require 'motion/project/smarticons'
@@ -0,0 +1,77 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ require 'RMagick'
6
+
7
+ class SmartIconsConfig
8
+ attr_accessor :text
9
+
10
+ def initialize(config)
11
+ @config = config
12
+ end
13
+
14
+ def build!
15
+ create_icons
16
+ end
17
+
18
+ def text
19
+ return @text if @text
20
+
21
+ default_text
22
+ end
23
+
24
+ def default_text
25
+ commit = `git rev-parse --short HEAD`.strip
26
+ branch=`git rev-parse --abbrev-ref HEAD`
27
+ app_version = @config.version
28
+ "#{app_version} #{branch} #{commit}"
29
+ end
30
+
31
+ private
32
+ def create_icons
33
+ icons = @config.icons
34
+ files = icons.map {|i|
35
+ [File.join(@config.resources_dirs, i),
36
+ File.join(@config.resources_dirs, "_smart_#{i}")]
37
+ }
38
+
39
+ files.each do |file, new_file|
40
+ icon = Magick::ImageList.new.from_blob(open(file) {|f| f.read}) {
41
+ self.gravity = Magick::SouthGravity
42
+ }.first
43
+
44
+ caption = Magick::Image.read("caption:#{self.text}") {
45
+ self.fill = "white"
46
+ self.background_color = "#0008"
47
+ height = (icon.rows * 0.35).to_i
48
+ self.size = "#{icon.columns}x#{height}"
49
+ self.gravity = Magick::CenterGravity
50
+ }.first
51
+
52
+ new_icon = icon.composite(caption, Magick::SouthGravity, 0, 0, Magick::AtopCompositeOp)
53
+
54
+ new_icon.write(new_file)
55
+ end
56
+
57
+ @config.icons = files.map {|f| File.split(f.last)[-1]}
58
+ end
59
+ end
60
+
61
+ module Motion; module Project; class Config
62
+ def smarticons!
63
+ @smarticons ||= SmartIconsConfig.new(self)
64
+ @smarticons.build!
65
+ end
66
+
67
+ def smarticons
68
+ @smarticons ||= SmartIconsConfig.new(self)
69
+ end
70
+
71
+ def smarticons=(string)
72
+ @smarticons ||= SmartIconsConfig.new(self)
73
+ @smarticons.text = string
74
+ @smarticons.build!
75
+ end
76
+
77
+ end; end; end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-smarticons
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Clay Allsopp
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rmagick
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.13'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.13'
30
+ description: motion-smarticons lets you overlay informational text like commit hash
31
+ and version number on top of RubyMotion app icons
32
+ email: clay.allsopp@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - README.md
38
+ - LICENSE
39
+ - lib/motion/project/smarticons.rb
40
+ - lib/motion-smarticons.rb
41
+ homepage: https://github.com/clayallsopp/motion-smarticons
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ segments:
54
+ - 0
55
+ hash: -86646653972963520
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ segments:
63
+ - 0
64
+ hash: -86646653972963520
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.23
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Automatically generate icon labels for RubyMotion apps
71
+ test_files: []