locotimezone 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c86c7b42877e96caf8e4448343121a107ba9f2f0
4
- data.tar.gz: f0a5aa2dafb18f4e66d0255cee959a9e16f2c1e1
3
+ metadata.gz: 07547b6a8ba51d66d7c3d340bc72d35534d56139
4
+ data.tar.gz: 3302d3c92771dbdb75556c8d60ba9f723e367c20
5
5
  SHA512:
6
- metadata.gz: 8e55cf04e424a7c6b594ab96f259071dc880274b744999f94cc0de709541583c993d92e99bd79b62d9b642ae4c4c46521bfbb69a9356b2eb097eff6a764752f3
7
- data.tar.gz: 5aee7cd402ef6db9d71d01043b01bd6a7e75b3f55bbbf6a54f51d3de764350e6862caecd0e1f4567a0f9beb277100f7a1965d96130c2116502ebcea1aa783733
6
+ metadata.gz: 5f243ab7d8937838a4e0c7b97a1edb61f713d0827b000d704bab8077af58e706514916bbdd3431f925a972f22699e71986ca35e3ec5982b5650e3100cb4a2afa
7
+ data.tar.gz: 5056d75567b48464ff9857b779e1e02fd2bdd0d5b55f8ae60288b477dbaf261e3f03758ec58259cac76f111e770d3a964c19a5583667d8de3aa278263f888132
data/README.md CHANGED
@@ -84,16 +84,29 @@ Locotimezone.locotime location: { lat: 0, lng: 0 }
84
84
 
85
85
  `Locotimezone.locotime` can take the following option hash keys:
86
86
  * `:address` is a string representation of a street address. This is required except when `timezone_only: true`.
87
- * `:location` is required only when `timezone_only: true`. The corresponding
88
- value is a hash containing the latitude and longitude: `{ lat: 26.1288238, lng: -80.1449743 }`.
87
+ * `:location` is a hash containing the latitude and longitude: `{ lat: 26.1288238, lng: -80.1449743 }`. When passing a location hash, the call to Google Maps Geolocation API is skipped.
89
88
  * `:key` is for your Google API key. This is not required but recommended if you
90
89
  want higher API quota. Create an API key and enable APIs in your [Google
91
90
  Developer Console](https://console.developers.google.com). As an alternative
92
91
  to passing the `:key` everytime, simply set `GOOGLE_API_KEY` environment variable.
93
- * `location_only: true` skips the call to Google Maps Timezone API. Geolocation only.
94
- * `timezone_only: true` skips the call to Google Maps Geolocation API. Gets only the
95
- timezone data for the specified `:location`. When `timezone_only: true`, you
96
- must inlcude the `:location` hash (see above).
92
+ * `skip: :timezone` skips the call to Google Maps Timezone API. For geolocation,
93
+ only.
94
+
95
+ ## Command Line Utility
96
+
97
+ Use the command-line utility to convert an address.
98
+
99
+ ```shell
100
+ $ locotimezone 525 NW 1st Ave Fort Lauderdale, FL 33301
101
+ {:geo=>{:formatted_address=>"150 NW 1st Ave, Fort Lauderdale, FL 33301, USA", :location=>{:lat=>26.1222723, :lng=>-80.1445756}}, :timezone=>{:timezone_id=>"America/New_York", :timezone_name=>"Eastern Daylight Time"}}
102
+ ```
103
+
104
+ Use the command-line utility to get timezone data for latitude and longitude
105
+
106
+ ```shell
107
+ $ locotimezone -l 26.1288238,-80.1449743
108
+ {:timezone=>{:timezone_id=>"America/New_York", :timezone_name=>"Eastern Daylight Time"}}
109
+ ```
97
110
 
98
111
  ## Versions of Ruby
99
112
 
data/bin/locotimezone ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/locotimezone'
4
+ require 'optparse'
5
+
6
+ parser = OptionParser.new do |opts|
7
+ opts.banner = 'Usage: locotimezone [options] command'
8
+ opts.separator ''
9
+ opts.separator 'Options:'
10
+ opts.on('-l', '--location [LAT,LNG]', 'Get timezone data from latitude and' \
11
+ ' longitude') do |lat_lng|
12
+ timezone_data(lat_lng)
13
+ end
14
+ opts.on('-h', '--help', 'Show this message') do
15
+ puts opts
16
+ exit
17
+ end
18
+ end
19
+
20
+ def timezone_data(lat_lng)
21
+ location_array = lat_lng.split(',')
22
+ location_hash = Hash[
23
+ lat: location_array[0].to_f,
24
+ lng: location_array[1].to_f
25
+ ]
26
+ puts location_hash
27
+ puts Locotimezone.locotime location: location_hash
28
+ exit
29
+ end
30
+
31
+ parser.parse!
32
+ address = ARGV.join(' ')
33
+
34
+ puts Locotimezone.locotime address: address
35
+
36
+
@@ -1,3 +1,3 @@
1
1
  module Locotimezone
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locotimezone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Miller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-30 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,7 @@ files:
80
80
  - README.md
81
81
  - Rakefile
82
82
  - bin/console
83
+ - bin/locotimezone
83
84
  - bin/setup
84
85
  - lib/locotimezone.rb
85
86
  - lib/locotimezone/location.rb