geolocalise 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82ebca67985653bf6905435ef5eb748448357c8e
4
- data.tar.gz: 3386e31ff25b4c09c1933338395919f4ed948f57
3
+ metadata.gz: 41cc5cea68db8ff6f0e898e2102fdca9be33be46
4
+ data.tar.gz: ee2c3480204a27624e01ce3e353dda7d3030416c
5
5
  SHA512:
6
- metadata.gz: 54419187ad59fc23c26c73a00345503ca85bcdf9f285d28dd9d151a5032cfc49c67e25070d5cd2ba2e0dc9f96a3685ba3b50954a113917d8cd6f8efb5d8b958e
7
- data.tar.gz: aab390bcb64c2912978f99dfaba2e0f01f3dfea4a5d9b71abaa5d5ec0a27b89b93af30ccc4cafa52750b8a2a757396f2e4cd7a79f55f3c24a443f4450a09028f
6
+ metadata.gz: 7cf8bb4d73feb0b3c2aeb14261986c76cae509e08f7450b61ba0d61bf195275c1d59ef566a38fadc79241d06394d6faf458fc5b98e032fa5389bc4264f9c8843
7
+ data.tar.gz: c5cd30d5d7dd4a5263a014d72801d25c8727fb49e66ab28bfac981bd014dfb5e649f69adba6d35c3e2a34265cda66f7e0ec95282ae93d1059e841b0c7eb2a705
@@ -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 = ["twinks14"]
9
+ spec.authors = ["Twinkal Savani"]
10
10
  spec.email = ["svnsavani0@gmail.com"]
11
11
 
12
- spec.summary = %q{Geolocalise use for get city, state, country, contry code and postal code based on co-ordinates or string(city,state,country name).}
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", "~> 3.3.0"
32
+ spec.add_development_dependency "rspec"
33
33
  spec.add_development_dependency "geocoder", "~> 1.2.9"
34
34
  end
@@ -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
- #location_is_string(location) ? Geocoder.search(location).first.city : 'Please Enter proper value'
8
- if (location =~ /[[:digit:]]/) == nil
9
- Geocoder.search(location).first.city
10
- else
11
- check_geo_cords(location) ? Geocoder.search(location).first.city : nil
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
- Geocoder.search(location).first.country
15
+ Geocoder.search(location).first.country
20
16
  else
21
- check_geo_cords(location) ? Geocoder.search(location).first.country : nil
22
- end
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
- Geocoder.search(location).first.state
23
+ Geocoder.search(location).first.state
29
24
  else
30
25
  check_geo_cords(location) ? Geocoder.search(location).first.state : nil
31
- end
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
- Geocoder.search(location).first.country_code
31
+ Geocoder.search(location).first.country_code
38
32
  else
39
33
  check_geo_cords(location) ? Geocoder.search(location).first.country_code : nil
40
- end
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
- Geocoder.search(Geocoder.coordinates(location).map(&:inspect).join(',')).first.postal_code
39
+ Geocoder.search(Geocoder.coordinates(location).map(&:inspect).join(',')).first.postal_code
48
40
  else
49
- #Geocoder.search(Geocoder.coordinates(location).map(&:inspect).join(',')).first.postal_code
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
- def self.check_geo_cords(location)
57
- #location.is_a?(String) ? location : location = location.map(&:inspect).join(',')
58
- latitude, longitude = location.split(',')[0], location.split(',')[1]
59
- if latitude.to_i >= -90 and latitude.to_i <= 90 and (latitude =~ /[[:alpha:]]/) == nil
60
- if longitude.to_i >= -180 and longitude.to_i <= 180 and (longitude =~ /[[:alpha:]]/) == nil
61
- true
62
- else
63
- false
64
- end
65
- else
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
@@ -1,3 +1,3 @@
1
1
  module Geolocalise
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - twinks14
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: 3.3.0
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: 3.3.0
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: Geolocalise use for get city, state, country, contry code and postal code
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: []