bcardarella-coder 0.2.0 → 0.3.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.
- data/VERSION +1 -1
- data/coder.gemspec +1 -1
- data/lib/countries/countries.rb +4 -5
- data/lib/countries/country.rb +3 -3
- data/lib/i18n/states/us/eng.yml +59 -1
- data/test/countries/countries_test.rb +2 -2
- data/test/countries/country_test.rb +2 -2
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/coder.gemspec
CHANGED
data/lib/countries/countries.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Coder
|
2
2
|
class Countries
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :countries
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
self.load_yaml
|
7
7
|
end
|
8
8
|
|
9
9
|
def load_yaml
|
10
|
-
self.
|
10
|
+
self.countries = YAML.load_file(yaml_file_name)
|
11
11
|
end
|
12
12
|
|
13
13
|
def yaml_file_name
|
@@ -16,13 +16,12 @@ module Coder
|
|
16
16
|
|
17
17
|
def [](_code)
|
18
18
|
_code = _code.to_s.upcase.to_sym
|
19
|
-
country =
|
19
|
+
country = countries[_code]
|
20
20
|
Coder::Country.new(:code => _code.to_s, :name => country)
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.[](_code)
|
24
|
-
|
25
|
-
countries[_code]
|
24
|
+
self.new[_code]
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
data/lib/countries/country.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Coder
|
2
2
|
class Country
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :states, :code, :name
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
self.code = args[:code].to_s
|
@@ -10,7 +10,7 @@ module Coder
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def load_yaml
|
13
|
-
self.
|
13
|
+
self.states = YAML.load_file(yaml_file_name)
|
14
14
|
end
|
15
15
|
|
16
16
|
def yaml_file_name
|
@@ -19,7 +19,7 @@ module Coder
|
|
19
19
|
|
20
20
|
def [](_code)
|
21
21
|
_code = _code.to_s.upcase.to_sym
|
22
|
-
state =
|
22
|
+
state = states[_code]
|
23
23
|
Coder::State.new(:code => _code.to_s, :name => state)
|
24
24
|
end
|
25
25
|
|
data/lib/i18n/states/us/eng.yml
CHANGED
@@ -1,2 +1,60 @@
|
|
1
1
|
---
|
2
|
-
:
|
2
|
+
:HI: Hawaii
|
3
|
+
:KY: Kentucky
|
4
|
+
:MN: Minnesota
|
5
|
+
:OK: Oklahoma
|
6
|
+
:FM: Federated States Of Micronesia
|
7
|
+
:MT: Montana
|
8
|
+
:NJ: New Jersey
|
9
|
+
:PW: Palau
|
10
|
+
:SD: South Dakota
|
11
|
+
:VI: Virgin Islands
|
12
|
+
:WA: Washington
|
13
|
+
:DE: Delaware
|
14
|
+
:IA: Iowa
|
15
|
+
:MO: Missouri
|
16
|
+
:OR: Oregon
|
17
|
+
:AK: Alaska
|
18
|
+
:MH: Marshall Islands
|
19
|
+
:NM: New Mexico
|
20
|
+
:WV: West Virginia
|
21
|
+
:ID: Idaho
|
22
|
+
:IL: Illinois
|
23
|
+
:KS: Kansas
|
24
|
+
:LA: Louisiana
|
25
|
+
:MA: Massachusetts
|
26
|
+
:MP: Northern Mariana Islands
|
27
|
+
:RI: Rhode Island
|
28
|
+
:VA: Virginia
|
29
|
+
:CT: Connecticut
|
30
|
+
:NY: New York
|
31
|
+
:WI: Wisconsin
|
32
|
+
:GU: Guam
|
33
|
+
:MI: Michigan
|
34
|
+
:NC: North Carolina
|
35
|
+
:PR: Puerto Rico
|
36
|
+
:TX: Texas
|
37
|
+
:DC: District Of Columbia
|
38
|
+
:ND: North Dakota
|
39
|
+
:TN: T:Tnessee
|
40
|
+
:WY: Wyoming
|
41
|
+
:AR: Arkansas
|
42
|
+
:IN: Indiana
|
43
|
+
:MD: Maryland
|
44
|
+
:NE: Nebraska
|
45
|
+
:NV: Nevada
|
46
|
+
:UT: Utah
|
47
|
+
:AL: Alabama
|
48
|
+
:AZ: Arizona
|
49
|
+
:FL: Florida
|
50
|
+
:GA: Georgia
|
51
|
+
:OH: Ohio
|
52
|
+
:AS: American Samoa
|
53
|
+
:CA: California
|
54
|
+
:CO: Colorado
|
55
|
+
:ME: Maine
|
56
|
+
:MS: Mississippi
|
57
|
+
:NH: New Hampshire
|
58
|
+
:PA: Pennsylvania
|
59
|
+
:SC: South Carolina
|
60
|
+
:VT: Vermont
|
@@ -15,10 +15,10 @@ class CountriesTest < Test::Unit::TestCase
|
|
15
15
|
assert_match /eng.yml/, @countries.yaml_file_name
|
16
16
|
end
|
17
17
|
|
18
|
-
should "set the #
|
18
|
+
should "set the #countries with the country data" do
|
19
19
|
YAML.expects(:load_file).returns({:US => "United States"})
|
20
20
|
@countries.load_yaml
|
21
|
-
assert "United States", @countries.
|
21
|
+
assert "United States", @countries.countries[:US]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -16,10 +16,10 @@ class CountryTest < Test::Unit::TestCase
|
|
16
16
|
assert_match /us/, @country.yaml_file_name
|
17
17
|
end
|
18
18
|
|
19
|
-
should "set the #
|
19
|
+
should "set the #states with the US state data" do
|
20
20
|
YAML.expects(:load_file).returns({:MA => "Massachusetts"})
|
21
21
|
@country.load_yaml
|
22
|
-
assert "Massachusetts", @country.
|
22
|
+
assert "Massachusetts", @country.states[:MA]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|