google_tz 0.1.0 → 0.2.1

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: bf56a3e132da11005ec5abaebbecf1beefa5248b
4
- data.tar.gz: ba6ad3eecda0e34f48fd8a4740e255c669f04ff3
3
+ metadata.gz: cfb55e775c573bb3937d9a71baf7b24ff6731624
4
+ data.tar.gz: f34371134c4dd9fa189cf64b0b92010cd7d07428
5
5
  SHA512:
6
- metadata.gz: 97c29cdb3c48d1aae6306fc21de9819eac433adfd2f77a4d64b3dd20d9cdd1416126b34f781e36be90fce2928cb498d38a79e35faeb30ca783f1e8636808cd15
7
- data.tar.gz: dde6f5930a1917fa3ef9d6bd6a7c7b4dae08acf46478035d34898d619c2c36e6c2d8ebc99fc97b1c1252f04bd2e0b1cbb990a341dacd3df3f3014f9088f85a72
6
+ metadata.gz: 217e3b871c06610b52a190103acf35cca710aab713ba4eb414a3fcfb7e641e8574b09c740eb9a50243e4e089a5807e43211fb8f5ced552b76ebb30ac1cb5e171
7
+ data.tar.gz: 160e7a0ab217f718a57181f4621591127921939a5f58f800308faf413033804a227170823bddb4d49ccb95ae4ce723f86ad76023fc43a96056cfd558d4c32245
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_tz (0.1.0)
4
+ google_tz (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
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
- 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.
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")
@@ -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 = GoogleTZ::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."
@@ -1,8 +1,7 @@
1
1
  require 'google_tz/query'
2
2
 
3
- module GoogleTZ
4
- def self.lookup(lat, lng, timestamp)
5
- q = Query.new(lat, lng, timestamp)
6
- q.lookup
3
+ class GoogleTZ
4
+ def self.lookup(lat, lng, opts={})
5
+ GoogleTZAPI::Query.new(lat, lng, opts).lookup
7
6
  end
8
7
  end
@@ -2,12 +2,14 @@ require 'net/http'
2
2
  require 'uri'
3
3
  require 'openssl'
4
4
 
5
- module GoogleTZ
5
+ module GoogleTZAPI
6
6
  class Query
7
- def initialize(lat, lng, timestamp)
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: false }
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
@@ -1,3 +1,3 @@
1
- module GoogleTZ
2
- VERSION = '0.1.0'
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.0
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
@@ -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