darksky 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +4 -0
- data/README.markdown +4 -1
- data/lib/darksky/api.rb +10 -0
- data/lib/darksky/version.rb +1 -1
- data/spec/cassettes/brief_forecast.yml +28 -0
- data/spec/darksky/api_spec.rb +10 -0
- data/spec/darksky/version_spec.rb +1 -1
- metadata +14 -12
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -16,11 +16,14 @@ gem 'darksky'
|
|
16
16
|
## Usage
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
darksky = Darksky::API.new('
|
19
|
+
darksky = Darksky::API.new('this-is-your-dark-sky-api-key')
|
20
20
|
|
21
21
|
# Returns a forecast for the next hour at a given location.
|
22
22
|
forecast = darksky.forecast('42.7243','-73.6927')
|
23
23
|
|
24
|
+
# Returns a brief forecast for the next hour at a given location.
|
25
|
+
brief_forecast = darksky.brief_forecast('42.7243','-73.6927')
|
26
|
+
|
24
27
|
# Returns forecasts for a collection of arbitrary points.
|
25
28
|
precipitation = darksky.precipitation(['42.7','-73.6',1325607100,'42.0','-73.0',1325607791])
|
26
29
|
|
data/lib/darksky/api.rb
CHANGED
@@ -24,6 +24,16 @@ module Darksky
|
|
24
24
|
JSON.parse(response.body) if response.code == 200
|
25
25
|
end
|
26
26
|
|
27
|
+
# Returns a brief forecast for the next hour at a given location.
|
28
|
+
#
|
29
|
+
# @param latitude [String] Latitude in decimal degrees.
|
30
|
+
# @param longitude [String] Longitude in decimal degrees.
|
31
|
+
# @param option [Hash] (Optional) Options to be passed to the Typhoeus::Request
|
32
|
+
def brief_forecast(latitude, longitude, options = {})
|
33
|
+
response = Typhoeus::Request.get("#{DARKSKY_API_URL}/brief_forecast/#{@api_key}/#{latitude},#{longitude}", DEFAULT_OPTIONS.dup.merge(options))
|
34
|
+
JSON.parse(response.body) if response.code == 200
|
35
|
+
end
|
36
|
+
|
27
37
|
# Returns forecasts for a collection of arbitrary points.
|
28
38
|
#
|
29
39
|
# @param latitudes_longitudes_times [Array] Triplets of latitude, longitude and time. Example: ['42.7','-73.6',1325607100,'42.0','-73.0',1325607791]
|
data/lib/darksky/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.darkskyapp.com/v1/brief_forecast/this-is-your-dark-sky-api-key/42.7243,-73.6927
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
X-Powered-By:
|
16
|
+
- Express
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Content-Length:
|
20
|
+
- '95'
|
21
|
+
Connection:
|
22
|
+
- keep-alive
|
23
|
+
body:
|
24
|
+
encoding: ASCII-8BIT
|
25
|
+
string: ! '{"isPrecipitating":false,"minutesUntilChange":0,"currentSummary":"clear","hourSummary":"clear"}'
|
26
|
+
http_version: '1.1'
|
27
|
+
recorded_at: Fri, 16 Mar 2012 20:19:37 GMT
|
28
|
+
recorded_with: VCR 2.0.0
|
data/spec/darksky/api_spec.rb
CHANGED
@@ -13,6 +13,16 @@ describe Darksky::API do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe '#brief_forecast' do
|
17
|
+
it 'should return a valid brief forecast for a latitude and longitude' do
|
18
|
+
VCR.use_cassette('brief_forecast', :record => :once) do
|
19
|
+
forecast = darksky_api.brief_forecast('42.7243','-73.6927')
|
20
|
+
forecast['currentSummary'].should == 'clear'
|
21
|
+
forecast['hourSummary'].should == 'clear'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
16
26
|
describe '#precipitation' do
|
17
27
|
it 'should return forecasts for a collection of arbitrary points' do
|
18
28
|
VCR.use_cassette('precipitation', :record => :once) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darksky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153405100 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153405100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153404240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153404240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153403480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153403480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: vcr
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153402800 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153402800
|
58
58
|
description: Ruby gem for retrieving data from the Dark Sky API
|
59
59
|
email:
|
60
60
|
- me@davidczarnecki.com
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/darksky.rb
|
74
74
|
- lib/darksky/api.rb
|
75
75
|
- lib/darksky/version.rb
|
76
|
+
- spec/cassettes/brief_forecast.yml
|
76
77
|
- spec/cassettes/forecast.yml
|
77
78
|
- spec/cassettes/interesting.yml
|
78
79
|
- spec/cassettes/precipitation.yml
|
@@ -93,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
94
|
version: '0'
|
94
95
|
segments:
|
95
96
|
- 0
|
96
|
-
hash: -
|
97
|
+
hash: -2762731968026929372
|
97
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
99
|
none: false
|
99
100
|
requirements:
|
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
103
|
version: '0'
|
103
104
|
segments:
|
104
105
|
- 0
|
105
|
-
hash: -
|
106
|
+
hash: -2762731968026929372
|
106
107
|
requirements: []
|
107
108
|
rubyforge_project: darksky
|
108
109
|
rubygems_version: 1.8.10
|
@@ -110,6 +111,7 @@ signing_key:
|
|
110
111
|
specification_version: 3
|
111
112
|
summary: Ruby gem for retrieving data from the Dark Sky API
|
112
113
|
test_files:
|
114
|
+
- spec/cassettes/brief_forecast.yml
|
113
115
|
- spec/cassettes/forecast.yml
|
114
116
|
- spec/cassettes/interesting.yml
|
115
117
|
- spec/cassettes/precipitation.yml
|