locationator 0.1.2 → 0.2.0
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 +8 -8
 - data/Gemfile.lock +1 -1
 - data/lib/locationator.rb +14 -9
 - data/lib/locationator/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                ZTkxZGU5ZTZkODY4MDQ5OWI1YjhkMDA1YzRiZjAzODgzNWMwNGViZA==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                MjZlNjAwMzM2MGI0MWQyN2VkMjJkOTkxYWIzZmE0M2IyNzMyYWQyZA==
         
     | 
| 
       7 
7 
     | 
    
         
             
            !binary "U0hBNTEy":
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                NWExZGE2ZjU4NWI1Zjk3NmUwOWU5ZDUxZWViN2Q0NWNiNThhYjMyNTRkNzAw
         
     | 
| 
      
 10 
     | 
    
         
            +
                MTRjYmY0NDA2MmMwZTk5M2NmMjRhYzY2ZWI3NmI2N2M2MzVlOTI5ZDNmZjUz
         
     | 
| 
      
 11 
     | 
    
         
            +
                ZTgzZDk4ZWE5YTQ5MDBlNWRjZWYyMDM0N2Q4NGI5NjcxZDBlNjk=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                NDg4YWE3YWE1Mzc0YjAwM2QxYzg5YjNlYmY0ZjQ3ZDliMDhlMjlmMjFiYTc5
         
     | 
| 
      
 14 
     | 
    
         
            +
                ODg5YTcyOWIzY2FhYjczMTQ1OWRhYmE0ZTM4MWZhZTE4MGZkNDAyOWFmMWJh
         
     | 
| 
      
 15 
     | 
    
         
            +
                MDYyMzdkZDE5ZWU1MTg2ZWE5NmUwNTVlMGJhODc0OWZhYjdlNjg=
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/locationator.rb
    CHANGED
    
    | 
         @@ -8,28 +8,33 @@ module Locationator 
     | 
|
| 
       8 
8 
     | 
    
         
             
              # Returns the latitude
         
     | 
| 
       9 
9 
     | 
    
         
             
              def self.lat(address)
         
     | 
| 
       10 
10 
     | 
    
         
             
                geocodeResponse = get_data(address)
         
     | 
| 
       11 
     | 
    
         
            -
                result = geocodeResponse["status"] == "ZERO_RESULTS" ?  
     | 
| 
      
 11 
     | 
    
         
            +
                result = geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lat"]
         
     | 
| 
       12 
12 
     | 
    
         
             
              end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
              # Returns the longitude
         
     | 
| 
       15 
15 
     | 
    
         
             
              def self.lng(address)
         
     | 
| 
       16 
16 
     | 
    
         
             
                geocodeResponse = get_data(address)
         
     | 
| 
       17 
     | 
    
         
            -
                result = geocodeResponse["status"] == "ZERO_RESULTS" ?  
     | 
| 
      
 17 
     | 
    
         
            +
                result = geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lng"]
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              # Builds an array of the latitude and longitude
         
     | 
| 
       21 
21 
     | 
    
         
             
              def self.lat_lng(address)
         
     | 
| 
       22 
     | 
    
         
            -
                 
     | 
| 
       23 
     | 
    
         
            -
                 
     | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
       25 
     | 
    
         
            -
                 
     | 
| 
      
 22 
     | 
    
         
            +
                myArray = []
         
     | 
| 
      
 23 
     | 
    
         
            +
                geocodeResponse = get_data(address)
         
     | 
| 
      
 24 
     | 
    
         
            +
                myArray.push(geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lat"])
         
     | 
| 
      
 25 
     | 
    
         
            +
                myArray.push(geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["geometry"]["location"]["lng"])
         
     | 
| 
      
 26 
     | 
    
         
            +
                if myArray == [nil, nil]
         
     | 
| 
      
 27 
     | 
    
         
            +
                  result = nil
         
     | 
| 
      
 28 
     | 
    
         
            +
                else
         
     | 
| 
      
 29 
     | 
    
         
            +
                  result = myArray
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
       26 
31 
     | 
    
         
             
              end
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
33 
     | 
    
         
             
              # Returns the zip code for an address
         
     | 
| 
       29 
34 
     | 
    
         
             
              def self.zip(address)
         
     | 
| 
       30 
35 
     | 
    
         
             
                geocodeResponse = get_data(address)
         
     | 
| 
       31 
36 
     | 
    
         
             
                if geocodeResponse["status"] == "ZERO_RESULTS"
         
     | 
| 
       32 
     | 
    
         
            -
                  zip =  
     | 
| 
      
 37 
     | 
    
         
            +
                  zip = nil
         
     | 
| 
       33 
38 
     | 
    
         
             
                else
         
     | 
| 
       34 
39 
     | 
    
         
             
                  components = geocodeResponse["results"][0]["address_components"]
         
     | 
| 
       35 
40 
     | 
    
         
             
                  # The postal code is always the last address component returned
         
     | 
| 
         @@ -41,7 +46,7 @@ module Locationator 
     | 
|
| 
       41 
46 
     | 
    
         
             
              # Returns a properly formatted address
         
     | 
| 
       42 
47 
     | 
    
         
             
              def self.format(address)
         
     | 
| 
       43 
48 
     | 
    
         
             
                geocodeResponse = get_data(address)
         
     | 
| 
       44 
     | 
    
         
            -
                result = geocodeResponse["status"] == "ZERO_RESULTS" ?  
     | 
| 
      
 49 
     | 
    
         
            +
                result = geocodeResponse["status"] == "ZERO_RESULTS" ? nil : geocodeResponse["results"][0]["formatted_address"] 
         
     | 
| 
       45 
50 
     | 
    
         
             
              end
         
     | 
| 
       46 
51 
     | 
    
         | 
| 
       47 
52 
     | 
    
         
             
              # Returns the latitude based on the current user's IP address
         
     | 
| 
         @@ -59,7 +64,7 @@ module Locationator 
     | 
|
| 
       59 
64 
     | 
    
         
             
              # Returns an array of the latitude and longitude based on the current user's IP address
         
     | 
| 
       60 
65 
     | 
    
         
             
              def self.ip_lat_lng
         
     | 
| 
       61 
66 
     | 
    
         
             
                myArray = []
         
     | 
| 
       62 
     | 
    
         
            -
                geocodeResponse =  
     | 
| 
      
 67 
     | 
    
         
            +
                geocodeResponse = get_ip_data
         
     | 
| 
       63 
68 
     | 
    
         
             
                myArray.push(geocodeResponse["latitude"])
         
     | 
| 
       64 
69 
     | 
    
         
             
                myArray.push(geocodeResponse["longitude"])
         
     | 
| 
       65 
70 
     | 
    
         
             
                result = myArray
         
     | 
    
        data/lib/locationator/version.rb
    CHANGED