google_tz 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfb55e775c573bb3937d9a71baf7b24ff6731624
4
- data.tar.gz: f34371134c4dd9fa189cf64b0b92010cd7d07428
3
+ metadata.gz: ebac84f78b5c7163a62ab7987aad8c49974a8278
4
+ data.tar.gz: 9d223135d1bd84a46d233857630fed328d49d2da
5
5
  SHA512:
6
- metadata.gz: 217e3b871c06610b52a190103acf35cca710aab713ba4eb414a3fcfb7e641e8574b09c740eb9a50243e4e089a5807e43211fb8f5ced552b76ebb30ac1cb5e171
7
- data.tar.gz: 160e7a0ab217f718a57181f4621591127921939a5f58f800308faf413033804a227170823bddb4d49ccb95ae4ce723f86ad76023fc43a96056cfd558d4c32245
6
+ metadata.gz: 35814a140a8526aa299dcca006d130db60118c925802a5eb3f57f69b36f57fa8fc5f1265c05a3e8ce7a62dc358f60fa0a596b399b82c6a8b4c97de9b1fec127b
7
+ data.tar.gz: 1260fc9024a09442ab7b8712fb8f1da75480714bec45e8718607268a971658f450575b030f5b5b4e395c729616f2ac47717c97b06eeef7aba974a4e309435e17
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_tz (0.2.0)
4
+ google_tz (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/Histroy.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## HEAD
2
2
 
3
+ ## 0.3.0 / 2013-09-02
4
+
5
+ ### Major Enhancements
6
+ * Add a Response object
7
+
3
8
  ## 0.2.1 / 2013-08-30
4
9
 
5
10
  ### Development Fixes
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-08-28'
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
@@ -1,5 +1,8 @@
1
+ require 'google_tz/version'
2
+ require 'google_tz/response'
1
3
  require 'google_tz/query'
2
4
 
5
+
3
6
  class GoogleTZ
4
7
  def self.lookup(lat, lng, opts={})
5
8
  GoogleTZAPI::Query.new(lat, lng, opts).lookup
@@ -14,7 +14,7 @@ module GoogleTZAPI
14
14
 
15
15
  def lookup
16
16
  response = make_request(build_uri)
17
- response.body
17
+ Response.new(response.body)
18
18
  end
19
19
 
20
20
  private
@@ -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
@@ -1,3 +1,3 @@
1
1
  module GoogleTZAPI
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -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
- response = GoogleTZ.lookup(39.7392, -104.9847)
6
+ resp = GoogleTZ.lookup(39.7392, -104.9847)
7
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"
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
- response = GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, sensor: false, language: "de")
17
+ resp = GoogleTZ.lookup(39.7392, -104.9847, timestamp: 1377891332, sensor: false, language: "de")
14
18
 
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"
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.2.1
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-08-28 00:00:00.000000000 Z
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
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'google_tz'
4
- p GoogleTZ.lookup(ARGV[0], ARGV[1], ARGV[2])