google_tz 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Histroy.md +5 -0
- data/google_tz.gemspec +1 -1
- data/lib/google_tz.rb +3 -0
- data/lib/google_tz/query.rb +1 -1
- data/lib/google_tz/response.rb +37 -0
- data/lib/google_tz/version.rb +1 -1
- data/spec/lib/google_tz_spec.rb +14 -6
- metadata +4 -5
- data/bin/google_tz +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebac84f78b5c7163a62ab7987aad8c49974a8278
|
4
|
+
data.tar.gz: 9d223135d1bd84a46d233857630fed328d49d2da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35814a140a8526aa299dcca006d130db60118c925802a5eb3f57f69b36f57fa8fc5f1265c05a3e8ce7a62dc358f60fa0a596b399b82c6a8b4c97de9b1fec127b
|
7
|
+
data.tar.gz: 1260fc9024a09442ab7b8712fb8f1da75480714bec45e8718607268a971658f450575b030f5b5b4e395c729616f2ac47717c97b06eeef7aba974a4e309435e17
|
data/Gemfile.lock
CHANGED
data/Histroy.md
CHANGED
data/google_tz.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "google_tz/version"
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'google_tz'
|
6
6
|
s.version = GoogleTZAPI::VERSION
|
7
|
-
s.date = '2013-
|
7
|
+
s.date = '2013-09-02'
|
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."
|
10
10
|
s.authors = ["Daniel McGraw"]
|
data/lib/google_tz.rb
CHANGED
data/lib/google_tz/query.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module GoogleTZAPI
|
4
|
+
class Response
|
5
|
+
def initialize(json)
|
6
|
+
@data = JSON.parse(json)
|
7
|
+
end
|
8
|
+
|
9
|
+
def success?
|
10
|
+
@data['status'].eql?('OK')
|
11
|
+
end
|
12
|
+
|
13
|
+
def dst_offset
|
14
|
+
@data.fetch('dstOffset', nil)
|
15
|
+
end
|
16
|
+
|
17
|
+
def raw_offset
|
18
|
+
@data.fetch('rawOffset', nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
def status
|
22
|
+
@data.fetch('status')
|
23
|
+
end
|
24
|
+
|
25
|
+
def timezone_id
|
26
|
+
@data.fetch('timeZoneId', nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
def timezone_name
|
30
|
+
@data.fetch('timeZoneName', nil)
|
31
|
+
end
|
32
|
+
|
33
|
+
def data
|
34
|
+
@data
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/google_tz/version.rb
CHANGED
data/spec/lib/google_tz_spec.rb
CHANGED
@@ -3,17 +3,25 @@ require 'spec_helper'
|
|
3
3
|
describe 'GoogleTZ' do
|
4
4
|
describe 'lookup' do
|
5
5
|
it 'fetches timezone info for a given latitude, longitude' do
|
6
|
-
|
6
|
+
resp = GoogleTZ.lookup(39.7392, -104.9847)
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
resp.success?.should == true
|
9
|
+
resp.status.should == 'OK'
|
10
|
+
resp.dst_offset.should == 3600
|
11
|
+
resp.raw_offset.should == -25200
|
12
|
+
resp.timezone_id.should == "America/Denver"
|
13
|
+
resp.timezone_name.should == "Mountain Daylight Time"
|
10
14
|
end
|
11
15
|
|
12
16
|
it 'fetches timezone info when given optional arguments' do
|
13
|
-
|
17
|
+
resp = GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, sensor: false, language: "de")
|
14
18
|
|
15
|
-
|
16
|
-
|
19
|
+
resp.success?.should == true
|
20
|
+
resp.status.should == 'OK'
|
21
|
+
resp.dst_offset.should == 3600
|
22
|
+
resp.raw_offset.should == -25200
|
23
|
+
resp.timezone_id.should == "America/Denver"
|
24
|
+
resp.timezone_name.should == "Rocky Mountain Sommerzeit"
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_tz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel McGraw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -42,8 +42,7 @@ description: Get timezone information for a location from the Google Timezone AP
|
|
42
42
|
(https://developers.google.com/maps/documentation/timezone/) using the locations
|
43
43
|
latitude, longitude, and optionally a timestamp.
|
44
44
|
email: dan.j.mcgraw@gmail.com
|
45
|
-
executables:
|
46
|
-
- google_tz
|
45
|
+
executables: []
|
47
46
|
extensions: []
|
48
47
|
extra_rdoc_files: []
|
49
48
|
files:
|
@@ -55,10 +54,10 @@ files:
|
|
55
54
|
- LICENSE
|
56
55
|
- README.md
|
57
56
|
- Rakefile
|
58
|
-
- bin/google_tz
|
59
57
|
- google_tz.gemspec
|
60
58
|
- lib/google_tz.rb
|
61
59
|
- lib/google_tz/query.rb
|
60
|
+
- lib/google_tz/response.rb
|
62
61
|
- lib/google_tz/version.rb
|
63
62
|
- spec/lib/google_tz_spec.rb
|
64
63
|
- spec/spec_helper.rb
|
data/bin/google_tz
DELETED