google_tz 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/Histroy.md +10 -0
- data/LICENSE +21 -0
- data/README.md +4 -0
- data/Rakefile +7 -0
- data/bin/google_tz +4 -0
- data/google_tz.gemspec +22 -0
- data/lib/google_tz.rb +8 -0
- data/lib/google_tz/query.rb +36 -0
- data/lib/google_tz/version.rb +3 -0
- data/spec/google_tz_spec.rb +12 -0
- data/spec/spec_helper.rb +1 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf56a3e132da11005ec5abaebbecf1beefa5248b
|
4
|
+
data.tar.gz: ba6ad3eecda0e34f48fd8a4740e255c669f04ff3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 97c29cdb3c48d1aae6306fc21de9819eac433adfd2f77a4d64b3dd20d9cdd1416126b34f781e36be90fce2928cb498d38a79e35faeb30ca783f1e8636808cd15
|
7
|
+
data.tar.gz: dde6f5930a1917fa3ef9d6bd6a7c7b4dae08acf46478035d34898d619c2c36e6c2d8ebc99fc97b1c1252f04bd2e0b1cbb990a341dacd3df3f3014f9088f85a72
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
google_tz (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.4)
|
10
|
+
rake (10.1.0)
|
11
|
+
rspec (2.14.1)
|
12
|
+
rspec-core (~> 2.14.0)
|
13
|
+
rspec-expectations (~> 2.14.0)
|
14
|
+
rspec-mocks (~> 2.14.0)
|
15
|
+
rspec-core (2.14.5)
|
16
|
+
rspec-expectations (2.14.2)
|
17
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
18
|
+
rspec-mocks (2.14.3)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
google_tz!
|
25
|
+
rake
|
26
|
+
rspec
|
data/Histroy.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Daniel McGraw
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/google_tz
ADDED
data/google_tz.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "google_tz/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'google_tz'
|
6
|
+
s.version = GoogleTZ::VERSION
|
7
|
+
s.date = '2013-08-28'
|
8
|
+
s.summary = "Get timezone information for a latitude, longitude, and optional timestamp."
|
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
|
+
s.authors = ["Daniel McGraw"]
|
11
|
+
s.email = 'dan.j.mcgraw@gmail.com'
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.homepage = 'http://github.com/danielmcgraw/google_tz'
|
16
|
+
s.license = 'MIT'
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
s.add_development_dependency 'rake'
|
20
|
+
s.add_development_dependency 'rspec'
|
21
|
+
|
22
|
+
end
|
data/lib/google_tz.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'openssl'
|
4
|
+
|
5
|
+
module GoogleTZ
|
6
|
+
class Query
|
7
|
+
def initialize(lat, lng, timestamp)
|
8
|
+
@lat=lat
|
9
|
+
@lng=lng
|
10
|
+
@timestamp=timestamp
|
11
|
+
end
|
12
|
+
|
13
|
+
def lookup
|
14
|
+
response = make_request(build_uri)
|
15
|
+
response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def build_uri
|
20
|
+
uri = URI.parse("https://maps.googleapis.com/maps/api/timezone/json")
|
21
|
+
args = { :location => "#{@lat},#{@lng}", timestamp: @timestamp, sensor: false }
|
22
|
+
uri.query = URI.encode_www_form(args)
|
23
|
+
uri
|
24
|
+
end
|
25
|
+
|
26
|
+
def make_request(uri)
|
27
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
28
|
+
http.use_ssl = true
|
29
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
30
|
+
|
31
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
32
|
+
response = http.request(request)
|
33
|
+
response
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'google_tz'
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_tz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel McGraw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Get timezone information for a location from the Google Timezone API
|
42
|
+
(https://developers.google.com/maps/documentation/timezone/) using the locations
|
43
|
+
latitude, longitude, and optionally a timestamp.
|
44
|
+
email: dan.j.mcgraw@gmail.com
|
45
|
+
executables:
|
46
|
+
- google_tz
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- .gitignore
|
51
|
+
- .rspec
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- Histroy.md
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- bin/google_tz
|
59
|
+
- google_tz.gemspec
|
60
|
+
- lib/google_tz.rb
|
61
|
+
- lib/google_tz/query.rb
|
62
|
+
- lib/google_tz/version.rb
|
63
|
+
- spec/google_tz_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: http://github.com/danielmcgraw/google_tz
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.0.6
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Get timezone information for a latitude, longitude, and optional timestamp.
|
89
|
+
test_files:
|
90
|
+
- spec/google_tz_spec.rb
|
91
|
+
- spec/spec_helper.rb
|