countries 0.9.2 → 0.9.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.
@@ -5,8 +5,7 @@
5
5
  names:
6
6
  - "Krung Thep"
7
7
  - Bangkok
8
- - Bangkok
9
- - Bangkok
8
+ - "BKK"
10
9
  ? "11"
11
10
  :
12
11
  name: "Samut Prakan"
@@ -51,6 +51,18 @@
51
51
  :
52
52
  name: Wakiso
53
53
  names: Wakiso
54
+ ? "114"
55
+ :
56
+ name: Mityana
57
+ names: Mityana
58
+ ? "115"
59
+ :
60
+ name: Nakaseke
61
+ names: Nakaseke
62
+ ? "116"
63
+ :
64
+ name: Lyantonde
65
+ names: Lyantonde
54
66
  ? "201"
55
67
  :
56
68
  name: Bugiri
@@ -111,6 +123,42 @@
111
123
  :
112
124
  name: Sironko
113
125
  names: Sironko
126
+ ? "216"
127
+ :
128
+ name: Amuria
129
+ names: Amuria
130
+ ? "217"
131
+ :
132
+ name: Budaka
133
+ names: Budaka
134
+ ? "218"
135
+ :
136
+ name: Bukwa
137
+ names: Bukwa
138
+ ? "219"
139
+ :
140
+ name: Butaleja
141
+ names: Butaleja
142
+ ? "220"
143
+ :
144
+ name: Kaliro
145
+ names: Kaliro
146
+ ? "221"
147
+ :
148
+ name: Manafwa
149
+ names: Manafwa
150
+ ? "222"
151
+ :
152
+ name: Namutumba
153
+ names: Namutumba
154
+ ? "223"
155
+ :
156
+ name: Bududa
157
+ names: Bududa
158
+ ? "224"
159
+ :
160
+ name: Bukedea
161
+ names: Bukedea
114
162
  ? "301"
115
163
  :
116
164
  name: Adjumani
@@ -163,6 +211,38 @@
163
211
  :
164
212
  name: Yumbe
165
213
  names: Yumbe
214
+ ? "314"
215
+ :
216
+ name: Amolatar
217
+ names: Amolatar
218
+ ? "315"
219
+ :
220
+ name: Kaabong
221
+ names: Kaabong
222
+ ? "316"
223
+ :
224
+ name: Koboko
225
+ names: Koboko
226
+ ? "317"
227
+ :
228
+ name: Abim
229
+ names: Abim
230
+ ? "318"
231
+ :
232
+ name: Dokolo
233
+ names: Dokolo
234
+ ? "319"
235
+ :
236
+ name: Amuru
237
+ names: Amuru
238
+ ? "320"
239
+ :
240
+ name: Maracha
241
+ names: Maracha
242
+ ? "321"
243
+ :
244
+ name: Oyam
245
+ names: Oyam
166
246
  ? "401"
167
247
  :
168
248
  name: Bundibugyo
@@ -223,3 +303,19 @@
223
303
  :
224
304
  name: Kyenjojo
225
305
  names: Kyenjojo
306
+ ? "416"
307
+ :
308
+ name: Ibanda
309
+ names: Ibanda
310
+ ? "417"
311
+ :
312
+ name: Isingiro
313
+ names: Isingiro
314
+ ? "418"
315
+ :
316
+ name: Kiruhura
317
+ names: Kiruhura
318
+ ? "419"
319
+ :
320
+ name: Buliisa
321
+ names: Buliisa
@@ -1,10 +1,19 @@
1
1
  ---
2
+ AA:
3
+ name: "Armed Forces Americas"
4
+ names: "Armed Forces Americas"
5
+ AE:
6
+ name: "Armed Forces Europe"
7
+ names: "Armed Forces Europe"
2
8
  AK:
3
9
  name: Alaska
4
10
  names: Alaska
5
11
  AL:
6
12
  name: Alabama
7
13
  names: Alabama
14
+ AP:
15
+ name: "Armed Forces Pacific"
16
+ names: "Armed Forces Pacific"
8
17
  AR:
9
18
  name: Arkansas
10
19
  names: Arkansas
@@ -1,5 +1,8 @@
1
1
  require 'yaml'
2
2
  require 'iso4217'
3
3
 
4
- require 'countries/select_helper'
5
4
  require 'countries/country'
5
+
6
+ if defined?(ActionView::Helpers::FormOptionsHelper)
7
+ ActionView::Helpers::FormOptionsHelper::COUNTRIES = ISO3166::Country::Names.map{ |(name,alpha2)| [name.html_safe,alpha2] }
8
+ end
@@ -6,6 +6,16 @@ describe ISO3166::Country do
6
6
 
7
7
  let(:country) { ISO3166::Country.search('US') }
8
8
 
9
+ it 'allows to create a country object from a symbol representation of the alpha2 code' do
10
+ country = described_class.new(:us)
11
+ country.data.should_not be_nil
12
+ end
13
+
14
+ it 'allows to create a country object from a lowercase alpha2 code' do
15
+ country = described_class.new("us")
16
+ country.data.should_not be_nil
17
+ end
18
+
9
19
  it 'should return 3166 number' do
10
20
  country.number.should == '840'
11
21
  end
@@ -23,7 +33,12 @@ describe ISO3166::Country do
23
33
  end
24
34
 
25
35
  it 'should return alternate names' do
26
- country.names.should == ["United States of America", "Vereinigte Staaten von Amerika", "États-Unis", "Estados Unidos"]
36
+ country.names.should == ["United States of America", "Vereinigte Staaten von Amerika", "États-Unis", "Estados Unidos", "アメリカ合衆国", "Verenigde Staten"]
37
+ end
38
+
39
+ it 'should return translations' do
40
+ country.translations.should be
41
+ country.translations["en"].should == "United States of America"
27
42
  end
28
43
 
29
44
  it 'should return latitude' do
@@ -90,11 +105,11 @@ describe ISO3166::Country do
90
105
  end
91
106
 
92
107
  it 'should return a hash with all sub divisions' do
93
- country.subdivisions.should have(57).states
108
+ country.subdivisions.should have(60).states
94
109
  end
95
110
 
96
111
  it 'should be available through states' do
97
- country.states.should have(57).states
112
+ country.states.should have(60).states
98
113
  end
99
114
  end
100
115
 
@@ -104,7 +119,25 @@ describe ISO3166::Country do
104
119
  end
105
120
 
106
121
  it 'should return false if country is invalid' do
107
- ISO3166::Country.new('fubar').should_not be_valid
122
+ ISO3166::Country.new({}).should_not be_valid
123
+ end
124
+ end
125
+
126
+ describe 'new' do
127
+ it 'should return new country object when a valid alpha2 string is passed' do
128
+ ISO3166::Country.new('US').should be_a(ISO3166::Country)
129
+ end
130
+
131
+ it 'should return nil when an invalid alpha2 string is passed' do
132
+ ISO3166::Country.new('fubar').should be_nil
133
+ end
134
+
135
+ it 'should return new country object when a valid alpha2 symbol is passed' do
136
+ ISO3166::Country.new(:us).should be_a(ISO3166::Country)
137
+ end
138
+
139
+ it 'should return nil when an invalid alpha2 symbol is passed' do
140
+ ISO3166::Country.new(:fubar).should be_nil
108
141
  end
109
142
  end
110
143
 
@@ -113,7 +146,7 @@ describe ISO3166::Country do
113
146
  countries = ISO3166::Country.all
114
147
  countries.should be_an(Array)
115
148
  countries.first.should be_an(Array)
116
- countries.should have(247).countries
149
+ countries.should have(250).countries
117
150
  end
118
151
 
119
152
  it "should allow to customize each country representation passing a block to the method" do
@@ -121,7 +154,7 @@ describe ISO3166::Country do
121
154
  countries.should be_an(Array)
122
155
  countries.first.should be_an(Array)
123
156
  countries.first.should have(3).fields
124
- countries.should have(247).countries
157
+ countries.should have(250).countries
125
158
  end
126
159
  end
127
160
 
@@ -136,16 +169,16 @@ describe ISO3166::Country do
136
169
  ISO3166::Country.search('US').should be_a(ISO3166::Country)
137
170
  end
138
171
 
139
- it 'should return false when an invalid alpha2 string is passed' do
140
- ISO3166::Country.search('fubar').should be_false
172
+ it 'should return nil when an invalid alpha2 string is passed' do
173
+ ISO3166::Country.search('fubar').should be_nil
141
174
  end
142
175
 
143
176
  it 'should return new country object when a valid alpha2 symbol is passed' do
144
177
  ISO3166::Country.search(:us).should be_a(ISO3166::Country)
145
178
  end
146
179
 
147
- it 'should return false when an invalid alpha2 symbol is passed' do
148
- ISO3166::Country.search(:fubar).should be_false
180
+ it 'should return nil when an invalid alpha2 symbol is passed' do
181
+ ISO3166::Country.search(:fubar).should be_nil
149
182
  end
150
183
  end
151
184
 
@@ -180,6 +213,12 @@ describe ISO3166::Country do
180
213
 
181
214
  it { should == ISO3166::Country }
182
215
  end
216
+
217
+ describe 'to_s' do
218
+ it 'should return the country name' do
219
+ Country.new('GB').to_s.should == 'United Kingdom'
220
+ end
221
+ end
183
222
  end
184
223
  end
185
224
 
@@ -346,4 +385,23 @@ describe ISO3166::Country do
346
385
  german_speaking_countries.size.should == 6
347
386
  end
348
387
  end
388
+
389
+ describe 'in_eu?' do
390
+ let(:netherlands) { ISO3166::Country.search('NL') }
391
+
392
+ it 'should return false for countries without eu_member flag' do
393
+ country.in_eu?.should be_false
394
+ end
395
+
396
+ it 'should return true for countries with eu_member flag set to true' do
397
+ netherlands.in_eu?.should be_true
398
+ end
399
+ end
400
+
401
+ describe 'to_s' do
402
+ it 'should return the country name' do
403
+ ISO3166::Country.new('GB').to_s.should == 'United Kingdom'
404
+ end
405
+ end
406
+
349
407
  end
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+ require File.expand_path('../../lib/countries/mongoid', __FILE__)
5
+
6
+ describe 'Mongoid support' do
7
+
8
+ let(:britain) { ISO3166::Country.new('GB') }
9
+ context 'instance methods' do
10
+ describe 'mongoize' do
11
+ it 'should delegate mongoization to the class method' do
12
+ britain.mongoize.should eql ISO3166::Country.mongoize(britain)
13
+ end
14
+ end
15
+ end
16
+
17
+ context 'class methods' do
18
+ describe 'mongoize' do
19
+ it 'should store the alpha2 given a country object' do
20
+ ISO3166::Country.mongoize(britain).should eql britain.alpha2
21
+ end
22
+
23
+ it 'should store the alpha2 given a valid alpha2' do
24
+ ISO3166::Country.mongoize('GB').should eql britain.alpha2
25
+ end
26
+
27
+ it 'should raise BadMongoidTypeError given an invalid object' do
28
+ bad_types = [[], Time.now, {}, Date.today]
29
+ bad_types.each do |type|
30
+ expect { ISO3166::Country.mongoize(type) }
31
+ .to raise_error(ISO3166::Country::BadMongoidTypeError, /neither/)
32
+ end
33
+ end
34
+
35
+ it 'should raise BadMongoidTypeError given an empty country object' do
36
+ expect { ISO3166::Country.mongoize(ISO3166::Country.new('')) }
37
+ .to raise_error(ISO3166::Country::BadMongoidTypeError, /neither/)
38
+ end
39
+
40
+ it 'should raise BadMongoidTypeError given a bad alpha2' do
41
+ expect { ISO3166::Country.mongoize('bad_alpha_2') }
42
+ .to raise_error(ISO3166::Country::BadMongoidTypeError,
43
+ /not a valid alpha2/)
44
+ end
45
+
46
+ end
47
+
48
+ describe 'demongoize' do
49
+ it 'should instantiate an equivalent object from stored alpha2 code' do
50
+ ISO3166::Country.demongoize(britain.mongoize).data
51
+ .should eql britain.data
52
+ end
53
+
54
+ it 'should be indifferent to storage by alpha2' do
55
+ ISO3166::Country.demongoize(ISO3166::Country.mongoize('GB'))
56
+ .data.should eql britain.data
57
+ end
58
+ end
59
+
60
+ describe 'evolve' do
61
+ it 'should delegate to self.mongoize and return the mongoized object' do
62
+ ISO3166::Country.should_receive(:mongoize).with(britain)
63
+ ISO3166::Country.evolve(britain)
64
+ end
65
+ end
66
+ end
67
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: countries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
5
- prerelease:
4
+ version: 0.9.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Josh Robinson
@@ -10,28 +9,25 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-03-02 00:00:00.000000000 Z
12
+ date: 2013-10-28 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: currencies
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - ~>
21
19
  - !ruby/object:Gem::Version
22
- version: 0.4.0
20
+ version: 0.4.2
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - ~>
29
26
  - !ruby/object:Gem::Version
30
- version: 0.4.0
27
+ version: 0.4.2
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rspec
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ! '>='
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ! '>='
45
40
  - !ruby/object:Gem::Version
@@ -47,7 +42,6 @@ dependencies:
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: yard
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ! '>='
53
47
  - !ruby/object:Gem::Version
@@ -55,7 +49,6 @@ dependencies:
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ! '>='
61
54
  - !ruby/object:Gem::Version
@@ -70,7 +63,7 @@ extra_rdoc_files: []
70
63
  files:
71
64
  - .document
72
65
  - .gitignore
73
- - .rvmrc
66
+ - .travis.yml
74
67
  - Gemfile
75
68
  - Gemfile.lock
76
69
  - LICENSE
@@ -79,7 +72,7 @@ files:
79
72
  - countries.gemspec
80
73
  - lib/countries.rb
81
74
  - lib/countries/country.rb
82
- - lib/countries/select_helper.rb
75
+ - lib/countries/mongoid.rb
83
76
  - lib/countries/version.rb
84
77
  - lib/data/countries.yaml
85
78
  - lib/data/subdivisions/AD.yaml
@@ -104,6 +97,7 @@ files:
104
97
  - lib/data/subdivisions/BJ.yaml
105
98
  - lib/data/subdivisions/BN.yaml
106
99
  - lib/data/subdivisions/BO.yaml
100
+ - lib/data/subdivisions/BQ.yaml
107
101
  - lib/data/subdivisions/BR.yaml
108
102
  - lib/data/subdivisions/BS.yaml
109
103
  - lib/data/subdivisions/BT.yaml
@@ -200,6 +194,7 @@ files:
200
194
  - lib/data/subdivisions/MM.yaml
201
195
  - lib/data/subdivisions/MN.yaml
202
196
  - lib/data/subdivisions/MR.yaml
197
+ - lib/data/subdivisions/MT.yaml
203
198
  - lib/data/subdivisions/MU.yaml
204
199
  - lib/data/subdivisions/MV.yaml
205
200
  - lib/data/subdivisions/MW.yaml
@@ -279,31 +274,32 @@ files:
279
274
  - lib/data/subdivisions/ZW.yaml
280
275
  - lib/iso3166.rb
281
276
  - spec/country_spec.rb
277
+ - spec/mongoid_spec.rb
282
278
  - spec/spec_helper.rb
283
279
  homepage: http://github.com/hexorx/countries
284
280
  licenses: []
281
+ metadata: {}
285
282
  post_install_message:
286
283
  rdoc_options: []
287
284
  require_paths:
288
285
  - lib
289
286
  required_ruby_version: !ruby/object:Gem::Requirement
290
- none: false
291
287
  requirements:
292
288
  - - ! '>='
293
289
  - !ruby/object:Gem::Version
294
290
  version: '0'
295
291
  required_rubygems_version: !ruby/object:Gem::Requirement
296
- none: false
297
292
  requirements:
298
293
  - - ! '>='
299
294
  - !ruby/object:Gem::Version
300
295
  version: '0'
301
296
  requirements: []
302
297
  rubyforge_project:
303
- rubygems_version: 1.8.23
298
+ rubygems_version: 2.0.3
304
299
  signing_key:
305
- specification_version: 3
300
+ specification_version: 4
306
301
  summary: Gives you a country object full of all sorts of useful information.
307
302
  test_files:
308
303
  - spec/country_spec.rb
304
+ - spec/mongoid_spec.rb
309
305
  - spec/spec_helper.rb