rwanda 0.7.2 → 0.8.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +15 -13
- data/lib/rwanda.rb +9 -2
- data/lib/rwanda/version.rb +1 -1
- data/spec/rwanda_spec.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8fcd2d987c04671d739e62c9e910669046860b9
|
4
|
+
data.tar.gz: 89fb5f38046645dbc3197dd67024a24a4cf151d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 557b747e34beed787334854a043d9996afb91fa641807fafc3c7da04927fb88d3f717dadc31b8cf5cc8d2cd214212c0edc64cd9318837803130a9df06e47d6ae
|
7
|
+
data.tar.gz: b8ee160322159c11117afdcabd5bf248f3b619d5c37f0982ae9670847d9285d40fabc7f92a9ff2490020faa0c0a26543bfca03d3c3341e9434dd7c95ec3111cf
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,9 +34,9 @@ Then you can try it on the command line:
|
|
34
34
|
## Usage
|
35
35
|
|
36
36
|
```ruby
|
37
|
-
|
37
|
+
pry(main)> rw=Rwanda.instance
|
38
38
|
=> #<Rwanda:0x007f00ea48cf28 ... >
|
39
|
-
|
39
|
+
pry(main)> rw.where_is? 'Gasabo'
|
40
40
|
Rwanda has 1 district, 0 sectors, 1 cell, and 8 villages called Gasabo:
|
41
41
|
Gasabo is a village in Kimaranzara Cell, Rilima Sector, Bugesera District, Eastern Province
|
42
42
|
Gasabo is a village in Butiruka Cell, Remera Sector, Gatsibo District, Eastern Province
|
@@ -49,27 +49,29 @@ Rwanda has 1 district, 0 sectors, 1 cell, and 8 villages called Gasabo:
|
|
49
49
|
Gasabo is a village in Kabeza Cell, Kanombe Sector, Kicukiro District, Kigali City
|
50
50
|
Gasabo is a village in Kabuguru II Cell, Rwezamenyo Sector, Nyarugenge District, Kigali City
|
51
51
|
=> nil
|
52
|
-
|
52
|
+
pry(main)> rw.provinces
|
53
53
|
=> ["Eastern Province", "Kigali City", "Northern Province", "Southern Province", "Western Province"]
|
54
|
-
|
54
|
+
pry(main)> rw.sectors_of 'Gasabo'
|
55
55
|
=> ["Bumbogo", "Gatsata", "Gikomero", "Gisozi", "Jabana", "Jali", "Kacyiru", "Kimihurura", "Kimironko", "Kinyinya", "Ndera", "Nduba", "Remera", "Rusororo", "Rutunga"]
|
56
|
-
|
56
|
+
pry(main)> rw.district_of 'Giheke'
|
57
57
|
=> "Rusizi"
|
58
|
-
|
58
|
+
pry(main)> rw.district_of 'Busasamana' # returns array if multiple
|
59
|
+
=> ["Nyanza", "Rubavu"]
|
60
|
+
pry(main)> rw.sector_like 'Rukuma'
|
59
61
|
RuntimeError: can't modify frozen #<Class:#<Rwanda:0x007f00ea48cf28>>
|
60
62
|
from /home/slack/vendor/bundle/gems/rwanda-0.7.1/lib/rwanda.rb:87:in `sectors'
|
61
|
-
|
63
|
+
pry(main)> rw.is_district? 'Karongi'
|
62
64
|
=> true
|
63
|
-
|
65
|
+
pry(main)> rw.is_sector? 'Gashari'
|
64
66
|
=> true
|
65
|
-
|
67
|
+
pry(main)> rw.is_cell? 'Musasa'
|
66
68
|
=> true
|
67
|
-
|
69
|
+
pry(main)> rw.is_village? 'Kaduha'
|
68
70
|
=> true
|
69
|
-
|
70
|
-
|
71
|
+
pry(main)> # Rwanda#exist?(district, sector, cell, village)
|
72
|
+
pry(main)> rw.exist?('Karongi','Bwishyura','Kiniha','Nyarurembo')
|
71
73
|
=> true
|
72
|
-
|
74
|
+
pry(main)> rw.exist?('Karongi','Bwishyura','Nyarurembo')
|
73
75
|
=> false
|
74
76
|
```
|
75
77
|
|
data/lib/rwanda.rb
CHANGED
@@ -42,8 +42,15 @@ class Rwanda
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
def district_of(sector)
|
45
|
-
|
46
|
-
|
45
|
+
villages = @villages.select {|v| v.sector.downcase == sector.downcase}.collect {|v| { sector: v.sector, district: v.district } }.uniq
|
46
|
+
case villages.length
|
47
|
+
when 0
|
48
|
+
nil
|
49
|
+
when 1
|
50
|
+
villages[0][:district]
|
51
|
+
else
|
52
|
+
villages.collect {|v| v[:district] }.sort
|
53
|
+
end
|
47
54
|
end
|
48
55
|
# )) Plural Ofs ((
|
49
56
|
def districts_of(province)
|
data/lib/rwanda/version.rb
CHANGED
data/spec/rwanda_spec.rb
CHANGED
@@ -7,10 +7,16 @@ describe Rwanda do
|
|
7
7
|
# Singular Ofs
|
8
8
|
|
9
9
|
describe '.district_of' do
|
10
|
-
it 'knows the distict of a sector' do
|
10
|
+
it 'knows the distict(s) of a sector' do
|
11
|
+
# Unfortunately, there are multiple sectors with the same name in different districts
|
12
|
+
# so this cannot give a unique response all of the time
|
13
|
+
# e.g. Busasamana in Nyanza and Rubavu
|
11
14
|
expect(r.district_of('Jali')).to eq 'Gasabo'
|
12
15
|
expect(r.district_of('jAlI')).to eq 'Gasabo'
|
13
16
|
|
17
|
+
# Returns districts in alphabetical order
|
18
|
+
expect(r.district_of('Busasamana')).to eq [ 'Nyanza', 'Rubavu' ].sort
|
19
|
+
|
14
20
|
expect(r.district_of('Foobar')).to eq nil
|
15
21
|
end
|
16
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwanda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Hetherington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|