fa_rails 0.1.24 → 0.1.25
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/fa_rails.gemspec +2 -2
- data/lib/fa/base.rb +8 -3
- data/spec/lib/fa_spec.rb +30 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0166501def630ab5880108fdd887614849f6a2b77a23c1e042c98a459a0130
|
4
|
+
data.tar.gz: 8dcd8b62b61b8f0dfe9a323378ccab27547e627dbfa3c5a97643da2720dbb0ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a17c51cd3277b386aea9211cd8e6b4744778f5546ca75936b9bdb917e39413096c6e672a9ec42191dfc8aa8e4472083b6a7324be5410aa1d4bf6a4e8ed54024
|
7
|
+
data.tar.gz: 5ec4b0d9261b7313305f306340a2d8bb0b060072161c4ba95f35ee5bd9abe18726b755cd630d1f63c2d2a6ef472d6247ce7fcbd78e8ccb53b58423d8cf984277
|
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 = '2021-
|
3
|
+
s.version = '0.1.25'
|
4
|
+
s.date = '2021-04-03'
|
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
@@ -106,8 +106,13 @@ module FA
|
|
106
106
|
def parse_classes(options)
|
107
107
|
@classes = []
|
108
108
|
@classes << parse_style(options)
|
109
|
-
@classes << options[:fa]
|
110
|
-
@classes << options[:css]
|
109
|
+
@classes << format_classes(options[:fa], prefix: 'fa-')
|
110
|
+
@classes << format_classes(options[:css])
|
111
|
+
end
|
112
|
+
|
113
|
+
def format_classes(classes, prefix: nil)
|
114
|
+
classes = classes.split(' ') if classes.is_a?(String)
|
115
|
+
classes.map { |c| "#{prefix}#{c}" } if classes.is_a?(Array)
|
111
116
|
end
|
112
117
|
|
113
118
|
def merge_fa_styles(options)
|
@@ -135,7 +140,7 @@ module FA
|
|
135
140
|
end
|
136
141
|
|
137
142
|
def parse_style(options)
|
138
|
-
return if options[:css].to_s.match?(/fa[
|
143
|
+
return if options[:css].to_s.match?(/fa[srldbk]/)
|
139
144
|
return 'fas' unless STYLES.keys.include?(options[:style])
|
140
145
|
|
141
146
|
'fa' + STYLES[options[:style]]
|
data/spec/lib/fa_spec.rb
CHANGED
@@ -47,6 +47,36 @@ RSpec.describe FA do
|
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'should correctly handle a string fa option' do
|
51
|
+
expect(FA::Icon.p(:help, fa: 'fw 2x')).to eql(
|
52
|
+
"<i class='fas fa-fw fa-2x fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should correctly handle an array fa option' do
|
57
|
+
expect(FA::Icon.p(:help, fa: %i[fw 2x])).to eql(
|
58
|
+
"<i class='fas fa-fw fa-2x fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should correctly handle a string css option' do
|
63
|
+
expect(FA::Icon.p(:help, css: 'green big')).to eql(
|
64
|
+
"<i class='fas green big fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should correctly handle an array css option' do
|
69
|
+
expect(FA::Icon.p(:help, css: %i[green big])).to eql(
|
70
|
+
"<i class='fas green big fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should correctly handle a nil css option' do
|
75
|
+
expect(FA::Icon.p(:help, css: nil)).to eql(
|
76
|
+
"<i class='fas fa-help fa-1x' style='' data-fa-transform='' title=''></i>"
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
50
80
|
it 'should raise ArgumentError for other input types' do
|
51
81
|
[nil, [], 0].each do |fa|
|
52
82
|
expect { FA::Icon.p(fa) }.to raise_error(
|
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.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -114,7 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.7.6
|
118
119
|
signing_key:
|
119
120
|
specification_version: 4
|
120
121
|
summary: FontAwesome helper for Rails
|