nationality 0.0.2 → 1.0.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/lib/nationality.rb +30 -0
- data/lib/nationality/version.rb +1 -1
- data/lib/nationality/yml/nationality.yml +4 -9
- data/nationality.gemspec +1 -1
- data/spec/nationality_spec.rb +27 -6
- metadata +3 -4
- data/nationality-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0266654aaf0168d9579e17c9bad5484b2e033d6
|
4
|
+
data.tar.gz: c881ecb5c6f0d73a4ec8c6f042f7f577d75998f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09b3e69ef00a090a8509a40a69e2376c1cf686d7f2ac6138a47904479e8c7d907de52c4e13b0a69b9823b8c38119cffce0e4032b4850226507b3f58e2c01b285
|
7
|
+
data.tar.gz: 9a18846c2aa435cec683636333b062c82005dbe4a4f1d18b033f23ad8890e79fd53560e3fab5c8554877d4f224cab2b51ba11d4ce5fedb203413d8209b0facb3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Nationality
|
2
|
+
by [Jose Marie Antonio Miñoza](https://github.com/JomaMinoza)
|
2
3
|
|
3
4
|
Provides listing of nationality that you may need in your ruby applications.
|
4
5
|
|
@@ -10,7 +11,7 @@ Data in this gem was taken from Github GIST and the following repos:
|
|
10
11
|
|
11
12
|
Add this line to your application's Gemfile:
|
12
13
|
|
13
|
-
gem 'nationality', '~>
|
14
|
+
gem 'nationality', '~> 1.0.3'
|
14
15
|
|
15
16
|
And then execute:
|
16
17
|
|
@@ -26,6 +27,14 @@ This gem provides the following constant arrays:
|
|
26
27
|
|
27
28
|
* `Nationality::NATIONALITY`
|
28
29
|
|
30
|
+
## New! Options for Select Helper
|
31
|
+
|
32
|
+
Customize `options_for_select` with default nationality for your Rails application.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
= f.select :nationality, options_for_select(Nationality::Nationality.default_option("filipino"), :selected => f.object.nationality), {include_blank: "What's your nationality?"}, {:class => 'form-control' }
|
36
|
+
```
|
37
|
+
|
29
38
|
## Contributing
|
30
39
|
|
31
40
|
1. Fork it
|
data/lib/nationality.rb
CHANGED
@@ -7,4 +7,34 @@ module Nationality
|
|
7
7
|
|
8
8
|
NATIONALITY = YML_NATIONALITY.map { |_, v| v }.flatten.compact.sort
|
9
9
|
|
10
|
+
class Nationality
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def count
|
15
|
+
NATIONALITY.map { |v| v }.flatten.count
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_option(default_option)
|
19
|
+
nationalities = NATIONALITY
|
20
|
+
|
21
|
+
default_nationality = default_option.split(" ").map{ |word| word.include?("and") ? word : word.capitalize }.join(" ")
|
22
|
+
|
23
|
+
if nationalities.include? default_nationality
|
24
|
+
nationalities = nationalities - [default_nationality]
|
25
|
+
nationalities.unshift(default_nationality)
|
26
|
+
return nationalities
|
27
|
+
else
|
28
|
+
raise NationalityNotFound
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class NationalityNotFound < StandardError
|
36
|
+
def initialize(msg="Nationality not found on the list")
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
10
40
|
end
|
data/lib/nationality/version.rb
CHANGED
@@ -26,6 +26,7 @@ nationalities:
|
|
26
26
|
- "Bosnian"
|
27
27
|
- "Brazilian"
|
28
28
|
- "British"
|
29
|
+
- "British Overseas Territories Citizens"
|
29
30
|
- "Bruneian"
|
30
31
|
- "Bulgarian"
|
31
32
|
- "Burkinabe"
|
@@ -42,7 +43,6 @@ nationalities:
|
|
42
43
|
- "Colombian"
|
43
44
|
- "Comoran"
|
44
45
|
- "Congolese"
|
45
|
-
- "Congolese"
|
46
46
|
- "Costa Rican"
|
47
47
|
- "Croatian"
|
48
48
|
- "Cuban"
|
@@ -51,10 +51,7 @@ nationalities:
|
|
51
51
|
- "Danish"
|
52
52
|
- "Djibouti"
|
53
53
|
- "Dominican"
|
54
|
-
- "Dominican"
|
55
54
|
- "Dutch"
|
56
|
-
- "Dutchman"
|
57
|
-
- "Dutchwoman"
|
58
55
|
- "East Timorese"
|
59
56
|
- "Ecuadorean"
|
60
57
|
- "Egyptian"
|
@@ -89,7 +86,6 @@ nationalities:
|
|
89
86
|
- "Iranian"
|
90
87
|
- "Iraqi"
|
91
88
|
- "Irish"
|
92
|
-
- "Irish"
|
93
89
|
- "Israeli"
|
94
90
|
- "Italian"
|
95
91
|
- "Ivorian"
|
@@ -113,7 +109,7 @@ nationalities:
|
|
113
109
|
- "Malagasy"
|
114
110
|
- "Malawian"
|
115
111
|
- "Malaysian"
|
116
|
-
- "
|
112
|
+
- "Maldivian"
|
117
113
|
- "Malian"
|
118
114
|
- "Maltese"
|
119
115
|
- "Marshallese"
|
@@ -131,7 +127,6 @@ nationalities:
|
|
131
127
|
- "Namibian"
|
132
128
|
- "Nauruan"
|
133
129
|
- "Nepalese"
|
134
|
-
- "Netherlander"
|
135
130
|
- "New Zealander"
|
136
131
|
- "Ni-Vanuatu"
|
137
132
|
- "Nicaraguan"
|
@@ -185,7 +180,8 @@ nationalities:
|
|
185
180
|
- "Thai"
|
186
181
|
- "Togolese"
|
187
182
|
- "Tongan"
|
188
|
-
- "Trinidadian
|
183
|
+
- "Trinidadian"
|
184
|
+
- "Tobagonian"
|
189
185
|
- "Tunisian"
|
190
186
|
- "Turkish"
|
191
187
|
- "Tuvaluan"
|
@@ -196,7 +192,6 @@ nationalities:
|
|
196
192
|
- "Venezuelan"
|
197
193
|
- "Vietnamese"
|
198
194
|
- "Welsh"
|
199
|
-
- "Welsh"
|
200
195
|
- "Yemenite"
|
201
196
|
- "Zambian"
|
202
197
|
- "Zimbabwean"
|
data/nationality.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.email = ["josemarieantoniominoza@gmail.com"]
|
10
10
|
gem.description = %q{Provides listing of nationality that you may need in your ruby applications.}
|
11
11
|
gem.summary = %q{List of Nationality}
|
12
|
-
gem.homepage = "https://github.com/"
|
12
|
+
gem.homepage = "https://github.com/JomaMinoza/nationality/"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($/)
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/spec/nationality_spec.rb
CHANGED
@@ -7,16 +7,37 @@ describe Nationality do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
context "::NATIONALITY" do
|
10
|
-
it "should be
|
11
|
-
Nationality::NATIONALITY.count.should ==
|
10
|
+
it "should be 196" do
|
11
|
+
Nationality::NATIONALITY.count.should == 196
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
let(:countries) { Nationality::YML_NATIONALITY.map { |_, v| v}.flatten.sort }
|
15
|
+
describe "::Nationality Class" do
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
describe '#default_option method' do
|
18
|
+
context "When Nationality exists" do
|
19
|
+
it "should return the first option selected" do
|
20
|
+
expect(Nationality::Nationality.default_option('filipino')[0]).to eq("Filipino")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "When Nationality does not exists" do
|
25
|
+
it "should raise NationalityNotFound error" do
|
26
|
+
expect { Nationality::Nationality.default_option('Jejemon') }.to raise_error( Nationality::NationalityNotFound )
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#count method' do
|
32
|
+
it 'should return total count of Nationalities' do
|
33
|
+
expect(Nationality::Nationality.count).to eq(196)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "::NationalityNotFound Error Class" do
|
39
|
+
it "should raise NationalityNotFound error" do
|
40
|
+
expect { raise Nationality::NationalityNotFound }.to raise_error( Nationality::NationalityNotFound )
|
20
41
|
end
|
21
42
|
end
|
22
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nationality
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Marie Antonio Miñoza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -59,11 +59,10 @@ files:
|
|
59
59
|
- lib/nationality.rb
|
60
60
|
- lib/nationality/version.rb
|
61
61
|
- lib/nationality/yml/nationality.yml
|
62
|
-
- nationality-0.0.1.gem
|
63
62
|
- nationality.gemspec
|
64
63
|
- spec/nationality_spec.rb
|
65
64
|
- spec/spec_helper.rb
|
66
|
-
homepage: https://github.com/
|
65
|
+
homepage: https://github.com/JomaMinoza/nationality/
|
67
66
|
licenses: []
|
68
67
|
metadata: {}
|
69
68
|
post_install_message:
|
data/nationality-0.0.1.gem
DELETED
Binary file
|