fa_rails 0.1.24 → 0.1.25

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: 69c12667e2d247c861e7c71c731f6b8f32af38d347df7a923263ffba1d3c2cef
4
- data.tar.gz: a3b77f362a60c92ec5ef2184d1e8b46dbd9dd99dcd6c6cf7095bfc65bd3b3a14
3
+ metadata.gz: 2a0166501def630ab5880108fdd887614849f6a2b77a23c1e042c98a459a0130
4
+ data.tar.gz: 8dcd8b62b61b8f0dfe9a323378ccab27547e627dbfa3c5a97643da2720dbb0ab
5
5
  SHA512:
6
- metadata.gz: d275d6951f206dedc9a22589825a16063af2f68ca93b85a9b6264182885a3e04356bf7fed1e6677800d7a6137c4bf8c5d95cda9d5280f8591ebd99c2915a4539
7
- data.tar.gz: 20e364aa0cacf00c866c1a129bfb391407e55158564255ebc068bd558cc24d02ee1c7c7d3f3428c5a5016ed0719ef055da421d36408623a49109e0264a101e3e
6
+ metadata.gz: 5a17c51cd3277b386aea9211cd8e6b4744778f5546ca75936b9bdb917e39413096c6e672a9ec42191dfc8aa8e4472083b6a7324be5410aa1d4bf6a4e8ed54024
7
+ data.tar.gz: 5ec4b0d9261b7313305f306340a2d8bb0b060072161c4ba95f35ee5bd9abe18726b755cd630d1f63c2d2a6ef472d6247ce7fcbd78e8ccb53b58423d8cf984277
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fa_rails (0.1.24)
4
+ fa_rails (0.1.25)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.3)
10
10
  docile (1.3.1)
11
- json (2.1.0)
11
+ json (2.3.1)
12
12
  rake (12.3.3)
13
13
  rspec (3.7.0)
14
14
  rspec-core (~> 3.7.0)
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.24'
4
- s.date = '2021-02-14'
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].to_s.split(' ').map { |c| "fa-#{c}" }
110
- @classes << options[:css].to_s.split(' ')
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[srldb]/)
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.24
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-02-14 00:00:00.000000000 Z
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
- rubygems_version: 3.1.4
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