material_icons 2.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,13 +84,7 @@ 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
 
@@ -92,15 +105,7 @@ class MaterialIcon
92
105
  end
93
106
 
94
107
  #
95
- # Check based on rails config if the selected mode is unicode
96
- #
97
- def unicode?
98
- MaterialIcons.unicode
99
- end
100
-
101
- #
102
- # Create the HTML code for the icon. This method check if selected mode is
103
- # unicode or ligatures.
108
+ # Create the HTML code for the icon
104
109
  #
105
110
  # == Returns:
106
111
  # Safe string
@@ -110,35 +115,24 @@ class MaterialIcon
110
115
  @html = @html.nil? || !@html.is_a?(Hash) ? {} : @html
111
116
 
112
117
  # Create the icon
113
- if unicode?
114
- content_tag(:i, '',
115
- @html.merge(
116
- style: @style,
117
- class: "material-icons #{@icon}#{@size}#{@rotation}#{@css_class}"))
118
- else
119
- content_tag(:i, "#{@icon}",
120
- @html.merge(
121
- style: @style,
122
- class: "material-icons#{@size}#{@rotation}#{@css_class}"))
123
- end
118
+ content_tag(:i, "#{@icon}",
119
+ @html.merge(
120
+ style: @style,
121
+ class: "material-icons#{@size}#{@rotation}#{@css_class}"))
124
122
  end
125
123
 
126
- 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
127
127
 
128
128
  #
129
- # Convert icon names that start with a number to the correct format. On
130
- # Material Design Icons version 2.0.0, unique conflict is the 3d-rotation
131
- # icon
132
- #
133
- # == Parameters:
134
- # icon:
135
- # String with the name of the 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
136
131
  #
137
- # == Returns:
138
- # An string with filtered name of the icon
132
+ # == Returns
133
+ # Nil
139
134
  #
140
- def clear_icon(icon)
141
- return icon if unicode? || icon != :three_d_rotation
142
- '3d_rotation'
135
+ def to_ary
136
+ nil
143
137
  end
144
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.0'
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.0
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: 2016-03-18 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
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '4.2'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '4.2'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: sqlite3
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +80,6 @@ dependencies:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: 2.4.4
97
- - !ruby/object:Gem::Dependency
98
- name: coveralls
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.8.2
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.8.2
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: pry
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -137,8 +109,8 @@ dependencies:
137
109
  - !ruby/object:Gem::Version
138
110
  version: 0.2.4
139
111
  description: Add Google Material Icons in your Rails projects easily. It is a library
140
- with +750 icons ;)
141
- email: angel@laux.es
112
+ with +2500 icons ;)
113
+ email: hi@angel.kiwi
142
114
  executables: []
143
115
  extensions: []
144
116
  extra_rdoc_files: []
@@ -146,22 +118,31 @@ files:
146
118
  - LICENSE
147
119
  - LICENSE_OF_FONTS
148
120
  - README.md
149
- - Rakefile
150
- - app/assets/fonts/MaterialIcons-Regular.eot
151
- - app/assets/fonts/MaterialIcons-Regular.ttf
152
- - app/assets/fonts/MaterialIcons-Regular.woff
153
- - 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
154
131
  - app/assets/stylesheets/material_icons.css.erb
155
- - 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
156
137
  - app/helpers/material_icons/material_icon_helper.rb
157
138
  - app/models/material_icon.rb
158
139
  - lib/material_icons.rb
159
140
  - lib/material_icons/engine.rb
160
141
  - lib/material_icons/version.rb
161
- homepage: http://irb.rocks
142
+ homepage: https://github.com/Angelmmiguel/material_icons
162
143
  licenses:
163
144
  - MIT
164
- - Creative Common Attribution 4.0 International License
145
+ - Apache-2.0
165
146
  metadata: {}
166
147
  post_install_message:
167
148
  rdoc_options: []
@@ -178,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
159
  - !ruby/object:Gem::Version
179
160
  version: '0'
180
161
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.5.1
162
+ rubygems_version: 3.3.26
183
163
  signing_key:
184
164
  specification_version: 4
185
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