material_icons 2.2.1 → 4.0.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.
@@ -5,12 +5,6 @@ class MaterialIcon
5
5
  # To use content_tag
6
6
  include ActionView::Helpers::TagHelper
7
7
 
8
- # Undefined method will ref to the icon.
9
- def method_missing(name)
10
- @icon = clear_icon(name)
11
- self
12
- end
13
-
14
8
  #
15
9
  # Reset will set all variables to nil
16
10
  #
@@ -19,6 +13,16 @@ class MaterialIcon
19
13
  self
20
14
  end
21
15
 
16
+ #
17
+ # Define shape style methods
18
+ #
19
+ %w(outlined round sharp twotone).each do |shape_style|
20
+ define_method(shape_style) do
21
+ css_class(shape_style)
22
+ self
23
+ end
24
+ end
25
+
22
26
  #
23
27
  # Define rotate methods
24
28
  #
@@ -39,6 +43,21 @@ class MaterialIcon
39
43
  end
40
44
  end
41
45
 
46
+ #
47
+ # Set the shape of the icon you want to use
48
+ #
49
+ # == Paremeters:
50
+ # name::
51
+ # String or symbol with icon name
52
+ #
53
+ # == Returns:
54
+ # MaterialIcon instance
55
+ #
56
+ def shape(name)
57
+ @icon = name.to_s
58
+ self
59
+ end
60
+
42
61
  #
43
62
  # Add a CSS class to :i tag
44
63
  #
@@ -65,42 +84,10 @@ class MaterialIcon
65
84
  # MaterialIcon instance
66
85
  #
67
86
  def style(css_style = '')
68
- if css_style && css_style.empty?
69
- # It references style icon
70
- @icon = clear_icon('style')
71
- else
72
- # User wants to apply a style to the icon
73
- @style = css_style
74
- end
87
+ @style = css_style
75
88
  self
76
89
  end
77
90
 
78
- # Create an alias to use the original method
79
- alias_method :super_send, :send
80
-
81
- #
82
- # Override send functionality to set the name of the icon to "send" when
83
- # the method doesn't receive any parameters
84
- #
85
- # == Paremeters:
86
- # name::
87
- # Name of the method to call
88
- # args::
89
- # Arguments to send the method
90
- #
91
- # == Returns:
92
- # MaterialIcon instance or the result of the method call
93
- #
94
- def send(name = '', *args)
95
- if name && name.empty?
96
- @icon = clear_icon('send')
97
- # Return self
98
- self
99
- else
100
- super_send(name.to_sym, *args)
101
- end
102
- end
103
-
104
91
  #
105
92
  # Add HTML options to :i tag.
106
93
  #
@@ -118,15 +105,7 @@ class MaterialIcon
118
105
  end
119
106
 
120
107
  #
121
- # Check based on rails config if the selected mode is unicode
122
- #
123
- def unicode?
124
- MaterialIcons.unicode
125
- end
126
-
127
- #
128
- # Create the HTML code for the icon. This method check if selected mode is
129
- # unicode or ligatures.
108
+ # Create the HTML code for the icon
130
109
  #
131
110
  # == Returns:
132
111
  # Safe string
@@ -136,35 +115,24 @@ class MaterialIcon
136
115
  @html = @html.nil? || !@html.is_a?(Hash) ? {} : @html
137
116
 
138
117
  # Create the icon
139
- if unicode?
140
- content_tag(:i, '',
141
- @html.merge(
142
- style: @style,
143
- class: "material-icons #{@icon}#{@size}#{@rotation}#{@css_class}"))
144
- else
145
- content_tag(:i, "#{@icon}",
146
- @html.merge(
147
- style: @style,
148
- class: "material-icons#{@size}#{@rotation}#{@css_class}"))
149
- end
118
+ content_tag(:i, "#{@icon}",
119
+ @html.merge(
120
+ style: @style,
121
+ class: "material-icons#{@size}#{@rotation}#{@css_class}"))
150
122
  end
151
123
 
152
- private
124
+ # Fix #13. Some Rails methods uses to_str instead of to_s. In this case, to_str is handled
125
+ # by method_missing so it's returning the same instance and the method are failing
126
+ alias_method :to_str, :to_s
153
127
 
154
128
  #
155
- # Convert icon names that start with a number to the correct format. On
156
- # Material Design Icons version 2.0.0, unique conflict is the 3d-rotation
157
- # icon
129
+ # Some methods require to_ary to be defined. We return nil in this method to avoid this class
130
+ # to be threated as an Array
158
131
  #
159
- # == Parameters:
160
- # icon:
161
- # String with the name of the icon
162
- #
163
- # == Returns:
164
- # An string with filtered name of the icon
132
+ # == Returns
133
+ # Nil
165
134
  #
166
- def clear_icon(icon)
167
- return icon if unicode? || icon != :three_d_rotation
168
- '3d_rotation'
135
+ def to_ary
136
+ nil
169
137
  end
170
138
  end
@@ -3,6 +3,6 @@
3
3
  #
4
4
  module MaterialIcons
5
5
  # Version for the library and the gem
6
- MATERIAL_ICONS_VERSION = '2.2.2'
7
- VERSION = '2.2.1'
6
+ MATERIAL_ICONS_VERSION = '4.0.0'
7
+ VERSION = '4.0.0'
8
8
  end
@@ -1,17 +1,3 @@
1
1
  require 'material_icons/version'
2
2
  # Only require if rails is available
3
3
  require 'material_icons/engine' if defined?(::Rails)
4
-
5
- #
6
- # Base module. This module defines the configuration of the gem.
7
- #
8
- module MaterialIcons
9
- # Use unicode icons
10
- mattr_accessor :unicode
11
- @unicode = false
12
-
13
- # Use the config from an initializer
14
- def self.setup
15
- yield self
16
- end
17
- end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: material_icons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angel M Miguel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-27 00:00:00.000000000 Z
11
+ date: 2022-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.4.4
83
- - !ruby/object:Gem::Dependency
84
- name: coveralls
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.8.2
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.8.2
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: pry
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -123,8 +109,8 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: 0.2.4
125
111
  description: Add Google Material Icons in your Rails projects easily. It is a library
126
- with +900 icons ;)
127
- email: angel@laux.es
112
+ with +2500 icons ;)
113
+ email: hi@angel.kiwi
128
114
  executables: []
129
115
  extensions: []
130
116
  extra_rdoc_files: []
@@ -132,19 +118,28 @@ files:
132
118
  - LICENSE
133
119
  - LICENSE_OF_FONTS
134
120
  - README.md
135
- - Rakefile
136
- - app/assets/fonts/MaterialIcons-Regular.eot
137
- - app/assets/fonts/MaterialIcons-Regular.ttf
138
- - app/assets/fonts/MaterialIcons-Regular.woff
139
- - app/assets/fonts/MaterialIcons-Regular.woff2
121
+ - app/assets/fonts/material-icons-outlined.woff
122
+ - app/assets/fonts/material-icons-outlined.woff2
123
+ - app/assets/fonts/material-icons-regular.woff
124
+ - app/assets/fonts/material-icons-regular.woff2
125
+ - app/assets/fonts/material-icons-round.woff
126
+ - app/assets/fonts/material-icons-round.woff2
127
+ - app/assets/fonts/material-icons-sharp.woff
128
+ - app/assets/fonts/material-icons-sharp.woff2
129
+ - app/assets/fonts/material-icons-twotone.woff
130
+ - app/assets/fonts/material-icons-twotone.woff2
140
131
  - app/assets/stylesheets/material_icons.css.erb
141
- - app/assets/stylesheets/material_icons_unicode.css.erb
132
+ - app/assets/stylesheets/material_icons.helpers.css
133
+ - app/assets/stylesheets/material_icons.outlined.css.erb
134
+ - app/assets/stylesheets/material_icons.round.css.erb
135
+ - app/assets/stylesheets/material_icons.sharp.css.erb
136
+ - app/assets/stylesheets/material_icons.twotone.css.erb
142
137
  - app/helpers/material_icons/material_icon_helper.rb
143
138
  - app/models/material_icon.rb
144
139
  - lib/material_icons.rb
145
140
  - lib/material_icons/engine.rb
146
141
  - lib/material_icons/version.rb
147
- homepage: http://irb.rocks
142
+ homepage: https://github.com/Angelmmiguel/material_icons
148
143
  licenses:
149
144
  - MIT
150
145
  - Apache-2.0
@@ -164,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
159
  - !ruby/object:Gem::Version
165
160
  version: '0'
166
161
  requirements: []
167
- rubyforge_project:
168
- rubygems_version: 2.5.1
162
+ rubygems_version: 3.3.26
169
163
  signing_key:
170
164
  specification_version: 4
171
165
  summary: A simple Rails wrapper for Google Material Icons
data/Rakefile DELETED
@@ -1,38 +0,0 @@
1
- #!/usr/bin/env rake
2
-
3
- # Rake tasks
4
- namespace :material_icons do
5
- #
6
- # Get the CSS to use unicode instead of ligatures.
7
- #
8
- desc "Create the CSS Unicode classes"
9
- task :unicode_css do
10
- # Check codepoint file
11
- unless File.exist?('codepoints')
12
- puts 'Codepoints file is required to perform this operation.'
13
- puts 'Go to: https://github.com/google/material-design-icons and download it.'
14
- else
15
- # Destination file
16
- out = File.new("unicode.css", "w")
17
-
18
- # Load from codepoints
19
- File.readlines('codepoints').each do |line|
20
- el = line.split(' ')
21
- css_class = el.first
22
- # Fix for icons that start with number
23
- css_class = 'three_d_rotation' if css_class == '3d_rotation'
24
- unicode = el.last
25
- # Need this strange indentation for CSS...
26
- css =
27
- <<-FOO
28
- .material-icons.#{css_class}:before,
29
- .mi.#{css_class}:before {
30
- content: '\\#{unicode}';
31
- }
32
- FOO
33
- # Print in the file
34
- out.puts css
35
- end
36
- end
37
- end
38
- end