country_flags 0.0.1 → 0.1.0
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/README.md +8 -0
- data/country_flags.gemspec +2 -0
- data/lib/country_flags/engine.rb +3 -1
- data/lib/country_flags/helper.rb +28 -0
- data/lib/country_flags/railtie.rb +5 -2
- data/lib/country_flags/version.rb +1 -1
- data/lib/country_flags.rb +1 -0
- data/spec/country_flags/helper_spec.rb +30 -0
- data/spec/spec_helper.rb +0 -1
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7714be3c9539e45cf731da6cd61a84a53f2575eb
|
4
|
+
data.tar.gz: 0d32fc0659e52d2bfed2bc7d6eb0934135a1b4b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fe3b03a7ff630dfaf148719da059265c3f2919cb840088d19df658c1c58600a56b3f5315c017be1323675965bee9471c0d57b0eaf1a82ecc54c056002d798ec
|
7
|
+
data.tar.gz: 08cdc532972fec3c9c4eaa848b7140bf4b0eb68951c0eb13e0663947c9ec04f6189e22ba526f13d3c386fd2556601ccc4cf592a2b530f4e4affa850c0681227d
|
data/README.md
CHANGED
@@ -19,6 +19,14 @@ bundle install
|
|
19
19
|
|
20
20
|
In views:
|
21
21
|
```ruby
|
22
|
+
|
23
|
+
# using helper
|
24
|
+
country_flag 'bg'
|
25
|
+
country_flag 'bg', format: 'gif'
|
26
|
+
|
27
|
+
image_tag country_flag_path 'bg'
|
28
|
+
image_tag country_flag_path 'bg', :gif
|
29
|
+
|
22
30
|
# gif version
|
23
31
|
image_tag 'country_flags/gif/bg.gif'
|
24
32
|
|
data/country_flags.gemspec
CHANGED
data/lib/country_flags/engine.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
|
3
|
+
module CountryFlags
|
4
|
+
module Helper
|
5
|
+
|
6
|
+
include ActionView::Helpers::AssetUrlHelper
|
7
|
+
include ActionView::Helpers::AssetTagHelper
|
8
|
+
|
9
|
+
# returns path to flag image
|
10
|
+
# use ISO-3166 Alpha 2 country codes
|
11
|
+
# format can be :png or :gif
|
12
|
+
def country_flag_path( country_code, format = :png )
|
13
|
+
unless [:png, :gif].include?(format)
|
14
|
+
raise(ArgumentError, 'format must be :png or :gif')
|
15
|
+
end
|
16
|
+
|
17
|
+
path = "country_flags/#{format}/#{country_code.downcase}.#{format}"
|
18
|
+
image_path path
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def country_flag( country_code, options = {} )
|
23
|
+
options = {format: :png}.merge(options)
|
24
|
+
|
25
|
+
image_tag country_flag_path(country_code, options[:format])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/country_flags.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CountryFlags::Helper do
|
4
|
+
|
5
|
+
include CountryFlags::Helper
|
6
|
+
|
7
|
+
describe '#country_flag_path' do
|
8
|
+
it 'throws exception if wrong format given' do
|
9
|
+
expect { country_flag_path('bg', :tiff) }.to raise_error(ArgumentError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'does not throw exception if format given in string' do
|
13
|
+
expect { country_flag_path('bg', 'gif') }.to raise_error(ArgumentError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns image path' do
|
17
|
+
expect(country_flag_path('bg', :png)).to be_a(String)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#country_flag' do
|
22
|
+
it 'returns image tag' do
|
23
|
+
expect(country_flag('bg')).to be_a(String)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'throws exception if wrong format given' do
|
27
|
+
expect { country_flag('bg', format: :tiff) }.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.0
|
4
|
+
version: 0.1.0
|
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-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: actionview
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
27
55
|
description: 'Gemified collection of country flags. See homepage for details: https://github.com/alexander-lazarov/isaf_id_validator'
|
28
56
|
email: alexander.lazaroff@gmail.com
|
29
57
|
executables: []
|
@@ -533,9 +561,11 @@ files:
|
|
533
561
|
- country_flags.gemspec
|
534
562
|
- lib/country_flags.rb
|
535
563
|
- lib/country_flags/engine.rb
|
564
|
+
- lib/country_flags/helper.rb
|
536
565
|
- lib/country_flags/railtie.rb
|
537
566
|
- lib/country_flags/version.rb
|
538
567
|
- project.sublime-project
|
568
|
+
- spec/country_flags/helper_spec.rb
|
539
569
|
- spec/spec_helper.rb
|
540
570
|
homepage: https://github.com/alexander-lazarov/country_flags
|
541
571
|
licenses:
|