rails_material_design_icons 0.6.0

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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +33 -0
  3. data/.gitignore +11 -0
  4. data/CHANGELOG.md +16 -0
  5. data/FONT_LICENSE +20 -0
  6. data/Gemfile +11 -0
  7. data/Gemfile.lock +123 -0
  8. data/Guardfile +11 -0
  9. data/LICENSE +22 -0
  10. data/README.md +105 -0
  11. data/Rakefile +14 -0
  12. data/app/assets/fonts/materialdesignicons-webfont.eot +0 -0
  13. data/app/assets/fonts/materialdesignicons-webfont.ttf +0 -0
  14. data/app/assets/fonts/materialdesignicons-webfont.woff +0 -0
  15. data/app/assets/fonts/materialdesignicons-webfont.woff2 +0 -0
  16. data/app/assets/stylesheets/materialdesignicons.css.erb +24096 -0
  17. data/gemfiles/rails-4.2.gemfile +7 -0
  18. data/gemfiles/rails-5.2.gemfile +6 -0
  19. data/gemfiles/rails-6.0.gemfile +6 -0
  20. data/gemfiles/rails-6.1.gemfile +6 -0
  21. data/gemfiles/rails-master.gemfile +7 -0
  22. data/gemfiles/sprockets-backport.gemfile +15 -0
  23. data/lib/rails_material_design_icons/engine.rb +17 -0
  24. data/lib/rails_material_design_icons/icon_helper.rb +44 -0
  25. data/lib/rails_material_design_icons/railtie.rb +14 -0
  26. data/lib/rails_material_design_icons/version.rb +8 -0
  27. data/lib/rails_material_design_icons.rb +5 -0
  28. data/rails_material_design_icons.gemspec +27 -0
  29. data/test/dummy/.gitignore +2 -0
  30. data/test/dummy/app/assets/config/manifest.js +3 -0
  31. data/test/dummy/app/assets/stylesheets/sass-import.css.sass +1 -0
  32. data/test/dummy/app/assets/stylesheets/scss-import.css.scss +1 -0
  33. data/test/dummy/app/assets/stylesheets/sprockets-require.css +3 -0
  34. data/test/dummy/app/controllers/pages_controller.rb +4 -0
  35. data/test/dummy/app/views/pages/icons.html.erb +1 -0
  36. data/test/dummy/config/application.rb +25 -0
  37. data/test/dummy/config/boot.rb +12 -0
  38. data/test/dummy/config/environment.rb +7 -0
  39. data/test/dummy/config/initializers/secret_token.rb +23 -0
  40. data/test/dummy/config/routes.rb +5 -0
  41. data/test/dummy/config.ru +6 -0
  42. data/test/icon_helper_test.rb +29 -0
  43. data/test/material_design_icons_test.rb +68 -0
  44. data/test/test_helper.rb +9 -0
  45. metadata +150 -0
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '../'
6
+ gem 'railties', '~> 4.2.0'
7
+ gem 'sass-rails', '~> 5.0.0'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '../'
6
+ gem 'railties', '~> 5.2.0'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '../'
6
+ gem 'railties', '~> 6.0.0'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '../'
6
+ gem 'railties', '~> 6.1.0'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec path: '../'
6
+ gem 'railties', github: 'rails/rails'
7
+ gem 'sass-rails', github: 'rails/sass-rails'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # See:
6
+ # http://blog.logdown.com/posts/171593-using-rails-4-asset-pipeline-on-rails-3-for-faster-deploy
7
+ # https://github.com/rails/sprockets-rails/issues/98
8
+ # https://discussion.heroku.com/t/using-the-rails-4-asset-pipeline-in-rails-3-apps-for-faster-deploys/205
9
+
10
+ gemspec path: '../'
11
+ gem 'railties', github: 'rails/rails', branch: '3-2-stable'
12
+ gem 'sass-rails', github: 'guilleiguaran/sass-rails', branch: 'backport'
13
+ gem 'sprockets', '2.2.2.backport2'
14
+ gem 'sprockets-rails', '2.0.0.backport1'
15
+ gem 'tzinfo'
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MaterialDesignIcons
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ initializer 'material_design_icons.assets.precompile', group: :all do |app|
7
+ %w(stylesheets fonts images).each do |sub|
8
+ app.config.assets.paths << root.join('assets', sub).to_s
9
+ end
10
+
11
+ %w(eot ttf woff woff2).each do |ext|
12
+ app.config.assets.precompile << "materialdesignicons-webfont.#{ext}"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MaterialDesignIcons
4
+ module IconHelper
5
+ # Creates an icon tag given an icon name and possible icon
6
+ # modifiers.
7
+ #
8
+ # Examples
9
+ #
10
+ # mdi_icon "sheep"
11
+ # # => <i class="mdi md-sheep"></i>
12
+ #
13
+ def mdi_icon(names = 'sheep', original_options = {})
14
+ options = original_options.deep_dup
15
+ classes = ['mdi']
16
+ classes.concat Private.icon_names(names)
17
+ classes.concat Array(options.delete(:class))
18
+ text = options.delete(:text)
19
+ right_icon = options.delete(:right)
20
+ icon = content_tag(:i, nil, options.merge(class: classes))
21
+ Private.icon_join(icon, text, right_icon)
22
+ end
23
+
24
+ module Private
25
+ extend ActionView::Helpers::OutputSafetyHelper
26
+
27
+ def self.icon_join(icon, text, reverse_order = false)
28
+ return icon if text.blank?
29
+
30
+ elements = [icon, ERB::Util.html_escape(text)]
31
+ elements.reverse! if reverse_order
32
+ safe_join(elements, ' ')
33
+ end
34
+
35
+ def self.icon_names(names = [])
36
+ array_value(names).map { |n| "mdi-#{n}" }
37
+ end
38
+
39
+ def self.array_value(value = [])
40
+ value.is_a?(Array) ? value : value.to_s.split(/\s+/)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_material_design_icons/icon_helper'
4
+
5
+ module MaterialDesignIcons
6
+ module Rails
7
+ # Initialize!
8
+ class Railtie < ::Rails::Railtie
9
+ initializer 'rails_material_design_icons.icon_helper' do
10
+ ActiveSupport.on_load(:action_view) { include MaterialDesignIcons::IconHelper }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MaterialDesignIcons
4
+ module Rails
5
+ VERSION = '0.6.0'
6
+ MATERIAL_DESIGN_ICON_VERSION = '5.4.55'
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_material_design_icons/version'
4
+ require 'rails_material_design_icons/railtie' if defined?(Rails)
5
+ require 'rails_material_design_icons/engine' if defined?(::Rails)
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/rails_material_design_icons/version', __dir__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.authors = ['sampokuokkanen']
7
+ gem.email = ['sampo.kuokkanen@gmail.com']
8
+ gem.description = 'Rails Material Design Icons provides the web fonts and stylesheets as a Rails engine for use with the asset pipeline.'
9
+ gem.summary = 'an asset gemification of the Material Icons font library'
10
+ gem.homepage = 'https://github.com/sampokuokkanen/rails_material_design_icons'
11
+ gem.licenses = ['MIT', 'Apache 2.0']
12
+
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.test_files = `git ls-files -- {test,spec}/*`.split("\n")
15
+ gem.name = 'rails_material_design_icons'
16
+
17
+ gem.require_paths = ['lib']
18
+ gem.version = MaterialDesignIcons::Rails::VERSION
19
+
20
+ gem.add_dependency 'railties', '>= 3.2', '< 7'
21
+
22
+ gem.add_development_dependency 'activesupport'
23
+ gem.add_development_dependency 'byebug'
24
+ gem.add_development_dependency 'sassc-rails'
25
+
26
+ gem.required_ruby_version = '>= 1.9.3'
27
+ end
@@ -0,0 +1,2 @@
1
+ /log
2
+ /tmp
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -0,0 +1 @@
1
+ @import materialdesignicons
@@ -0,0 +1 @@
1
+ @import "materialdesignicons";
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require materialdesignicons
3
+ */
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PagesController < ActionController::Base
4
+ end
@@ -0,0 +1 @@
1
+ <%= mdi_icon "sheep" %>
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('boot', __dir__)
4
+
5
+ # require "rails/all"
6
+ require 'sprockets/railtie'
7
+
8
+ Bundler.require(:default, :development)
9
+
10
+ module Dummy
11
+ class Application < Rails::Application
12
+ config.encoding = 'utf-8'
13
+ config.assets.enabled = true
14
+ config.assets.version = '1.0'
15
+
16
+ # replacement for environments/*.rb
17
+ config.active_support.deprecation = :stderr
18
+ config.eager_load = false
19
+ config.active_support.test_order = begin
20
+ :random
21
+ rescue StandardError
22
+ nil
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ gemfile = File.expand_path('../../../Gemfile', __dir__)
5
+
6
+ if File.exist?(gemfile)
7
+ ENV['BUNDLE_GEMFILE'] = gemfile
8
+ require 'bundler'
9
+ Bundler.setup
10
+ end
11
+
12
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the rails application
4
+ require File.expand_path('application', __dir__)
5
+
6
+ # Initialize the rails application
7
+ Dummy::Application.initialize!
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Be sure to restart your server when you modify this file.
4
+
5
+ # Your secret key for verifying the integrity of signed cookies.
6
+ # If you change this key, all old signed cookies will become invalid!
7
+ # Make sure the secret is at least 30 characters and all random,
8
+ # no regular words or you'll be exposed to dictionary attacks.
9
+ #
10
+ # avoid deprecation warnings if building against older versions of Rails
11
+
12
+ # secret_token migrated to secret_key_base in Rails 4
13
+ SKB_VERSION = Gem::Version.new('4.0.0')
14
+
15
+ # Get the current Rails version.
16
+ RAILS_VERSION = Rails.respond_to?(:version) ? Gem::Version.new(Rails.version) : Gem::Version.new('3.22')
17
+
18
+ # if we're running an old version of Rails
19
+ if RAILS_VERSION < SKB_VERSION
20
+ Dummy::Application.config.secret_token = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
21
+ elsif Dummy::Application.config.respond_to?(:secret_key_base)
22
+ Dummy::Application.config.secret_key_base = 'deadbeef'
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dummy::Application.routes.draw do
4
+ get '/icons', to: 'pages#icons'
5
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require ::File.expand_path('config/environment', __dir__)
6
+ run Dummy::Application
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module MaterialDesignIcons
6
+ class IconHelperTest < ActionView::TestCase
7
+ test '#md_icon with no args should render a sheep icon' do
8
+ assert_icon i('mdi mdi-sheep')
9
+ end
10
+
11
+ test '#md_icon should render different individual icons' do
12
+ assert_icon i('mdi mdi-flag'), 'flag'
13
+ assert_icon i('mdi mdi-camera-retro'), 'camera-retro'
14
+ assert_icon i('mdi mdi-cog'), 'cog'
15
+ assert_icon i('mdi mdi-github'), 'github'
16
+ end
17
+
18
+ private
19
+
20
+ def assert_icon(expected, *args)
21
+ message = "`mdi_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
22
+ assert_dom_equal expected, mdi_icon(*args), message
23
+ end
24
+
25
+ def i(classes)
26
+ %(<i class="#{classes}"></i>)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class MaterialDesignIconsTest < ActionDispatch::IntegrationTest
6
+ teardown { clean_sprockets_cache }
7
+
8
+ test 'engine is loaded' do
9
+ assert_equal ::Rails::Engine, MaterialDesignIcons::Rails::Engine.superclass
10
+ end
11
+
12
+ test 'fonts are served' do
13
+ get '/assets/materialdesignicons-webfont.eot'
14
+ assert_response :success
15
+ get '/assets/materialdesignicons-webfont.woff2'
16
+ assert_response :success
17
+ get '/assets/materialdesignicons-webfont.woff'
18
+ assert_response :success
19
+ get '/assets/materialdesignicons-webfont.ttf'
20
+ assert_response :success
21
+ end
22
+
23
+ test 'stylesheets are served' do
24
+ get '/assets/materialdesignicons.css'
25
+ assert_material_icons(response)
26
+ end
27
+
28
+ test 'stylesheets contain asset pipeline references to fonts' do
29
+ get '/assets/materialdesignicons.css'
30
+ assert_match %r{/assets/materialdesignicons-webfont(-\w+)?\.eot}, response.body
31
+ assert_match %r{/assets/materialdesignicons-webfont(-\w+)?\.eot\?#iefix}, response.body
32
+ assert_match %r{/assets/materialdesignicons-webfont(-\w+)?\.woff2}, response.body
33
+ assert_match %r{/assets/materialdesignicons-webfont(-\w+)?\.woff}, response.body
34
+ assert_match %r{/assets/materialdesignicons-webfont(-\w+)?\.ttf}, response.body
35
+ end
36
+
37
+ test 'stylesheet is available in a css sprockets require' do
38
+ get '/assets/sprockets-require.css'
39
+ assert_material_icons(response)
40
+ end
41
+
42
+ test 'stylesheet is available in a sass import' do
43
+ get '/assets/sass-import.css'
44
+ assert_material_icons(response)
45
+ end
46
+
47
+ test 'stylesheet is available in a scss import' do
48
+ get '/assets/scss-import.css'
49
+ assert_material_icons(response)
50
+ end
51
+
52
+ test 'helpers should be available in the view' do
53
+ get '/icons'
54
+ assert_response :success
55
+ assert_select 'i.mdi.mdi-sheep'
56
+ end
57
+
58
+ private
59
+
60
+ def clean_sprockets_cache
61
+ FileUtils.rm_rf File.expand_path('dummy/tmp', __dir__)
62
+ end
63
+
64
+ def assert_material_icons(response)
65
+ assert_response :success
66
+ assert_match(/font-family:\s*"Material Design Icons";/, response.body)
67
+ end
68
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configure Rails Environment
4
+ ENV['RAILS_ENV'] = 'test'
5
+
6
+ require File.expand_path('dummy/config/environment.rb', __dir__)
7
+ require 'rails/test_help'
8
+
9
+ Rails.backtrace_cleaner.remove_silencers!
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_material_design_icons
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: ruby
6
+ authors:
7
+ - sampokuokkanen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-14 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: '7'
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: '7'
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
+ - !ruby/object:Gem::Dependency
48
+ name: byebug
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: sassc-rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: Rails Material Design Icons provides the web fonts and stylesheets as
76
+ a Rails engine for use with the asset pipeline.
77
+ email:
78
+ - sampo.kuokkanen@gmail.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - ".github/workflows/main.yml"
84
+ - ".gitignore"
85
+ - CHANGELOG.md
86
+ - FONT_LICENSE
87
+ - Gemfile
88
+ - Gemfile.lock
89
+ - Guardfile
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - app/assets/fonts/materialdesignicons-webfont.eot
94
+ - app/assets/fonts/materialdesignicons-webfont.ttf
95
+ - app/assets/fonts/materialdesignicons-webfont.woff
96
+ - app/assets/fonts/materialdesignicons-webfont.woff2
97
+ - app/assets/stylesheets/materialdesignicons.css.erb
98
+ - gemfiles/rails-4.2.gemfile
99
+ - gemfiles/rails-5.2.gemfile
100
+ - gemfiles/rails-6.0.gemfile
101
+ - gemfiles/rails-6.1.gemfile
102
+ - gemfiles/rails-master.gemfile
103
+ - gemfiles/sprockets-backport.gemfile
104
+ - lib/rails_material_design_icons.rb
105
+ - lib/rails_material_design_icons/engine.rb
106
+ - lib/rails_material_design_icons/icon_helper.rb
107
+ - lib/rails_material_design_icons/railtie.rb
108
+ - lib/rails_material_design_icons/version.rb
109
+ - rails_material_design_icons.gemspec
110
+ - test/dummy/.gitignore
111
+ - test/dummy/app/assets/config/manifest.js
112
+ - test/dummy/app/assets/stylesheets/sass-import.css.sass
113
+ - test/dummy/app/assets/stylesheets/scss-import.css.scss
114
+ - test/dummy/app/assets/stylesheets/sprockets-require.css
115
+ - test/dummy/app/controllers/pages_controller.rb
116
+ - test/dummy/app/views/pages/icons.html.erb
117
+ - test/dummy/config.ru
118
+ - test/dummy/config/application.rb
119
+ - test/dummy/config/boot.rb
120
+ - test/dummy/config/environment.rb
121
+ - test/dummy/config/initializers/secret_token.rb
122
+ - test/dummy/config/routes.rb
123
+ - test/icon_helper_test.rb
124
+ - test/material_design_icons_test.rb
125
+ - test/test_helper.rb
126
+ homepage: https://github.com/sampokuokkanen/rails_material_design_icons
127
+ licenses:
128
+ - MIT
129
+ - Apache 2.0
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 1.9.3
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubygems_version: 3.1.4
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: an asset gemification of the Material Icons font library
150
+ test_files: []