symbol_to_fontawesome 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/symbol_to_fontawesome.rb +78 -0
- data/lib/symbol_to_fontawesome/version.rb +3 -0
- data/symbol_to_fontawesome.gemspec +26 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edaf1acc62ce7a202338c82e34820a12d96b96eb
|
4
|
+
data.tar.gz: 07a735317d582a9488110c50c07073b9843e4c3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bef63501c5d14b0104dd5c408c57d3d3fbdb5e268831ea1fbf500d5cc7bec93abce382c6641e36328175194f00530ebb0999bde113f1c6922594466062fbf82a
|
7
|
+
data.tar.gz: 4a48ec31eecff955545023c1029de2ec7b75edbb8588cd32a46cd0253a702737191961f2e199dc2784a899782cff0d8a4cfa9970573b4784589661f66ef1e4dd
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 kaneita tsuyoshi
|
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,32 @@
|
|
1
|
+
# SymbolToFontawesome
|
2
|
+
|
3
|
+
More short.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'symbol_to_fontawesome'
|
9
|
+
```
|
10
|
+
|
11
|
+
$ bundle install
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
:ban.fa
|
17
|
+
# <i class="fa fa-ban"></i>
|
18
|
+
|
19
|
+
:ban.fa(4)
|
20
|
+
# <i class="fa fa-ban fa-4x"></i>
|
21
|
+
|
22
|
+
:ban.fa(:left)
|
23
|
+
# <i class="fa fa-ban fa-pull-left"></i>
|
24
|
+
|
25
|
+
:stack.fa(:lg){
|
26
|
+
stack :square_o, 2
|
27
|
+
stack :twitter, 1
|
28
|
+
}
|
29
|
+
# <span class="fa-stack fa-lg"><i class="fa fa-square-o fa-stack-2x"></i><i class="fa fa-twitter fa-stack-1x"></i></span>
|
30
|
+
```
|
31
|
+
|
32
|
+
[More](./spec/symbol_to_fontawesome_spec.rb)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "symbol_to_fontawesome"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require "symbol_to_fontawesome/version"
|
2
|
+
|
3
|
+
module SymbolToFontawesome
|
4
|
+
class ::Symbol
|
5
|
+
def fa(*args, &block)
|
6
|
+
Builder.call(*([self.to_s.gsub('_', '-')] + args), &block).build!
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Builder
|
11
|
+
class << self
|
12
|
+
def call(*args, &block)
|
13
|
+
new(*args, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(*args, &block)
|
18
|
+
if block_given?
|
19
|
+
args.shift
|
20
|
+
@classes = ['fa-stack'] + args.map(&method(:analyze))
|
21
|
+
@stacker = []
|
22
|
+
instance_eval(&block)
|
23
|
+
else
|
24
|
+
@stacked = true if !!args.delete(:stacking)
|
25
|
+
@classes = ['fa-' + args.shift] + args.map(&method(:analyze))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def analyze(param)
|
30
|
+
raise 'not number' if (i = param.to_i) == 0
|
31
|
+
case param.to_i
|
32
|
+
when 1, 2, 3, 4, 5
|
33
|
+
if !!@stacked
|
34
|
+
"fa-stack-#{i}x"
|
35
|
+
else
|
36
|
+
"fa-#{i}x"
|
37
|
+
end
|
38
|
+
when 90, 180, 270
|
39
|
+
"fa-rotate-#{i}"
|
40
|
+
else
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
rescue
|
44
|
+
case param
|
45
|
+
when :fixed_width
|
46
|
+
'fa-fw'
|
47
|
+
when :left, :right
|
48
|
+
"fa-pull-#{param}"
|
49
|
+
when :horizontal, :vertical
|
50
|
+
"fa-flip-#{param}"
|
51
|
+
else
|
52
|
+
if param.is_a?(Symbol)
|
53
|
+
"fa-#{param}"
|
54
|
+
else
|
55
|
+
param
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def build!
|
61
|
+
tag = if !!@stacker
|
62
|
+
%{<span class="#{@classes.join(' ')}">#{@stacker.join}</span>}
|
63
|
+
else
|
64
|
+
%{<i class="fa #{@classes.join(' ')}"></i>}
|
65
|
+
end
|
66
|
+
|
67
|
+
if tag.respond_to?(:html_safe)
|
68
|
+
tag.html_safe
|
69
|
+
else
|
70
|
+
tag
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def stack(*args)
|
75
|
+
@stacker.push(args.shift.fa(*args + [:stacking]))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -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
|
+
require 'symbol_to_fontawesome/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "symbol_to_fontawesome"
|
8
|
+
spec.version = SymbolToFontawesome::VERSION
|
9
|
+
spec.authors = ["mmmpa"]
|
10
|
+
spec.email = ["mmmpa.mmmpa@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "more symple fontawesoming"
|
13
|
+
spec.description = "more symple fontawesoming"
|
14
|
+
spec.homepage = "https://github.com/mmmpa/symbol_to_fontawesome"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
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
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: symbol_to_fontawesome
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mmmpa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-12 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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
|
+
description: more symple fontawesoming
|
56
|
+
email:
|
57
|
+
- mmmpa.mmmpa@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/symbol_to_fontawesome.rb
|
71
|
+
- lib/symbol_to_fontawesome/version.rb
|
72
|
+
- symbol_to_fontawesome.gemspec
|
73
|
+
homepage: https://github.com/mmmpa/symbol_to_fontawesome
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: more symple fontawesoming
|
97
|
+
test_files: []
|