my_society-map_it 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # MySociety::MapIt
2
2
 
3
- TODO: Write a gem description
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
- TODO: Write usage instructions here
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
 
@@ -1,5 +1,5 @@
1
1
  module MySociety
2
2
  module MapIt
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -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.detect do |la|
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_society-map_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: