moticons 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +13 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +15 -0
- data/app/app_delegate.rb +5 -0
- data/lib/moticons.rb +12 -0
- data/lib/moticons/icon.rb +62 -0
- data/moticons.gemspec +26 -0
- data/vendor/Podfile.lock +24 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1f01ac054af566c91caf391eed771acd6261c6e4
|
4
|
+
data.tar.gz: 5e9ed3b5903e2bdbf7126813469bd15a106eb0b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cf2dd0bd78bf99387026b7d7015e589c1bf1a2839b4260bed140c9b2419a105169a1622ace0128730f6904203000d5bc9d1abfc3dcbd513997b3c396b8fc644
|
7
|
+
data.tar.gz: 5532bc0cf22b32c8d2c3e51414ca4ebe2931b7de5df511701f395166e7b763eb92f41f8d937063dd4ae5e59b0859a0f2626b462a3d438ebc39ae682a1d58cc3b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: objective-c
|
2
|
+
before_install:
|
3
|
+
- (ruby --version)
|
4
|
+
- sudo chown -R travis ~/Library/RubyMotion
|
5
|
+
- sudo mkdir -p ~/Library/RubyMotion/build
|
6
|
+
- sudo motion update
|
7
|
+
gemfile:
|
8
|
+
- Gemfile
|
9
|
+
script:
|
10
|
+
- bundle exec rake clean
|
11
|
+
- bundle install
|
12
|
+
- bundle exec rake pod:install > /dev/null
|
13
|
+
- bundle exec rake spec
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Havens
|
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,65 @@
|
|
1
|
+
# RubyMotion Icons (a.k.a. Moticons)
|
2
|
+
|
3
|
+
Moticons is the easiest way to add icons to your RubyMotion project. It provides a simple interface for creating text-based or image-based icons.
|
4
|
+
|
5
|
+
Moticons is a wrapper around the [FontAwesomeKit CocoaPod](https://github.com/PrideChung/FontAwesomeKit).
|
6
|
+
|
7
|
+
Supported icon collections include:
|
8
|
+
|
9
|
+
* [Font Awesome](http://fortawesome.github.io/Font-Awesome/)
|
10
|
+
* [Foundation](http://zurb.com/playground/foundation-icon-fonts-3)
|
11
|
+
* [Zocial](http://zocial.smcllns.com)
|
12
|
+
* [Ionicons](http://ionicons.com)
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'moticons'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Moticons provides two global helper methods for creating icons: `icon_string` and `icon_image`.
|
29
|
+
|
30
|
+
Both methods require you to specify the name of the icon collection and the name of the font.
|
31
|
+
|
32
|
+
The collection names are:
|
33
|
+
|
34
|
+
* Font Awesome - `:awesome`
|
35
|
+
* Foundation - `:foundation`
|
36
|
+
* Zocial - `:zocial`
|
37
|
+
* Ionicons - `:ion`
|
38
|
+
|
39
|
+
The icon names are the typical, Ruby snake-cased version of the original name. For example, you would refer to the Font Awesome `cart-arrow-down` icon as `cart_arrow_down`.
|
40
|
+
|
41
|
+
You may specify collection and icon names as separate arguments:
|
42
|
+
|
43
|
+
icon_image(:ion, :star)
|
44
|
+
|
45
|
+
Or you can combine them as a single argument:
|
46
|
+
|
47
|
+
icon_image(:ion_star)
|
48
|
+
|
49
|
+
### Creating an icon as an `NSAttributedString`
|
50
|
+
|
51
|
+
icon_string(:ion, :star, size: 40, color: UIColor.redColor)
|
52
|
+
|
53
|
+
Specifying size and color are optional.
|
54
|
+
|
55
|
+
### Creating an icon as a `UIImage`
|
56
|
+
|
57
|
+
icon_image(:ion, :star, size: 40, color: UIColor.redColor)
|
58
|
+
|
59
|
+
Specifying size and color are optional.
|
60
|
+
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
This gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). Refer to each icon library for their license.
|
65
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift("/Library/RubyMotion/lib")
|
2
|
+
case ENV.fetch('platform', 'ios') # allow setting from the command line, default to iOS
|
3
|
+
when 'ios' then require 'motion/project/template/ios'
|
4
|
+
when 'osx' then require 'motion/project/template/osx'
|
5
|
+
when 'android' then require 'motion/project/template/android'
|
6
|
+
else raise "Unsupported platform #{ENV['platform']}"
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'bundler'
|
10
|
+
Bundler.require
|
11
|
+
require "bundler/gem_tasks"
|
12
|
+
|
13
|
+
Motion::Project::App.setup do |app|
|
14
|
+
app.name = 'moticons'
|
15
|
+
end
|
data/app/app_delegate.rb
ADDED
data/lib/moticons.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This gem is intended to be used in a RubyMotion project."
|
3
|
+
end
|
4
|
+
|
5
|
+
require "motion-cocoapods"
|
6
|
+
|
7
|
+
Motion::Project::App.setup do |app|
|
8
|
+
app.files += Dir.glob(File.join(File.dirname(__FILE__), "moticons", "**", "*.rb"))
|
9
|
+
app.pods do
|
10
|
+
pod "FontAwesomeKit", "~> 2.2"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Moticons
|
2
|
+
class Icon
|
3
|
+
COLLECTION_CLASSES = {
|
4
|
+
awesome: :FAKFontAwesome,
|
5
|
+
foundation: :FAKFoundationIcons,
|
6
|
+
ion: :FAKIonIcons,
|
7
|
+
zocial: :FAKZocial
|
8
|
+
}
|
9
|
+
|
10
|
+
attr_reader :collection, :name, :size, :color
|
11
|
+
|
12
|
+
def initialize(collection, name = nil, options = {})
|
13
|
+
if name.is_a?(Hash)
|
14
|
+
options = name; name = nil
|
15
|
+
end
|
16
|
+
if name.nil?
|
17
|
+
collection, name = collection.split('_', 2)
|
18
|
+
end
|
19
|
+
@collection = collection.to_sym
|
20
|
+
@name = camelize(name).to_sym
|
21
|
+
@size = options.fetch(:size, 42)
|
22
|
+
@color = options.fetch(:color, UIColor.blackColor)
|
23
|
+
|
24
|
+
create_instance
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_image
|
28
|
+
@instance.imageWithSize(CGSizeMake(size, size))
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_string
|
32
|
+
@instance.attributedString
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def create_instance
|
38
|
+
raise "Unknown icon collection name: #{collection}" unless COLLECTION_CLASSES.has_key? collection
|
39
|
+
|
40
|
+
collection_class = Kernel.const_get(COLLECTION_CLASSES[collection])
|
41
|
+
|
42
|
+
if collection_class.respond_to?("#{name}IconWithSize")
|
43
|
+
@instance = collection_class.send("#{name}IconWithSize", size)
|
44
|
+
@instance.addAttribute(NSForegroundColorAttributeName, value: color)
|
45
|
+
else
|
46
|
+
raise "#{name} is an invalid icon name for the #{collection} collection"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def camelize(string)
|
51
|
+
string.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def icon_string(collection, name = nil, options = {})
|
57
|
+
Moticons::Icon.new(collection, name, options).to_string
|
58
|
+
end
|
59
|
+
|
60
|
+
def icon_image(collection, name = nil, options = {})
|
61
|
+
Moticons::Icon.new(collection, name, options).to_image
|
62
|
+
end
|
data/moticons.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "moticons"
|
7
|
+
spec.version = "1.0.0"
|
8
|
+
spec.authors = ["Andrew Havens"]
|
9
|
+
spec.email = ["email@andrewhavens.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Easy icons generators for your RubyMotion app.}
|
12
|
+
spec.description = %q{Easy icons generators for your RubyMotion app.}
|
13
|
+
spec.homepage = "https://github.com/andrewhavens/moticons"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "motion-cocoapods"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
data/vendor/Podfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PODS:
|
2
|
+
- FontAwesomeKit (2.2.0):
|
3
|
+
- FontAwesomeKit/Core (= 2.2.0)
|
4
|
+
- FontAwesomeKit/FontAwesome (= 2.2.0)
|
5
|
+
- FontAwesomeKit/FoundationIcons (= 2.2.0)
|
6
|
+
- FontAwesomeKit/IonIcons (= 2.2.0)
|
7
|
+
- FontAwesomeKit/Zocial (= 2.2.0)
|
8
|
+
- FontAwesomeKit/Core (2.2.0)
|
9
|
+
- FontAwesomeKit/FontAwesome (2.2.0):
|
10
|
+
- FontAwesomeKit/Core
|
11
|
+
- FontAwesomeKit/FoundationIcons (2.2.0):
|
12
|
+
- FontAwesomeKit/Core
|
13
|
+
- FontAwesomeKit/IonIcons (2.2.0):
|
14
|
+
- FontAwesomeKit/Core
|
15
|
+
- FontAwesomeKit/Zocial (2.2.0):
|
16
|
+
- FontAwesomeKit/Core
|
17
|
+
|
18
|
+
DEPENDENCIES:
|
19
|
+
- FontAwesomeKit (~> 2.2)
|
20
|
+
|
21
|
+
SPEC CHECKSUMS:
|
22
|
+
FontAwesomeKit: 025fd4dd1017fe4e3f8d47b03e024deedbb33cd4
|
23
|
+
|
24
|
+
COCOAPODS: 0.37.2
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moticons
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Havens
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: motion-cocoapods
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
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
|
+
description: Easy icons generators for your RubyMotion app.
|
70
|
+
email:
|
71
|
+
- email@andrewhavens.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- app/app_delegate.rb
|
83
|
+
- lib/moticons.rb
|
84
|
+
- lib/moticons/icon.rb
|
85
|
+
- moticons.gemspec
|
86
|
+
- vendor/Podfile.lock
|
87
|
+
homepage: https://github.com/andrewhavens/moticons
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.5
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Easy icons generators for your RubyMotion app.
|
111
|
+
test_files: []
|