nationality 0.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: 4b408ce1c4238c13517a661be263926b6a44c5e7
4
- data.tar.gz: 505f35c1fb63958674cb6af80717a7d4d146967b
3
+ metadata.gz: b0266654aaf0168d9579e17c9bad5484b2e033d6
4
+ data.tar.gz: c881ecb5c6f0d73a4ec8c6f042f7f577d75998f3
5
5
  SHA512:
6
- metadata.gz: 00b328dcf4649e9a8a3fff2592bf2d5f37e3d0efd728425bef2f74de9925522d0d075720a78c932f242d6102c25591072c2fa153c9496222d2c5a3a6f8b63bee
7
- data.tar.gz: 7c0c1ad16b608e6bf04a813e902d12422dfab2559b2f6011cfd897b9cc8db17c186d7e5e554afd53febd64caf284188c616408837ac4fd9291d25d05a0e62ada
6
+ metadata.gz: 09b3e69ef00a090a8509a40a69e2376c1cf686d7f2ac6138a47904479e8c7d907de52c4e13b0a69b9823b8c38119cffce0e4032b4850226507b3f58e2c01b285
7
+ data.tar.gz: 9a18846c2aa435cec683636333b062c82005dbe4a4f1d18b033f23ad8890e79fd53560e3fab5c8554877d4f224cab2b51ba11d4ce5fedb203413d8209b0facb3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nationality (0.0.1)
4
+ nationality (1.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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', '~> 0.0.1'
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
@@ -1,3 +1,3 @@
1
1
  module Nationality
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -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
- - "Maldivan"
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 or Tobagonian"
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) }
@@ -7,16 +7,37 @@ describe Nationality do
7
7
  end
8
8
 
9
9
  context "::NATIONALITY" do
10
- it "should be 201" do
11
- Nationality::NATIONALITY.count.should == 201
10
+ it "should be 196" do
11
+ Nationality::NATIONALITY.count.should == 196
12
12
  end
13
13
  end
14
14
 
15
- context "::REGION_DATA" do
16
- let(:countries) { Nationality::YML_NATIONALITY.map { |_, v| v}.flatten.sort }
15
+ describe "::Nationality Class" do
17
16
 
18
- it "provinces should be consistent with PROVINCES" do
19
- countries.should == Nationality::NATIONALITY
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: 0.0.2
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: 2016-10-04 00:00:00.000000000 Z
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:
Binary file