icomoon_rails 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: 05ff25b633303a3aa3bfea875b8ab558cd5cad86
4
+ data.tar.gz: b6d1a26bfcc1da97a3979a636997437000fe7a15
5
+ SHA512:
6
+ metadata.gz: c3186e2a21086207a845fcafd8ab57331097023f4a2ef741830c6804bd038381243c443e3ba147e5bbffcad0c946e87edfe4e752ef51a1dfaf1b3973ef5475c8
7
+ data.tar.gz: 3e323cb3c491fa0a639913d149b5cd0ecf97037394316a935de8619d1aeab59768467c6da3f9d02fe97a6bbf91247c55522663041c6cff36271f4a6fbe77c13c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in icomoon-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 KhoaNT
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,92 @@
1
+ # Icomoon::Rails
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/icomoon/rails`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'icomoon-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install icomoon-rails
20
+
21
+ ## Usage
22
+
23
+ In your application.css, include the file:
24
+
25
+ ```
26
+ /*
27
+ *= require icomoon-rails
28
+ */
29
+ ```
30
+
31
+ ### Create IcoMoon project
32
+
33
+ Step 1. Go to https://icomoon.io
34
+
35
+ Step 2. Click on **IcoMoon App**
36
+
37
+ Step 3. Select any icons you liked!
38
+
39
+ Step 4. Click **Generate Font**
40
+
41
+ Step 5. Click **Enable Quick Usage**
42
+
43
+ Step 6. Copy href value of link (example: https://i.icomoon.io/public/temp/fc457ef804/UntitledProject/style.css)
44
+
45
+ Step 7. Run on terminal
46
+
47
+ $ bundle exec rails g icomoon:update <link>
48
+
49
+ With example: ```bundle exec rails g icomoon:update
50
+ https://i.icomoon.io/public/temp/fc457ef804/UntitledProject/style.css```
51
+
52
+ ### How to use icon in View
53
+
54
+ ```
55
+ icon('moon')
56
+ # => <i class="icon-moon"></i>
57
+ ```
58
+
59
+ ```
60
+ icon('moon', class: 'strong')
61
+ # => <i class="icon-moon strong"></i>
62
+ ```
63
+
64
+ ```
65
+ icon('moon', 'MOON', id: 'moon-icon', class: 'strong')
66
+ # => <i id="moon-icon" class="icon-moon strong"></i> MOON
67
+ ```
68
+
69
+ ### How to config Prefix and Postfix class
70
+
71
+ $ rails g icomoon:install
72
+
73
+ You have set prefix and postfix class for IcoMoon in ```config/initializers/icomoon.rb``` file.
74
+
75
+
76
+ ## Then restart your Web Server if it was previously running.
77
+
78
+ ## Development
79
+
80
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
81
+
82
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
83
+
84
+ ## Contributing
85
+
86
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ThanhKhoaIT/icomoon-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
87
+
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
92
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,12 @@
1
+ @font-face {
2
+ font-family: 'icomoon';
3
+ src: url('icomoon_rails/icomoon.eot?5mo2a0');
4
+ src: url('icomoon_rails/icomoon.eot?5mo2a0#iefix') format('embedded-opentype'),
5
+ url('icomoon_rails/icomoon.ttf?5mo2a0') format('truetype'),
6
+ url('icomoon_rails/icomoon.woff?5mo2a0') format('woff'),
7
+ url('icomoon_rails/icomoon.svg?5mo2a0#icomoon') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+
12
+ @import "icomoon_rails/icons.css";
@@ -0,0 +1,17 @@
1
+ module IcomoonRails
2
+ module IconHelper
3
+
4
+ def icon(icon, text = nil, html_options = {})
5
+ text, html_options = nil, text if text.is_a?(Hash)
6
+
7
+ content_class = "#{IcoMoonRails.class_prefix}-#{icon}#{IcoMoonRails.class_postfix}"
8
+ content_class << " #{html_options[:class]}" if html_options.key?(:class)
9
+ html_options[:class] = content_class
10
+
11
+ html = content_tag(:i, nil, html_options)
12
+ html << ' ' << text.to_s unless text.blank?
13
+ html
14
+ end
15
+
16
+ end
17
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "icomoon/rails"
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'icomoon_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "icomoon_rails"
8
+ spec.version = IcomoonRails::VERSION
9
+ spec.authors = ["ThanhKhoaIT"]
10
+ spec.email = ["thanhkhoait@gmail.com"]
11
+
12
+ spec.summary = %q{IcoMoon Client for Rails}
13
+ spec.description = %q{IcoMoon for Rails Application}
14
+ spec.homepage = "https://github.com/ThanhKhoaIT/icomoon-rails"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
@@ -0,0 +1,17 @@
1
+ require "rails/generators/base"
2
+
3
+ module IcomoonRails
4
+ module Generators
5
+
6
+ class InstallGenerator < ::Rails::Generators::Base
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+
10
+ def copy_initializes
11
+ template "icomoon.rb", "config/initializers/icomoon.rb"
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ IcoMoonRails.setup do |config|
2
+
3
+ # Config prefix class
4
+ config.class_prefix = "icon"
5
+
6
+ # Config postfix class
7
+ config.class_postfix = ""
8
+
9
+ end
@@ -0,0 +1,43 @@
1
+ require 'open-uri'
2
+ require 'fileutils'
3
+ require "rails/generators/base"
4
+
5
+ module IcomoonRails
6
+ module Generators
7
+
8
+ class UpdateGenerator < ::Rails::Generators::Base
9
+
10
+ attr_reader :css_body, :assets_path
11
+
12
+ def initializer
13
+ url = @args.first
14
+ @css_body = open(url).read
15
+ @assets_path = "vendor/assets/stylesheets/icomoon_rails"
16
+ end
17
+
18
+ def create_dir
19
+ FileUtils.mkdir_p(assets_path) unless File.directory?(assets_path)
20
+ end
21
+
22
+ def download_font_files
23
+ files = css_body.scan(/(https\:\/\/i.icomoon.io\/public\/temp\/.*)\?/).map(&:first)
24
+
25
+ files.each do |url|
26
+ File.open("#{assets_path}/#{File.basename(url)}", "wb") do |fo|
27
+ fo.write open(url).read
28
+ puts "#{File.basename(url)} is updated"
29
+ end
30
+ end
31
+ end
32
+
33
+ def download_style_files
34
+ File.open("#{assets_path}/icons.css", "wb") do |fo|
35
+ fo.write css_body[css_body.index("}")+1..-1]
36
+ end
37
+ puts "Icons is updated"
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ module IcomoonRails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+
5
+ def self.setup
6
+ yield self
7
+ end
8
+
9
+ mattr_accessor :class_prefix
10
+ @@class_prefix = "icon"
11
+
12
+ mattr_accessor :class_postfix
13
+ @@class_prefix = ""
14
+ end
15
+
16
+ IcoMoonRails = IcomoonRails
@@ -0,0 +1,3 @@
1
+ module IcomoonRails
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icomoon_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ThanhKhoaIT
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-22 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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
+ description: IcoMoon for Rails Application
42
+ email:
43
+ - thanhkhoait@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/stylesheets/icomoon_rails.css.scss
54
+ - app/helpers/icomoon_rails/icon_helper.rb
55
+ - bin/console
56
+ - bin/setup
57
+ - icomoon-rails.gemspec
58
+ - lib/generators/icomoon_rails/install_generator.rb
59
+ - lib/generators/icomoon_rails/templates/icomoon.rb
60
+ - lib/generators/icomoon_rails/update_generator.rb
61
+ - lib/icomoon_rails.rb
62
+ - lib/icomoon_rails/version.rb
63
+ homepage: https://github.com/ThanhKhoaIT/icomoon-rails
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.6
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: IcoMoon Client for Rails
87
+ test_files: []
88
+ has_rdoc: