geolocalise 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/geolocalise.gemspec +3 -3
- data/lib/geolocalise.rb +25 -39
- data/lib/geolocalise/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41cc5cea68db8ff6f0e898e2102fdca9be33be46
|
4
|
+
data.tar.gz: ee2c3480204a27624e01ce3e353dda7d3030416c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cf8bb4d73feb0b3c2aeb14261986c76cae509e08f7450b61ba0d61bf195275c1d59ef566a38fadc79241d06394d6faf458fc5b98e032fa5389bc4264f9c8843
|
7
|
+
data.tar.gz: c5cd30d5d7dd4a5263a014d72801d25c8727fb49e66ab28bfac981bd014dfb5e649f69adba6d35c3e2a34265cda66f7e0ec95282ae93d1059e841b0c7eb2a705
|
data/geolocalise.gemspec
CHANGED
@@ -6,10 +6,10 @@ require 'geolocalise/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "geolocalise"
|
8
8
|
spec.version = Geolocalise::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["Twinkal Savani"]
|
10
10
|
spec.email = ["svnsavani0@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
12
|
+
spec.summary = %q{A Gem to get city, state, country, contry code and postal code.}
|
13
13
|
spec.description = %q{}
|
14
14
|
spec.homepage = "https://github.com/twinks14/geolocalise"
|
15
15
|
spec.license = "MIT"
|
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.10"
|
31
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
-
spec.add_development_dependency "rspec"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
33
|
spec.add_development_dependency "geocoder", "~> 1.2.9"
|
34
34
|
end
|
data/lib/geolocalise.rb
CHANGED
@@ -2,72 +2,58 @@ require "geolocalise/version"
|
|
2
2
|
require 'geocoder'
|
3
3
|
|
4
4
|
module Geolocalise
|
5
|
-
# Your code goes here...
|
6
5
|
def self.get_city(location)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
#check_geo_cords(location) ? Geocoder.search(location).first.city : "Please Enter proper co-ordinates"
|
6
|
+
if (location =~ /[[:digit:]]/) == nil
|
7
|
+
Geocoder.search(location).first.city
|
8
|
+
else
|
9
|
+
check_geo_cords(location) ? Geocoder.search(location).first.city : nil
|
10
|
+
end
|
14
11
|
end
|
15
12
|
|
16
13
|
def self.get_country(location)
|
17
|
-
#location_is_string(location) ? Geocoder.search(location).first.country : 'Please Enter proper value'
|
18
14
|
if (location =~ /[[:digit:]]/) == nil
|
19
|
-
|
15
|
+
Geocoder.search(location).first.country
|
20
16
|
else
|
21
|
-
|
22
|
-
|
17
|
+
check_geo_cords(location) ? Geocoder.search(location).first.country : nil
|
18
|
+
end
|
23
19
|
end
|
24
20
|
|
25
21
|
def self.get_state(location)
|
26
|
-
#location_is_string(location) ? Geocoder.search(location).first.state : 'Please Enter proper value'
|
27
22
|
if (location =~ /[[:digit:]]/) == nil
|
28
|
-
|
23
|
+
Geocoder.search(location).first.state
|
29
24
|
else
|
30
25
|
check_geo_cords(location) ? Geocoder.search(location).first.state : nil
|
31
|
-
|
26
|
+
end
|
32
27
|
end
|
33
28
|
|
34
29
|
def self.get_country_code(location)
|
35
|
-
#location_is_string(location) ? Geocoder.search(location).first.country_code : 'Please Enter proper value'
|
36
30
|
if (location =~ /[[:digit:]]/) == nil
|
37
|
-
|
31
|
+
Geocoder.search(location).first.country_code
|
38
32
|
else
|
39
33
|
check_geo_cords(location) ? Geocoder.search(location).first.country_code : nil
|
40
|
-
|
34
|
+
end
|
41
35
|
end
|
42
36
|
|
43
37
|
def self.get_postal_code(location)
|
44
|
-
#check_geo_cords(location) ? Geocoder.search(location).first.postal_code : "Please Enter proper co-ordinates"
|
45
|
-
#cords = Geocoder.coordinates(location)
|
46
38
|
if (location =~ /[[:digit:]]/) == nil
|
47
|
-
|
39
|
+
Geocoder.search(Geocoder.coordinates(location).map(&:inspect).join(',')).first.postal_code
|
48
40
|
else
|
49
|
-
|
50
|
-
check_geo_cords(location) ? Geocoder.search(location).first.postal_code : nil
|
41
|
+
check_geo_cords(location) ? Geocoder.search(location).first.postal_code : nil
|
51
42
|
end
|
52
43
|
end
|
53
44
|
|
54
45
|
private
|
55
46
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
false
|
67
|
-
end
|
47
|
+
def self.check_geo_cords(location)
|
48
|
+
latitude, longitude = location.split(',')[0], location.split(',')[1]
|
49
|
+
if latitude.to_i >= -90 and latitude.to_i <= 90 and (latitude =~ /[[:alpha:]]/) == nil
|
50
|
+
if longitude.to_i >= -180 and longitude.to_i <= 180 and (longitude =~ /[[:alpha:]]/) == nil
|
51
|
+
true
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
else
|
56
|
+
false
|
68
57
|
end
|
69
|
-
|
70
|
-
# def self.location_is_string(location)
|
71
|
-
# (location =~ /[[:digit:]]/) == nil
|
72
|
-
# end
|
58
|
+
end
|
73
59
|
end
|
data/lib/geolocalise/version.rb
CHANGED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geolocalise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Twinkal Savani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: geocoder
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +109,5 @@ rubyforge_project:
|
|
109
109
|
rubygems_version: 2.2.2
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
|
-
summary:
|
113
|
-
based on co-ordinates or string(city,state,country name).
|
112
|
+
summary: A Gem to get city, state, country, contry code and postal code.
|
114
113
|
test_files: []
|