drg_material_icons 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/LICENSE +22 -0
- data/README.md +113 -0
- data/Rakefile +12 -0
- data/app/assets/fonts/material-icons-outline.woff2 +0 -0
- data/app/assets/fonts/material-icons-regular.woff2 +0 -0
- data/app/assets/stylesheets/drg_material_icons.css +2430 -0
- data/app/helpers/drg_material_icons/rails/icon_helper.rb +112 -0
- data/lib/drg_material_icons/engine.rb +6 -0
- data/lib/drg_material_icons/version.rb +6 -0
- data/lib/drg_material_icons.rb +2 -0
- data/lib/generators/drg_material_icons_update/USAGE +8 -0
- data/lib/generators/drg_material_icons_update/common.css +284 -0
- data/lib/generators/drg_material_icons_update/drg_material_icons_update_generator.rb +41 -0
- data/lib/generators/drg_material_icons_update/material-icons-outline.codepoints +2117 -0
- data/lib/generators/drg_material_icons_update/material-icons-regular.codepoints +2142 -0
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/assets/stylesheets/sass-import.css.sass +1 -0
- data/test/dummy/app/assets/stylesheets/scss-import.css.scss +1 -0
- data/test/dummy/app/assets/stylesheets/sprockets-require.css +3 -0
- data/test/dummy/app/controllers/pages_controller.rb +2 -0
- data/test/dummy/app/views/pages/icons.html.erb +3 -0
- data/test/dummy/config/application.rb +19 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +22 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config.ru +4 -0
- data/test/font_awesome_rails_test.rb +70 -0
- data/test/icon_helper_test.rb +138 -0
- data/test/test_helper.rb +7 -0
- metadata +123 -0
@@ -0,0 +1 @@
|
|
1
|
+
@import font-awesome
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "font-awesome";
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# require "rails/all"
|
4
|
+
require "sprockets/railtie"
|
5
|
+
|
6
|
+
Bundler.require(:default, :development)
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.encoding = "utf-8"
|
11
|
+
config.assets.enabled = true
|
12
|
+
config.assets.version = '1.0'
|
13
|
+
|
14
|
+
# replacement for environments/*.rb
|
15
|
+
config.active_support.deprecation = :stderr
|
16
|
+
config.eager_load = false
|
17
|
+
config.active_support.test_order = :random rescue nil
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
#
|
8
|
+
# avoid deprecation warnings if building against older versions of Rails
|
9
|
+
|
10
|
+
# secret_token migrated to secret_key_base in Rails 4
|
11
|
+
SKB_VERSION = Gem::Version.new('4.0.0')
|
12
|
+
|
13
|
+
# Get the current Rails version.
|
14
|
+
RAILS_VERSION = Rails.respond_to?(:version) ? Gem::Version.new(Rails.version) : Gem::Version.new('3.22')
|
15
|
+
|
16
|
+
# if we're running an old version of Rails
|
17
|
+
if RAILS_VERSION < SKB_VERSION
|
18
|
+
Dummy::Application.config.secret_token = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
|
19
|
+
else
|
20
|
+
Dummy::Application.config.secret_key_base = 'deadbeef' if Dummy::Application.config.respond_to?(:secret_key_base)
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class FontAwesomeRailsTest < ActionDispatch::IntegrationTest
|
4
|
+
teardown { clean_sprockets_cache }
|
5
|
+
|
6
|
+
test "engine is loaded" do
|
7
|
+
assert_equal ::Rails::Engine, FontAwesome::Rails::Engine.superclass
|
8
|
+
end
|
9
|
+
|
10
|
+
test "fonts are served" do
|
11
|
+
get "/assets/fontawesome-webfont.eot"
|
12
|
+
assert_response :success
|
13
|
+
get "/assets/fontawesome-webfont.woff2"
|
14
|
+
assert_response :success
|
15
|
+
get "/assets/fontawesome-webfont.woff"
|
16
|
+
assert_response :success
|
17
|
+
get "/assets/fontawesome-webfont.ttf"
|
18
|
+
assert_response :success
|
19
|
+
get "/assets/fontawesome-webfont.svg"
|
20
|
+
assert_response :success
|
21
|
+
end
|
22
|
+
|
23
|
+
test "stylesheets are served" do
|
24
|
+
get "/assets/font-awesome.css"
|
25
|
+
assert_font_awesome(response)
|
26
|
+
end
|
27
|
+
|
28
|
+
test "stylesheets contain asset pipeline references to fonts" do
|
29
|
+
get "/assets/font-awesome.css"
|
30
|
+
assert_match %r{/assets/fontawesome-webfont(-\w+)?\.eot}, response.body
|
31
|
+
assert_match %r{/assets/fontawesome-webfont(-\w+)?\.eot\?#iefix}, response.body
|
32
|
+
assert_match %r{/assets/fontawesome-webfont(-\w+)?\.woff2}, response.body
|
33
|
+
assert_match %r{/assets/fontawesome-webfont(-\w+)?\.woff}, response.body
|
34
|
+
assert_match %r{/assets/fontawesome-webfont(-\w+)?\.ttf}, response.body
|
35
|
+
assert_match %r{/assets/fontawesome-webfont(-\w+)?\.svg#fontawesomeregular}, response.body
|
36
|
+
end
|
37
|
+
|
38
|
+
test "stylesheet is available in a css sprockets require" do
|
39
|
+
get "/assets/sprockets-require.css"
|
40
|
+
assert_font_awesome(response)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "stylesheet is available in a sass import" do
|
44
|
+
get "/assets/sass-import.css"
|
45
|
+
assert_font_awesome(response)
|
46
|
+
end
|
47
|
+
|
48
|
+
test "stylesheet is available in a scss import" do
|
49
|
+
get "/assets/scss-import.css"
|
50
|
+
assert_font_awesome(response)
|
51
|
+
end
|
52
|
+
|
53
|
+
test "helpers should be available in the view" do
|
54
|
+
get "/icons"
|
55
|
+
assert_response :success
|
56
|
+
assert_select "i.fa.fa-flag"
|
57
|
+
assert_select "span.fa-stack"
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def clean_sprockets_cache
|
63
|
+
FileUtils.rm_rf File.expand_path("../dummy/tmp", __FILE__)
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_font_awesome(response)
|
67
|
+
assert_response :success
|
68
|
+
assert_match(/font-family:\s*'FontAwesome';/, response.body)
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class FontAwesome::Rails::IconHelperTest < ActionView::TestCase
|
4
|
+
|
5
|
+
test "#fa_icon with no args should render a flag icon" do
|
6
|
+
assert_icon i("fa fa-flag")
|
7
|
+
end
|
8
|
+
|
9
|
+
test "#fa_icon should render different individual icons" do
|
10
|
+
assert_icon i("fa fa-flag"), "flag"
|
11
|
+
assert_icon i("fa fa-camera-retro"), "camera-retro"
|
12
|
+
assert_icon i("fa fa-cog"), "cog"
|
13
|
+
assert_icon i("fa fa-github"), "github"
|
14
|
+
end
|
15
|
+
|
16
|
+
test "#fa_icon should render icons with multiple modifiers" do
|
17
|
+
assert_icon i("fa fa-pencil fa-fixed-width"), "pencil fixed-width"
|
18
|
+
assert_icon i("fa fa-flag fa-4x"), "flag 4x"
|
19
|
+
assert_icon i("fa fa-refresh fa-2x fa-spin"), "refresh 2x spin"
|
20
|
+
end
|
21
|
+
|
22
|
+
test "#fa_icon should render icons with array modifiers" do
|
23
|
+
assert_icon i("fa fa-flag"), ["flag"]
|
24
|
+
assert_icon i("fa fa-check fa-li"), ["check", "li"]
|
25
|
+
assert_icon i("fa fa-flag fa-4x"), ["flag", "4x"]
|
26
|
+
assert_icon i("fa fa-refresh fa-2x fa-spin"), ["refresh", "2x", "spin"]
|
27
|
+
end
|
28
|
+
|
29
|
+
test "#fa_icon should incorporate additional class styles" do
|
30
|
+
assert_icon i("fa fa-flag pull-right"), "flag", :class => "pull-right"
|
31
|
+
assert_icon i("fa fa-flag fa-2x pull-right"), ["flag", "2x"], :class => ["pull-right"]
|
32
|
+
assert_icon i("fa fa-check fa-li pull-right special"), "check li", :class => "pull-right special"
|
33
|
+
assert_icon i("fa fa-check pull-right special"), "check", :class => ["pull-right", "special"]
|
34
|
+
end
|
35
|
+
|
36
|
+
test "#fa_icon should incorporate a text suffix" do
|
37
|
+
assert_icon "#{i("fa fa-camera-retro")} Take a photo", "camera-retro", :text => "Take a photo"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "#fa_icon should be able to put the icon on the right" do
|
41
|
+
assert_icon "Submit #{i("fa fa-chevron-right")}", "chevron-right", :text => "Submit", :right => true
|
42
|
+
end
|
43
|
+
|
44
|
+
test "#fa_icon should html escape text" do
|
45
|
+
assert_icon "#{i("fa fa-camera-retro")} <script></script>", "camera-retro", :text => "<script></script>"
|
46
|
+
end
|
47
|
+
|
48
|
+
test "#fa_icon should not html escape safe text" do
|
49
|
+
assert_icon "#{i("fa fa-camera-retro")} <script></script>", "camera-retro", :text => "<script></script>".html_safe
|
50
|
+
end
|
51
|
+
|
52
|
+
test "#fa_icon should pull it all together" do
|
53
|
+
assert_icon "#{i("fa fa-camera-retro pull-right")} Take a photo", "camera-retro", :text => "Take a photo", :class => "pull-right"
|
54
|
+
end
|
55
|
+
|
56
|
+
test "#fa_icon should pass all other options through" do
|
57
|
+
assert_icon %(<i class="fa fa-user" data-id="123"></i>), "user", :data => { :id => 123 }
|
58
|
+
end
|
59
|
+
|
60
|
+
test '#fa_icon does not modify options' do
|
61
|
+
icon_options = { :class => 'foo', :data => { :id => 123 }, :text => 'bar' }
|
62
|
+
assert_icon %(<i class="fa fa-user foo" data-id="123"></i> bar), "user", icon_options
|
63
|
+
assert_includes icon_options, :class
|
64
|
+
assert_includes icon_options, :text
|
65
|
+
assert_includes icon_options, :data
|
66
|
+
end
|
67
|
+
|
68
|
+
test "#fa_stacked_icon with no args should render a flag icon" do
|
69
|
+
expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-flag fa-stack-1x")}</span>)
|
70
|
+
assert_stacked_icon expected
|
71
|
+
end
|
72
|
+
|
73
|
+
test "#fa_stacked_icon should render a stacked icon" do
|
74
|
+
expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span>)
|
75
|
+
assert_stacked_icon expected, "twitter", :base => "square-o"
|
76
|
+
expected = %(<span class="fa-stack">#{i("fa fa-square fa-stack-2x")}#{i("fa fa-terminal fa-inverse fa-stack-1x")}</span>)
|
77
|
+
assert_stacked_icon expected, ["terminal", "inverse"], :base => ["square"]
|
78
|
+
end
|
79
|
+
|
80
|
+
test "#fa_stacked_icon should incorporate additional class styles" do
|
81
|
+
expected = %(<span class="fa-stack pull-right">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span>)
|
82
|
+
assert_stacked_icon expected, "twitter", :base => "square-o", :class => "pull-right"
|
83
|
+
end
|
84
|
+
|
85
|
+
test "#fa_stacked_icon should reverse the stack" do
|
86
|
+
expected = %(<span class="fa-stack">#{i("fa fa-facebook fa-stack-1x")}#{i("fa fa-ban fa-stack-2x")}</span>)
|
87
|
+
assert_stacked_icon expected, "facebook", :base => "ban", :reverse => "true"
|
88
|
+
end
|
89
|
+
|
90
|
+
test "#fa_stacked_icon should be able to put the icon on the right" do
|
91
|
+
expected = %(Go <span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-exclamation fa-stack-1x")}</span>)
|
92
|
+
assert_stacked_icon expected, "exclamation", :text => "Go", :right => true
|
93
|
+
end
|
94
|
+
|
95
|
+
test "#fa_stacked_icon should html escape text" do
|
96
|
+
expected = %(<span class="fa-stack">#{i("fa fa-check-empty fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span> <script>)
|
97
|
+
assert_stacked_icon expected, "twitter", :base => "check-empty", :text => "<script>"
|
98
|
+
end
|
99
|
+
|
100
|
+
test "#fa_stacked_icon should not html escape safe text" do
|
101
|
+
expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span> <script>)
|
102
|
+
assert_stacked_icon expected, "twitter", :base => "square-o", :text => "<script>".html_safe
|
103
|
+
end
|
104
|
+
|
105
|
+
test "#fa_stacked_icon should accept options for base and main icons" do
|
106
|
+
expected = %(<span class="fa-stack">#{i("fa fa-camera fa-stack-1x text-info")}#{i("fa fa-ban fa-stack-2x text-error")}</span>)
|
107
|
+
assert_stacked_icon expected, "camera", :base => "ban", :reverse => true, :base_options => { :class => "text-error" }, :icon_options => { :class => "text-info" }
|
108
|
+
end
|
109
|
+
|
110
|
+
test "#fa_stacked_icon should pass all other options through" do
|
111
|
+
expected = %(<span class="fa-stack" data-id="123">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-user fa-stack-1x")}</span>)
|
112
|
+
assert_stacked_icon expected, "user", :base => "square-o", :data => { :id => 123 }
|
113
|
+
end
|
114
|
+
|
115
|
+
test '#fa_stacked_icon does not modify options' do
|
116
|
+
icon_options = { :class => 'foo', :base => "square-o", :data => { :id => 123 } }
|
117
|
+
expected = %(<span class="fa-stack foo" data-id="123">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-user fa-stack-1x")}</span>)
|
118
|
+
assert_stacked_icon expected, "user", icon_options
|
119
|
+
assert_includes icon_options, :class
|
120
|
+
assert_includes icon_options, :data
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def assert_icon(expected, *args)
|
126
|
+
message = "`fa_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
|
127
|
+
assert_dom_equal expected, fa_icon(*args), message
|
128
|
+
end
|
129
|
+
|
130
|
+
def assert_stacked_icon(expected, *args)
|
131
|
+
message = "`fa_stacked_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
|
132
|
+
assert_dom_equal expected, fa_stacked_icon(*args), message
|
133
|
+
end
|
134
|
+
|
135
|
+
def i(classes)
|
136
|
+
%(<i class="#{classes}"></i>)
|
137
|
+
end
|
138
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drg_material_icons
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Damjan Rems
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '8.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '8.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: drg_material_icons provides Google Material icon web fonts and stylesheets
|
48
|
+
as a Rails engine for use with the asset pipeline.
|
49
|
+
email:
|
50
|
+
- damjan.rems@gmail.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- app/assets/fonts/material-icons-outline.woff2
|
59
|
+
- app/assets/fonts/material-icons-regular.woff2
|
60
|
+
- app/assets/stylesheets/drg_material_icons.css
|
61
|
+
- app/helpers/drg_material_icons/rails/icon_helper.rb
|
62
|
+
- lib/drg_material_icons.rb
|
63
|
+
- lib/drg_material_icons/engine.rb
|
64
|
+
- lib/drg_material_icons/version.rb
|
65
|
+
- lib/generators/drg_material_icons_update/USAGE
|
66
|
+
- lib/generators/drg_material_icons_update/common.css
|
67
|
+
- lib/generators/drg_material_icons_update/drg_material_icons_update_generator.rb
|
68
|
+
- lib/generators/drg_material_icons_update/material-icons-outline.codepoints
|
69
|
+
- lib/generators/drg_material_icons_update/material-icons-regular.codepoints
|
70
|
+
- test/dummy/app/assets/config/manifest.js
|
71
|
+
- test/dummy/app/assets/stylesheets/sass-import.css.sass
|
72
|
+
- test/dummy/app/assets/stylesheets/scss-import.css.scss
|
73
|
+
- test/dummy/app/assets/stylesheets/sprockets-require.css
|
74
|
+
- test/dummy/app/controllers/pages_controller.rb
|
75
|
+
- test/dummy/app/views/pages/icons.html.erb
|
76
|
+
- test/dummy/config.ru
|
77
|
+
- test/dummy/config/application.rb
|
78
|
+
- test/dummy/config/boot.rb
|
79
|
+
- test/dummy/config/environment.rb
|
80
|
+
- test/dummy/config/initializers/secret_token.rb
|
81
|
+
- test/dummy/config/routes.rb
|
82
|
+
- test/font_awesome_rails_test.rb
|
83
|
+
- test/icon_helper_test.rb
|
84
|
+
- test/test_helper.rb
|
85
|
+
homepage: https://github.com/drgcms/drg-material-icons
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubygems_version: 3.2.22
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: an asset gemification of the Google Material icon font library
|
108
|
+
test_files:
|
109
|
+
- test/dummy/app/assets/config/manifest.js
|
110
|
+
- test/dummy/app/assets/stylesheets/sass-import.css.sass
|
111
|
+
- test/dummy/app/assets/stylesheets/scss-import.css.scss
|
112
|
+
- test/dummy/app/assets/stylesheets/sprockets-require.css
|
113
|
+
- test/dummy/app/controllers/pages_controller.rb
|
114
|
+
- test/dummy/app/views/pages/icons.html.erb
|
115
|
+
- test/dummy/config/application.rb
|
116
|
+
- test/dummy/config/boot.rb
|
117
|
+
- test/dummy/config/environment.rb
|
118
|
+
- test/dummy/config/initializers/secret_token.rb
|
119
|
+
- test/dummy/config/routes.rb
|
120
|
+
- test/dummy/config.ru
|
121
|
+
- test/font_awesome_rails_test.rb
|
122
|
+
- test/icon_helper_test.rb
|
123
|
+
- test/test_helper.rb
|