fa_rails 0.1.29 → 0.1.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 066ee0296fe9eddacfb54f58f2425661b2be548b0590ad04523089d6f61d0a25
4
- data.tar.gz: 9730e00557d1ae282e262fd7067b99e9d667f2308b7aab2984d2390fa68d6f3c
3
+ metadata.gz: 5e75c0e9608f41e199502dd2feb1157b8f1fb2e83c6fef273d9655b267e7c0a1
4
+ data.tar.gz: 421e5312e5988e3fa5039c5269b37259f21a2e60b06bc28d1b3de910b4e1e0c6
5
5
  SHA512:
6
- metadata.gz: e0081789f2c062f2aae50d568f58cf8d11e5cd4b17954ca47cf27c6a1608119a543fd562e6b616677b16d5c98b97066bbabe0555b4d1588afb12f34077ad6cb7
7
- data.tar.gz: 04c3fa02408f7e88c98973e75765a28668b302afc1e69909a647c677f26d408c5c558d27a208d1a9f18b88fcf0cb69c08658c316c6826e73cabfcfad27bf0209
6
+ metadata.gz: b57d25bacf152ba1651c70d224c9cce0dd19ece29226572783c31a4ebab2bce3b97d7ff864a000fcd71f4d674dd601bf1578e3eee4ce77a5c75514e04d5fd8ee
7
+ data.tar.gz: fc339b05b167b9a35f73006495b4458dd8458a263e93d48d987a1fe59c2028581966794cf2e8cc89b90095b52ae6b060ee2106ef1a8193545092ac0f30fa219f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fa_rails (0.1.29)
4
+ fa_rails (0.1.31)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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.29'
4
- s.date = '2023-03-13'
3
+ s.version = '0.1.31'
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,11 +146,13 @@ module FA
146
146
  end
147
147
 
148
148
  def parse_style(options)
149
- return if options[:css].to_s.match?(/\bfa[#{STYLES.values.join}]\b/)
149
+ if options[:css].to_s =~ /\bfa[#{MODES.values.uniq.join}]?[#{STYLES.values.uniq.join}]\b/
150
+ return # Don't overwrite a manual style [& mode] class
151
+ end
150
152
 
151
153
  style = 'fa'
152
- style += STYLES[options[:style]]
153
154
  style += MODES[options[:mode]]
155
+ style += STYLES[options[:style]]
154
156
  end
155
157
  end
156
158
  end
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 'should generate the correct link tag' do
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 'should generate the correct kit link tag' do
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 'should raise an ArgumentError if not initialized correctly' do
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 'should generate the correct icon from a string name' do
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 'should generate the correct icon from a symbol name' do
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 'should generate the correct icon from a configuration hash' do
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 'should correctly handle a string fa option' do
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 'should correctly handle an array fa option' do
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 'should correctly handle a string css option' do
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 'should correctly handle an array css option' do
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 'should correctly handle a nil css option' do
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 'should raise ArgumentError for other input types' do
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 'should generate the correct brand icon' do
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 'should generate the correct icon with styles' do
106
+ it 'generates the correct sharp regular icon' do
107
+ expect(FA::Icon.p(:house, style: :regular, mode: :sharp)).to eql(
108
+ "<i class='fasr 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='fasl 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 'should generate the correct layer from string or symbol names' do
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 'should generate the correct layer with a span' do
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 'should apply layer titles to all icons' do
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 'should generate the correct layer' do
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 'should generate the correct span from a string or symbol type' do
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 'should generate the correct span from a configuration hash' do
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 'should raise ArgumentError for other input types' do
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.29
4
+ version: 0.1.31
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-13 00:00:00.000000000 Z
11
+ date: 2023-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake