country_flags 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +2 -0
- data/lib/country_flags/helper.rb +7 -1
- data/lib/country_flags/version.rb +1 -1
- data/spec/country_flags/helper_spec.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66a62ff6afae0677b0685dda8d07238d4bf7a6e
|
4
|
+
data.tar.gz: 01b31eab6c12ec3c8fa83495c9d06ab3a8292099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df5e5bdc1a712906ddfd472c53fd58a02f03f39c12fa2d1cca1cce4ee65d23c961ab2fbe882906e9940cd0d71744683295cd910f8e596d3c6ab1f1283af7427
|
7
|
+
data.tar.gz: 9d4bd79f2af1b35c927be18f2c05f4cd6e68ee6b928e6139bdcc58205f9258c9881b025ccb559f18de9ef617c0e6f4407f91960415c9e5801346198bc91b01db
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/lib/country_flags/helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'action_view'
|
2
2
|
|
3
|
+
require 'normalize_country'
|
4
|
+
|
3
5
|
module CountryFlags
|
4
6
|
module Helper
|
5
7
|
|
@@ -14,6 +16,8 @@ module CountryFlags
|
|
14
16
|
raise(ArgumentError, 'format must be :png or :gif')
|
15
17
|
end
|
16
18
|
|
19
|
+
return '' unless country_code && !country_code.empty?
|
20
|
+
|
17
21
|
path = "country_flags/#{format}/#{country_code.downcase}.#{format}"
|
18
22
|
image_path path
|
19
23
|
end
|
@@ -24,8 +28,10 @@ module CountryFlags
|
|
24
28
|
|
25
29
|
country_name = NormalizeCountry( country_code, to: :short )
|
26
30
|
|
31
|
+
return '' unless country_name
|
32
|
+
|
27
33
|
image_tag country_flag_path(country_code, options[:format]),
|
28
34
|
alt: country_name, title: country_name
|
29
35
|
end
|
30
36
|
end
|
31
|
-
end
|
37
|
+
end
|
@@ -16,6 +16,11 @@ describe CountryFlags::Helper do
|
|
16
16
|
it 'returns image path' do
|
17
17
|
expect(country_flag_path('bg', :png)).to be_a(String)
|
18
18
|
end
|
19
|
+
|
20
|
+
it 'returns empty string if no country path given' do
|
21
|
+
expect(country_flag_path(nil)).to eq('')
|
22
|
+
expect(country_flag_path('')).to eq('')
|
23
|
+
end
|
19
24
|
end
|
20
25
|
|
21
26
|
describe '#country_flag' do
|
@@ -26,5 +31,10 @@ describe CountryFlags::Helper do
|
|
26
31
|
it 'throws exception if wrong format given' do
|
27
32
|
expect { country_flag('bg', format: :tiff) }.to raise_error(ArgumentError)
|
28
33
|
end
|
34
|
+
|
35
|
+
it 'returns empty string if no coutry given' do
|
36
|
+
expect(country_flag(nil)).to eq('')
|
37
|
+
expect(country_flag('')).to eq('')
|
38
|
+
end
|
29
39
|
end
|
30
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country_flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Lazarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -601,7 +601,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
601
601
|
version: '0'
|
602
602
|
requirements: []
|
603
603
|
rubyforge_project:
|
604
|
-
rubygems_version: 2.4.
|
604
|
+
rubygems_version: 2.4.8
|
605
605
|
signing_key:
|
606
606
|
specification_version: 4
|
607
607
|
summary: Gemified collection of country flags.
|