google_tz 0.1.0 → 0.2.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 +4 -4
- data/Gemfile.lock +1 -1
- data/Histroy.md +11 -0
- data/README.md +13 -1
- data/google_tz.gemspec +1 -1
- data/lib/google_tz.rb +3 -4
- data/lib/google_tz/query.rb +8 -6
- data/lib/google_tz/version.rb +2 -2
- data/spec/lib/google_tz_spec.rb +24 -0
- metadata +3 -3
- data/spec/google_tz_spec.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfb55e775c573bb3937d9a71baf7b24ff6731624
|
4
|
+
data.tar.gz: f34371134c4dd9fa189cf64b0b92010cd7d07428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 217e3b871c06610b52a190103acf35cca710aab713ba4eb414a3fcfb7e641e8574b09c740eb9a50243e4e089a5807e43211fb8f5ced552b76ebb30ac1cb5e171
|
7
|
+
data.tar.gz: 160e7a0ab217f718a57181f4621591127921939a5f58f800308faf413033804a227170823bddb4d49ccb95ae4ce723f86ad76023fc43a96056cfd558d4c32245
|
data/Gemfile.lock
CHANGED
data/Histroy.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
+
## 0.2.1 / 2013-08-30
|
4
|
+
|
5
|
+
### Development Fixes
|
6
|
+
* move spec to correct folder
|
7
|
+
|
8
|
+
## 0.2.0 / 2013-08-30
|
9
|
+
|
10
|
+
### Major Enhancements
|
11
|
+
* Make timestamp optional
|
12
|
+
* Add sensor and language optional arguments
|
13
|
+
|
3
14
|
## 0.1.0 / 2013-08-29
|
4
15
|
|
5
16
|
### Minor Enhancements
|
data/README.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
# GoogleTZ
|
2
|
+
##### Get timezone information for a location from the [Google Timezone API](https://developers.google.com/maps/documentation/timezone/) using the locations latitude, longitude, and optionally a timestamp, sensor, and language.
|
2
3
|
|
3
|
-
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
gem install google_tz
|
4
7
|
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
require 'google_tz'
|
11
|
+
|
12
|
+
# Lookup timezone information on a location using latitude and longitude.
|
13
|
+
GoogleTZ.lookup(39.7392, -104.9847)
|
14
|
+
|
15
|
+
# Lookup timezone infomration on a location using latitude, longitude, timestamp, and language
|
16
|
+
GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, language: "es")
|
data/google_tz.gemspec
CHANGED
@@ -3,7 +3,7 @@ require "google_tz/version"
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'google_tz'
|
6
|
-
s.version =
|
6
|
+
s.version = GoogleTZAPI::VERSION
|
7
7
|
s.date = '2013-08-28'
|
8
8
|
s.summary = "Get timezone information for a latitude, longitude, and optional timestamp."
|
9
9
|
s.description = "Get timezone information for a location from the Google Timezone API (https://developers.google.com/maps/documentation/timezone/) using the locations latitude, longitude, and optionally a timestamp."
|
data/lib/google_tz.rb
CHANGED
data/lib/google_tz/query.rb
CHANGED
@@ -2,12 +2,14 @@ require 'net/http'
|
|
2
2
|
require 'uri'
|
3
3
|
require 'openssl'
|
4
4
|
|
5
|
-
module
|
5
|
+
module GoogleTZAPI
|
6
6
|
class Query
|
7
|
-
def initialize(lat, lng,
|
8
|
-
@lat=lat
|
9
|
-
@lng=lng
|
10
|
-
@timestamp=timestamp
|
7
|
+
def initialize(lat, lng, opts)
|
8
|
+
@lat = lat
|
9
|
+
@lng = lng
|
10
|
+
@timestamp = opts[:timestamp] || Time.now.to_i
|
11
|
+
@sensor = opts[:sensor] || false
|
12
|
+
@language = opts[:language] || "en"
|
11
13
|
end
|
12
14
|
|
13
15
|
def lookup
|
@@ -18,7 +20,7 @@ module GoogleTZ
|
|
18
20
|
private
|
19
21
|
def build_uri
|
20
22
|
uri = URI.parse("https://maps.googleapis.com/maps/api/timezone/json")
|
21
|
-
args = { :location => "#{@lat},#{@lng}", timestamp: @timestamp, sensor:
|
23
|
+
args = { :location => "#{@lat},#{@lng}", timestamp: @timestamp, sensor: @sensor, language: @language }
|
22
24
|
uri.query = URI.encode_www_form(args)
|
23
25
|
uri
|
24
26
|
end
|
data/lib/google_tz/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '0.1
|
1
|
+
module GoogleTZAPI
|
2
|
+
VERSION = '0.2.1'
|
3
3
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'GoogleTZ' do
|
4
|
+
describe 'lookup' do
|
5
|
+
it 'fetches timezone info for a given latitude, longitude' do
|
6
|
+
response = GoogleTZ.lookup(39.7392, -104.9847)
|
7
|
+
|
8
|
+
response.should_not be_nil
|
9
|
+
response.should == "{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Mountain Daylight Time\"\n}\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'fetches timezone info when given optional arguments' do
|
13
|
+
response = GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, sensor: false, language: "de")
|
14
|
+
|
15
|
+
response.should_not be_nil
|
16
|
+
response.should == "{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Rocky Mountain Sommerzeit\"\n}\n"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
"{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Hora de verano de Montaña\"\n}\n"
|
24
|
+
'{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Hora de verano de Monta\\xC3\\xB1a\"\n}\n'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_tz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel McGraw
|
@@ -60,7 +60,7 @@ files:
|
|
60
60
|
- lib/google_tz.rb
|
61
61
|
- lib/google_tz/query.rb
|
62
62
|
- lib/google_tz/version.rb
|
63
|
-
- spec/google_tz_spec.rb
|
63
|
+
- spec/lib/google_tz_spec.rb
|
64
64
|
- spec/spec_helper.rb
|
65
65
|
homepage: http://github.com/danielmcgraw/google_tz
|
66
66
|
licenses:
|
@@ -87,5 +87,5 @@ signing_key:
|
|
87
87
|
specification_version: 4
|
88
88
|
summary: Get timezone information for a latitude, longitude, and optional timestamp.
|
89
89
|
test_files:
|
90
|
-
- spec/google_tz_spec.rb
|
90
|
+
- spec/lib/google_tz_spec.rb
|
91
91
|
- spec/spec_helper.rb
|
data/spec/google_tz_spec.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GoogleTZ do
|
4
|
-
describe 'lookup' do
|
5
|
-
it 'fetches timezone info for a given latitude, longitude, and timestamp' do
|
6
|
-
response = GoogleTZ.lookup(39.7392, -104.9847, 1377754760)
|
7
|
-
|
8
|
-
response.should_not be_nil
|
9
|
-
response.should == "{\n \"dstOffset\" : 3600,\n \"rawOffset\" : -25200,\n \"status\" : \"OK\",\n \"timeZoneId\" : \"America/Denver\",\n \"timeZoneName\" : \"Mountain Daylight Time\"\n}\n"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|