geolombia 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/lib/geolombia/city.rb +8 -4
- data/lib/geolombia/state.rb +2 -2
- data/lib/geolombia/version.rb +1 -1
- data/spec/geolombia/city_spec.rb +22 -1
- data/spec/geolombia/state_spec.rb +8 -0
- metadata +5 -4
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -64,4 +64,4 @@ This gem is currently only compatible with Ruby 1.9.3.
|
|
64
64
|
|
65
65
|
## Credits
|
66
66
|
|
67
|
-
Thanks to Jorge Iván Meza for his
|
67
|
+
Thanks to Jorge Iván Meza for his [CSV data files](http://blog.jorgeivanmeza.com/2008/09/departamentos-y-municipios-de-colombia-actualizacion-20080915/) .
|
data/lib/geolombia/city.rb
CHANGED
@@ -4,10 +4,10 @@ module Geolombia
|
|
4
4
|
class City < Base
|
5
5
|
|
6
6
|
def initialize(code, name, state_code, state_name, latitude, longitude)
|
7
|
-
@code = code
|
8
|
-
@name = name
|
9
|
-
@state_code = state_code
|
10
|
-
@state_name = state_name
|
7
|
+
@code = code.force_encoding("UTF-8")
|
8
|
+
@name = name.force_encoding("UTF-8")
|
9
|
+
@state_code = state_code.force_encoding("UTF-8")
|
10
|
+
@state_name = state_name.force_encoding("UTF-8")
|
11
11
|
@latitude = latitude.to_f
|
12
12
|
@longitude = longitude.to_f
|
13
13
|
end
|
@@ -22,6 +22,10 @@ module Geolombia
|
|
22
22
|
@@all.select { |city| city.name == some_name }.first
|
23
23
|
end
|
24
24
|
|
25
|
+
def self.find_by_code(some_code)
|
26
|
+
@@all.select { |city| city.code == some_code }.first
|
27
|
+
end
|
28
|
+
|
25
29
|
def self.all
|
26
30
|
@@all
|
27
31
|
end
|
data/lib/geolombia/state.rb
CHANGED
@@ -3,8 +3,8 @@ require 'csv'
|
|
3
3
|
module Geolombia
|
4
4
|
class State < Base
|
5
5
|
def initialize(code, name, latitude, longitude)
|
6
|
-
@code = code
|
7
|
-
@name = name
|
6
|
+
@code = code.force_encoding("UTF-8")
|
7
|
+
@name = name.force_encoding("UTF-8")
|
8
8
|
@latitude = latitude.to_f
|
9
9
|
@longitude = longitude.to_f
|
10
10
|
end
|
data/lib/geolombia/version.rb
CHANGED
data/spec/geolombia/city_spec.rb
CHANGED
@@ -22,8 +22,22 @@ describe Geolombia::State do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe "#self.find_by_code" do
|
26
|
+
it "returns an instance of City if found" do
|
27
|
+
city = Geolombia::City.find_by_code("05001")
|
28
|
+
city.should be_instance_of(Geolombia::City)
|
29
|
+
city.name.should == "Medellín"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns nil if not found" do
|
33
|
+
Geolombia::City.find_by_code("666").should be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
25
39
|
describe "getters" do
|
26
|
-
it "
|
40
|
+
it "return correct values" do
|
27
41
|
state = Geolombia::City.find_by_name("Medellín")
|
28
42
|
state.name.should == "Medellín"
|
29
43
|
state.code.should == "05001"
|
@@ -47,4 +61,11 @@ describe Geolombia::State do
|
|
47
61
|
@medellin.state.should be_instance_of(Geolombia::State)
|
48
62
|
end
|
49
63
|
end
|
64
|
+
|
65
|
+
describe "#name" do
|
66
|
+
it "is UTF-8 encoded" do
|
67
|
+
name = Geolombia::City.find_by_name("Medellín").name
|
68
|
+
name.encoding.should == Encoding.find("UTF-8")
|
69
|
+
end
|
70
|
+
end
|
50
71
|
end
|
@@ -57,4 +57,12 @@ describe Geolombia::State do
|
|
57
57
|
names.should include("Caucasia")
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
describe "#name" do
|
62
|
+
it "is UTF-8 encoded" do
|
63
|
+
name = Geolombia::State.find_by_name("Antioquia").name
|
64
|
+
name.encoding.should == Encoding.find("UTF-8")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
60
68
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geolombia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -53,6 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
55
|
- .travis.yml
|
56
|
+
- CHANGELOG.md
|
56
57
|
- Gemfile
|
57
58
|
- LICENSE
|
58
59
|
- README.md
|
@@ -82,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
segments:
|
84
85
|
- 0
|
85
|
-
hash:
|
86
|
+
hash: -3200884025077100655
|
86
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
88
|
none: false
|
88
89
|
requirements:
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: '0'
|
92
93
|
segments:
|
93
94
|
- 0
|
94
|
-
hash:
|
95
|
+
hash: -3200884025077100655
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
98
|
rubygems_version: 1.8.24
|