country_flags 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3699cfa6204fa91fb1d51ff69e4c4207c4c96c23
4
- data.tar.gz: 9a358f76c3d9d360ef6fbb5fadde7559dbf206f4
3
+ metadata.gz: a66a62ff6afae0677b0685dda8d07238d4bf7a6e
4
+ data.tar.gz: 01b31eab6c12ec3c8fa83495c9d06ab3a8292099
5
5
  SHA512:
6
- metadata.gz: 13d52f0a8009e6094c9864752ea562f5744e6ed2698c7bbe5dc94d4ace189eedf269a8b5f7b0399829290fa5c16d81b4888cd54e1539079295c91aeaa4908f8f
7
- data.tar.gz: d76b3f8f690b43709f31eda18eefc818ead859929e2bd088b92c13564683abdb65b7be3144242cee47d02f05b2d75c24f48dbc1c5820b76c97c7c4eec645b5de
6
+ metadata.gz: 4df5e5bdc1a712906ddfd472c53fd58a02f03f39c12fa2d1cca1cce4ee65d23c961ab2fbe882906e9940cd0d71744683295cd910f8e596d3c6ab1f1283af7427
7
+ data.tar.gz: 9d4bd79f2af1b35c927be18f2c05f4cd6e68ee6b928e6139bdcc58205f9258c9881b025ccb559f18de9ef617c0e6f4407f91960415c9e5801346198bc91b01db
data/.gitignore CHANGED
@@ -36,3 +36,6 @@ Gemfile.lock
36
36
 
37
37
  # Sublime Text workspace
38
38
  project.sublime-workspace
39
+
40
+ # vi(m) swap files
41
+ *.sw?
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Readme
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/country_flags.svg)](http://badge.fury.io/rb/country_flags)
4
+
3
5
  Gemified collection of
4
6
  [country flags](http://www.famfamfam.com/lab/icons/flags/).
5
7
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CountryFlags
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  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.2
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-08-07 00:00:00.000000000 Z
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.5
604
+ rubygems_version: 2.4.8
605
605
  signing_key:
606
606
  specification_version: 4
607
607
  summary: Gemified collection of country flags.