locations_ng 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/locations_ng/city.rb +4 -4
- data/lib/locations_ng/lga.rb +4 -4
- data/lib/locations_ng/state.rb +7 -7
- data/lib/locations_ng/version.rb +1 -1
- data/spec/locations_ng/city_spec.rb +1 -1
- data/spec/locations_ng/lga_spec.rb +1 -1
- data/spec/locations_ng/state_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93aac4c83695e75a4cb21172cb5f5ae8d59e9397
|
4
|
+
data.tar.gz: 1818a9e75bf2a78d0c58da85d0b127d2b0e28486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a80cd8305107e43b24513fd9ecf34b812676050891f18cee0a21d9442e1e7687390db404ed3643a22417487e67380dea6462df52b3c7950e8925d6010467357c
|
7
|
+
data.tar.gz: 2e071f238c8f31d74231188669cadf893202069ca9997fa6daedd785ec7d15530c4506a61338cd8ef4c4da7b3bc936f03ae32f7ec9f938253efca6998542e40e
|
data/lib/locations_ng/city.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module LocationsNg
|
2
2
|
class City
|
3
|
-
def all
|
3
|
+
def self.all
|
4
4
|
load_cities
|
5
5
|
end
|
6
6
|
|
7
|
-
def cities(state)
|
7
|
+
def self.cities(state)
|
8
8
|
state = state.downcase.gsub(' ', '_')
|
9
9
|
all_cities = load_cities
|
10
10
|
|
@@ -19,11 +19,11 @@ module LocationsNg
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def load_cities
|
22
|
+
def self.load_cities
|
23
23
|
YAML.load(File.read(files_location 'cities'))
|
24
24
|
end
|
25
25
|
|
26
|
-
def files_location(file)
|
26
|
+
def self.files_location(file)
|
27
27
|
File.expand_path("../locations/#{file}.yml", __FILE__)
|
28
28
|
end
|
29
29
|
end
|
data/lib/locations_ng/lga.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module LocationsNg
|
2
2
|
class Lga
|
3
|
-
def all
|
3
|
+
def self.all
|
4
4
|
load_lgas
|
5
5
|
end
|
6
6
|
|
7
|
-
def lgas(state)
|
7
|
+
def self.lgas(state)
|
8
8
|
state = state.downcase.gsub(' ', '_')
|
9
9
|
all_lgas = load_lgas
|
10
10
|
|
@@ -19,11 +19,11 @@ module LocationsNg
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def load_lgas
|
22
|
+
def self.load_lgas
|
23
23
|
YAML.load(File.read(files_location 'lgas'))
|
24
24
|
end
|
25
25
|
|
26
|
-
def files_location(file)
|
26
|
+
def self.files_location(file)
|
27
27
|
File.expand_path("../locations/#{file}.yml", __FILE__)
|
28
28
|
end
|
29
29
|
end
|
data/lib/locations_ng/state.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module LocationsNg
|
2
2
|
class State
|
3
|
-
def all
|
3
|
+
def self.all
|
4
4
|
load_states.map{ |s| {name: s['name'], capital: s['capital']} }
|
5
5
|
end
|
6
6
|
|
7
|
-
def details(state)
|
7
|
+
def self.details(state)
|
8
8
|
state = state.downcase.gsub(' ', '_')
|
9
9
|
all_states = load_states
|
10
10
|
|
@@ -14,13 +14,13 @@ module LocationsNg
|
|
14
14
|
{message: "No state found for '#{state}'", status: 404}
|
15
15
|
else
|
16
16
|
res = all_states[state_index].with_indifferent_access
|
17
|
-
res['cities'] = LocationsNg::City.
|
18
|
-
res['lgas'] = LocationsNg::Lga.
|
17
|
+
res['cities'] = LocationsNg::City.cities(state)
|
18
|
+
res['lgas'] = LocationsNg::Lga.lgas(state)
|
19
19
|
res
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def capital(state)
|
23
|
+
def self.capital(state)
|
24
24
|
state = state.downcase.gsub(' ', '_')
|
25
25
|
all_states = load_states
|
26
26
|
|
@@ -35,11 +35,11 @@ module LocationsNg
|
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
|
-
def load_states
|
38
|
+
def self.load_states
|
39
39
|
YAML.load(File.read(files_location 'states'))
|
40
40
|
end
|
41
41
|
|
42
|
-
def files_location(file)
|
42
|
+
def self.files_location(file)
|
43
43
|
File.expand_path("../locations/#{file}.yml", __FILE__)
|
44
44
|
end
|
45
45
|
end
|
data/lib/locations_ng/version.rb
CHANGED