which_time 1.0.3 → 1.0.4
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/README.md +20 -11
- data/lib/which_time.rb +7 -6
- data/lib/which_time/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acf0e565c1b527437bebc010b4c1d2e0c0461c13
|
4
|
+
data.tar.gz: 7f4661596a9db9bc05ddeafacf4907a366ec85af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caeee68ccd54fb3345d8c15ec6f9d200814f960f62f391e3b590f6fe9c3952c5993ad42139d940a9958c580dcbc129cdd854b5b383ccb694e3df124807ee8234
|
7
|
+
data.tar.gz: a0773b349d111305e89edc7e63c423eb6c55b11c73d99809c63a122325e1fe655c9cb00da1c8a435709e9b504bec925595341559507f475d58d08a5dd7cca44d
|
data/README.md
CHANGED
@@ -25,46 +25,55 @@ Manually:
|
|
25
25
|
|
26
26
|
### 1. Get local time of some address
|
27
27
|
```
|
28
|
-
WhichTime.in
|
28
|
+
WhichTime.in somewhere, api_key: google_api_key
|
29
29
|
```
|
30
|
-
|
30
|
+
or
|
31
|
+
```
|
32
|
+
WhichTime.in somewhere, api_key: google_api_key, time: your_time
|
33
|
+
```
|
34
|
+
or
|
35
|
+
```
|
36
|
+
WhichTime.in somewhere, api_key: google_api_key, time: your_time, http_proxy: proxy_url
|
37
|
+
```
|
38
|
+
- "somewhere" - may be an address or some place ("Lviv city, Naykova str." or "'Naturlih' pub, Kyiv" e.g.)
|
31
39
|
- "google_api_key" - API_KEY of Google application with an access to TimeZone and Geocoding API
|
32
|
-
- "your_time"
|
40
|
+
- "your_time" - is not mandatory (Time.now is default)
|
41
|
+
- "proxy_url" - proxy host with port ( is not mandatory, 'https://fooproxy.com:8080' etc.)
|
33
42
|
|
34
43
|
examples:
|
35
44
|
```
|
36
|
-
WhichTime.in
|
45
|
+
WhichTime.in "Kyiv, pub 'Naturlih'", api_key: "AIzaSyCqfXRRJ1d8mCS_I0Kcs4XnaZ9KYRUrJVE"
|
37
46
|
# => 2015-07-06 03:53:10 +0300
|
38
|
-
WhichTime.in
|
47
|
+
WhichTime.in "Kyiv", api_key: "AIzaSyCqfXRRJ1d8mCS_I0Kcs4XnaZ9KYRUrJVE", time: 2.days.ago
|
39
48
|
# => 2015-07-04 03:53:10 +0300
|
40
49
|
```
|
41
50
|
|
42
51
|
### 2. Get local time of some address (variant 2)
|
43
52
|
```
|
44
|
-
WhichTime.new( somewhere, google_api_key, your_time ).time
|
53
|
+
WhichTime.new( somewhere, api_key: google_api_key, time: your_time ).time
|
45
54
|
# => 2015-07-06 03:53:10 +0300
|
46
55
|
```
|
47
56
|
|
48
57
|
### 3. Get timezone of some place/address/city/country
|
49
58
|
```
|
50
|
-
WhichTime.new( somewhere, google_api_key ).timezone
|
59
|
+
WhichTime.new( somewhere, api_key: google_api_key ).timezone
|
51
60
|
```
|
52
61
|
examples:
|
53
62
|
```
|
54
|
-
WhichTime.new("Kyiv, pub 'Naturlih'", "AIzaSyCqfXRRJ1d8mCS_I0Kcs4XnaZ9KYRUrJVE").timezone
|
55
|
-
WhichTime.in("Kyiv", "AIzaSyCqfXRRJ1d8mCS_I0Kcs4XnaZ9KYRUrJVE").timezone
|
63
|
+
WhichTime.new("Kyiv, pub 'Naturlih'", api_key: "AIzaSyCqfXRRJ1d8mCS_I0Kcs4XnaZ9KYRUrJVE").timezone
|
64
|
+
WhichTime.in("Kyiv", api_key: "AIzaSyCqfXRRJ1d8mCS_I0Kcs4XnaZ9KYRUrJVE").timezone
|
56
65
|
# => "Europe/Kiev"
|
57
66
|
```
|
58
67
|
|
59
68
|
### 4. Get coordinates of some place/address/location
|
60
69
|
```
|
61
|
-
WhichTime.new( somewhere, google_api_key ).location
|
70
|
+
WhichTime.new( somewhere, api_key: google_api_key ).location
|
62
71
|
# => {"lat"=>50.4501, "lng"=>30.5234}
|
63
72
|
```
|
64
73
|
|
65
74
|
### 5. Get coordinates of some place/address/location (variant 2)
|
66
75
|
```
|
67
|
-
WhichTime.new( somewhere, google_api_key ).coordinates
|
76
|
+
WhichTime.new( somewhere, api_key: google_api_key ).coordinates
|
68
77
|
# => "50.4501,30.5234"
|
69
78
|
```
|
70
79
|
|
data/lib/which_time.rb
CHANGED
@@ -40,14 +40,11 @@ class WhichTime
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def with_proxy uri_path
|
43
|
-
|
44
|
-
http.use_ssl = true
|
45
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
46
|
-
http.get( uri_path.request_uri ).body
|
43
|
+
Net::HTTP.new('maps.googleapis.com', 443, proxy_host, proxy_port)
|
47
44
|
end
|
48
45
|
|
49
46
|
def without_proxy uri_path
|
50
|
-
Net::HTTP.
|
47
|
+
Net::HTTP.new(uri_path.host, uri_path.port)
|
51
48
|
end
|
52
49
|
|
53
50
|
def request_uri type, params
|
@@ -55,7 +52,11 @@ class WhichTime
|
|
55
52
|
end
|
56
53
|
|
57
54
|
def request type, params
|
58
|
-
|
55
|
+
path = request_uri(type, params)
|
56
|
+
http = @proxy ? with_proxy(path) : without_proxy(path)
|
57
|
+
http.use_ssl = true
|
58
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
59
|
+
http.get( path.request_uri ).body
|
59
60
|
end
|
60
61
|
|
61
62
|
def response type, params
|
data/lib/which_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: which_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bmalets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -119,10 +119,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.2.2
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: search local time by your location
|
126
126
|
test_files:
|
127
127
|
- spec/spec_helper.rb
|
128
128
|
- spec/which_time_spec.rb
|
129
|
+
has_rdoc:
|