fa_rails 0.1.29 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/fa_rails.gemspec +2 -2
- data/lib/fa/base.rb +4 -2
- data/spec/lib/fa_spec.rb +39 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e861445b4047bffc1047326c7fc2b62a8ffffdbb8fba0e391cd47ec53750d9f
|
4
|
+
data.tar.gz: f619fb7fedceaa6db642149f22fde4b392c359df3ec0372370177f48abf1582a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21c8c9a644c8ab06f5528af26f8926030d421834d4d4bc0470257ad0e4d3f2388f4e72bc6c04af54edf3d982e4fa608a89585adc7e85c4715b0bfc37f68bf37c
|
7
|
+
data.tar.gz: be852be38fd50e7685c993cc27b34d2c2b9ae257173b52b44dc9f2dced1595e507fde32899d44cb138ce2abba2f3a4e06a67167801578d37c146f673b2c1173e
|
data/Gemfile.lock
CHANGED
data/fa_rails.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'fa_rails'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2023-03-
|
3
|
+
s.version = '0.1.30'
|
4
|
+
s.date = '2023-03-28'
|
5
5
|
s.summary = 'FontAwesome helper for Rails'
|
6
6
|
s.description = 'A helper module for using FontAwesome icons in Rails.'
|
7
7
|
s.homepage = 'http://rubygems.org/gems/fa_rails'
|
data/lib/fa/base.rb
CHANGED
@@ -51,7 +51,7 @@ module FA
|
|
51
51
|
|
52
52
|
@classes << "fa-#{name}"
|
53
53
|
@classes << "fa-#{options[:size]}x"
|
54
|
-
css = @classes.flatten.join(' ')
|
54
|
+
css = @classes.flatten.join(' ').sub(/\A\s+/, '')
|
55
55
|
transforms = @transforms.join(' ')
|
56
56
|
|
57
57
|
"<i class='#{css}' style='#{@styles}' data-fa-transform='#{transforms}' " \
|
@@ -146,7 +146,9 @@ module FA
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def parse_style(options)
|
149
|
-
|
149
|
+
if options[:css].to_s =~ /\bfa[#{STYLES.values.uniq.join}][#{MODES.values.uniq.join}]?\b/
|
150
|
+
return # Don't overwrite a manual style [& mode] class
|
151
|
+
end
|
150
152
|
|
151
153
|
style = 'fa'
|
152
154
|
style += STYLES[options[:style]]
|
data/spec/lib/fa_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe FA do
|
6
6
|
describe 'link' do
|
7
|
-
it '
|
7
|
+
it 'generates the correct link tag' do
|
8
8
|
tag = FA::Link.new(version: 'v0.1.2', integrity: 'sha384-abc', pro: true)
|
9
9
|
expect(tag.safe).to eql(
|
10
10
|
'<link rel="stylesheet" ' \
|
@@ -13,14 +13,14 @@ RSpec.describe FA do
|
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
|
-
it '
|
16
|
+
it 'generates the correct kit link tag' do
|
17
17
|
tag = FA::Link.kit('abcdefg')
|
18
18
|
expect(tag).to eql(
|
19
19
|
"<script src=\"https://kit.fontawesome.com/abcdefg.js\"></script>"
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
|
-
it '
|
23
|
+
it 'raises an ArgumentError if not initialized correctly' do
|
24
24
|
expect { FA::Link.new(version: 'v0.0.0', pro: true) }.to raise_error(
|
25
25
|
ArgumentError, 'Must specify version and integrity or kit.'
|
26
26
|
)
|
@@ -28,56 +28,56 @@ RSpec.describe FA do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'icon' do
|
31
|
-
it '
|
31
|
+
it 'generates the correct icon from a string name' do
|
32
32
|
expect(FA::Icon.p('help')).to eql(
|
33
33
|
"<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
37
|
-
it '
|
37
|
+
it 'generates the correct icon from a symbol name' do
|
38
38
|
expect(FA::Icon.p(:help)).to eql(
|
39
39
|
"<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
40
40
|
)
|
41
41
|
end
|
42
42
|
|
43
|
-
it '
|
43
|
+
it 'generates the correct icon from a configuration hash' do
|
44
44
|
fa = { name: 'help', options: { style: :light, size: 2 } }
|
45
45
|
expect(FA::Icon.p(fa)).to eql(
|
46
46
|
"<i class='fal fa-help fa-2x' style='' data-fa-transform='' title=''></i>"
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
it '
|
50
|
+
it 'handles a string fa option' do
|
51
51
|
expect(FA::Icon.p(:help, fa: 'fw 2x')).to eql(
|
52
52
|
"<i class='fas fa-fw fa-2x fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
53
53
|
)
|
54
54
|
end
|
55
55
|
|
56
|
-
it '
|
56
|
+
it 'handles an array fa option' do
|
57
57
|
expect(FA::Icon.p(:help, fa: %i[fw 2x])).to eql(
|
58
58
|
"<i class='fas fa-fw fa-2x fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
59
59
|
)
|
60
60
|
end
|
61
61
|
|
62
|
-
it '
|
62
|
+
it 'handles a string css option' do
|
63
63
|
expect(FA::Icon.p(:help, css: 'green big')).to eql(
|
64
64
|
"<i class='fas green big fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
65
65
|
)
|
66
66
|
end
|
67
67
|
|
68
|
-
it '
|
68
|
+
it 'handles an array css option' do
|
69
69
|
expect(FA::Icon.p(:help, css: %i[green big])).to eql(
|
70
70
|
"<i class='fas green big fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
71
71
|
)
|
72
72
|
end
|
73
73
|
|
74
|
-
it '
|
74
|
+
it 'handles a nil css option' do
|
75
75
|
expect(FA::Icon.p(:help, css: nil)).to eql(
|
76
76
|
"<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
77
77
|
)
|
78
78
|
end
|
79
79
|
|
80
|
-
it '
|
80
|
+
it 'raises ArgumentError for other input types' do
|
81
81
|
[nil, [], 0].each do |fa|
|
82
82
|
expect { FA::Icon.p(fa) }.to raise_error(
|
83
83
|
ArgumentError, 'Unexpected argument type.'
|
@@ -85,7 +85,13 @@ RSpec.describe FA do
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
it '
|
88
|
+
it 'generates the correct icon with a manual style class' do
|
89
|
+
expect(FA::Icon.p(:help, style: :solid, css: 'fad')).to eql(
|
90
|
+
"<i class='fad fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'generates the correct brand icon' do
|
89
95
|
expect(FA::Icon.p(:github, style: :brands)).to eql(
|
90
96
|
"<i class='fab fa-github fa-1x' style='' data-fa-transform='' title=''></i>"
|
91
97
|
)
|
@@ -97,7 +103,19 @@ RSpec.describe FA do
|
|
97
103
|
)
|
98
104
|
end
|
99
105
|
|
100
|
-
it '
|
106
|
+
it 'generates the correct sharp regular icon' do
|
107
|
+
expect(FA::Icon.p(:house, style: :regular, mode: :sharp)).to eql(
|
108
|
+
"<i class='fars fa-house fa-1x' style='' data-fa-transform='' title=''></i>"
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'generates the correct sharp light icon' do
|
113
|
+
expect(FA::Icon.p(:house, style: :light, mode: :sharp)).to eql(
|
114
|
+
"<i class='fals fa-house fa-1x' style='' data-fa-transform='' title=''></i>"
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'generates the correct icon with styles' do
|
101
119
|
expect(
|
102
120
|
FA::Icon.p(
|
103
121
|
'fire-alt', style: :duotone, fa_styles: {
|
@@ -112,7 +130,7 @@ RSpec.describe FA do
|
|
112
130
|
end
|
113
131
|
|
114
132
|
describe 'layer' do
|
115
|
-
it '
|
133
|
+
it 'generates the correct layer from string or symbol names' do
|
116
134
|
icons = [
|
117
135
|
{ name: :square },
|
118
136
|
{ name: :circle, options: { grow: 1 } },
|
@@ -128,7 +146,7 @@ RSpec.describe FA do
|
|
128
146
|
)
|
129
147
|
end
|
130
148
|
|
131
|
-
it '
|
149
|
+
it 'generates the correct layer with a span' do
|
132
150
|
icons = [
|
133
151
|
{ name: :square },
|
134
152
|
{ name: :counter, text: 17, options: { position: :tl } }
|
@@ -142,7 +160,7 @@ RSpec.describe FA do
|
|
142
160
|
)
|
143
161
|
end
|
144
162
|
|
145
|
-
it '
|
163
|
+
it 'applies layer titles to all icons' do
|
146
164
|
icons = [
|
147
165
|
{ name: :square, title: 'wrong 1' },
|
148
166
|
{ name: :exclamation, title: 'wrong 2' }
|
@@ -158,7 +176,7 @@ RSpec.describe FA do
|
|
158
176
|
end
|
159
177
|
|
160
178
|
describe 'build' do
|
161
|
-
it '
|
179
|
+
it 'generates the correct layer' do
|
162
180
|
layer = FA::Build.p do |b|
|
163
181
|
b.icon('circle')
|
164
182
|
b.span('counter', 7)
|
@@ -174,13 +192,13 @@ RSpec.describe FA do
|
|
174
192
|
end
|
175
193
|
|
176
194
|
describe 'span' do
|
177
|
-
it '
|
195
|
+
it 'generates the correct span from a string or symbol type' do
|
178
196
|
expect(FA::Span.p(:text, 'Hello')).to eql(
|
179
197
|
"<span class='fa-layers-text ' style='' data-fa-transform=''>Hello</span>"
|
180
198
|
)
|
181
199
|
end
|
182
200
|
|
183
|
-
it '
|
201
|
+
it 'generates the correct span from a configuration hash' do
|
184
202
|
span = { type: :text, text: 'World', options: { position: :bl } }
|
185
203
|
expect(FA::Span.p(span)).to eql(
|
186
204
|
"<span class='fa-layers-text fa-layers-bottom-left' " \
|
@@ -188,7 +206,7 @@ RSpec.describe FA do
|
|
188
206
|
)
|
189
207
|
end
|
190
208
|
|
191
|
-
it '
|
209
|
+
it 'raises ArgumentError for other input types' do
|
192
210
|
[nil, [], 0].each do |fa|
|
193
211
|
expect { FA::Span.p(fa) }.to raise_error(
|
194
212
|
ArgumentError, 'Unexpected argument type.'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fa_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|