my_society-map_it 0.0.1 → 0.0.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.
- data/README.md +8 -2
- data/lib/my_society/map_it/version.rb +1 -1
- data/lib/my_society/map_it.rb +6 -2
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# MySociety::MapIt
|
2
2
|
|
3
|
-
|
3
|
+
Interact with the MySociety MapIt service.
|
4
|
+
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -16,9 +17,14 @@ Or install it yourself as:
|
|
16
17
|
|
17
18
|
$ gem install my_society-map_it
|
18
19
|
|
20
|
+
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
require 'my_society/map_it'
|
24
|
+
p = MySociety::MapIt::Postcode.new 'SE1 1EY'
|
25
|
+
la = p.local_authority
|
26
|
+
la.name # => "Southwark Borough Council"
|
27
|
+
|
22
28
|
|
23
29
|
## Contributing
|
24
30
|
|
data/lib/my_society/map_it.rb
CHANGED
@@ -19,15 +19,19 @@ module MySociety
|
|
19
19
|
|
20
20
|
module LocalAuthorityFinder
|
21
21
|
LOCAL_AUTHORITY_TYPE_CODES = %w(
|
22
|
-
DIS MTD UTA LBO CTY
|
22
|
+
DIS MTD UTA LBO CTY LGD
|
23
23
|
).map { |c| c.freeze }.freeze
|
24
24
|
|
25
25
|
def local_authority
|
26
|
-
local_authority_info = to_point.to_hash.values.
|
26
|
+
local_authority_info = to_point.to_hash.values.sort_by { |a|
|
27
|
+
LOCAL_AUTHORITY_TYPE_CODES.index(a['type']) || -1
|
28
|
+
}.detect do |la|
|
27
29
|
LOCAL_AUTHORITY_TYPE_CODES.include? la['type']
|
28
30
|
end
|
29
31
|
|
30
32
|
LocalAuthority.new local_authority_info
|
33
|
+
rescue
|
34
|
+
nil
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|