ReverseGeo 0.2.2 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/reverse_geo/reverse_geo.rb +12 -2
  3. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1a7e7d8c3a52cda0499de41bc1fac5a96bb203d
4
- data.tar.gz: bf22086853eaf3ffed65a3172733fd11917a6652
3
+ metadata.gz: f2a3be365f753d4ad62dd8d242ec869bc625a1ed
4
+ data.tar.gz: 77f31f83877980a5b3fa8fdfb7c4a8c4e505aa79
5
5
  SHA512:
6
- metadata.gz: 57034ccfec951b7aed31d7dc3df9adcede9100ce36934a1f3e52ab68a62ce34f125740c1024c39b254a05e5f1c3a652838542c5d6a158cce3805967fd3a4022e
7
- data.tar.gz: d5dcbd46f37986ed1f77fd71ccf656f81fae73c99d45890f6145ac448cadd16eede889ea60759fb569ebcd60aa38501d3b9a404649f99a41fcfe1d29600f3d9b
6
+ metadata.gz: e2b92a142fd6cb692c352d280053885b32076a8d5d028678582dfebc94ab0a6a6f73f645ac9292d5527d892f88f8e4adc4c696b12b3ebc088aa0b83afc679b97
7
+ data.tar.gz: 70868c6ebe000d884a29a231e18d4e280d29c80ab91f43a4f3680b70cdfc729162506c4673a3604ed6c31bad069e19dc11943a66d7d3ccc9a88b12b4b0793cfe
@@ -12,14 +12,24 @@ class ReverseGeo
12
12
  @countries = RGeo::GeoJSON.decode(File.open(file).read, :json_parser => :json, :geo_factory => @factory)
13
13
  end
14
14
 
15
+ def country_code(opts = {})
16
+ country_search('ISO_A3', opts)
17
+ end
18
+
15
19
  def country(opts = {})
20
+ country_search('Country', opts)
21
+ end
22
+
23
+ private
24
+
25
+ def country_search(property_name, opts)
16
26
  raise ArgumentError, "Did not supply a valid lat ([-90,90]) and lng ([-180,180]). You supplied lat: #{opts[:lat]}, lng: #{opts[:lng]}" unless opts[:lat] && opts[:lat].between?(-90, 90) && opts[:lng] && opts[:lng].between?(-180, 180)
17
27
 
18
28
  poi = @factory.point(opts[:lng], opts[:lat])
19
29
  @countries.each do |country|
20
- return country.properties['ISO_A3'] if poi.within?(country.geometry)
30
+ return country.properties[property_name] if poi.within?(country.geometry)
21
31
  end
22
32
 
23
- return nil#fallback if we didn't find anything
33
+ nil#fallback if we didn't find anything
24
34
  end
25
35
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ReverseGeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luka Mirosevic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgeo
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rgeo-geojson
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.2'
41
41
  description:
@@ -45,8 +45,8 @@ extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
47
  - lib/reverse_geo.rb
48
- - lib/reverse_geo/reverse_geo.rb
49
48
  - lib/reverse_geo/World-EEZ.geojson
49
+ - lib/reverse_geo/reverse_geo.rb
50
50
  homepage: https://github.com/lmirosevic/ReverseGeo
51
51
  licenses:
52
52
  - Apache License 2.0
@@ -57,17 +57,17 @@ require_paths:
57
57
  - lib
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - '>='
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 2.0.3
70
+ rubygems_version: 2.2.1
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: A gem for reverse geocoding lat/lng pairs into a 3 letter ISO country code,