forecast_io-cache 0.0.1 → 0.0.2
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +13 -1
- data/lib/forecast_io/cache/forecast_data.rb +2 -2
- data/lib/forecast_io/cache/generate.rb +1 -1
- data/lib/forecast_io/cache/version.rb +1 -1
- data/spec/forecast_io/cache/forecast_data_spec.rb +2 -1
- data/spec/forecast_io/cache/generate_spec.rb +8 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 897ea0cd9885c02e90c353e5c2f58453f7dd57ae
|
4
|
+
data.tar.gz: b1110de708c9841c124676c2bbc15e272d48dc63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac561e43227203f3f338811b88f289d17b84c9fdf79d0f59d275e92aaa1756213d89b94988f26c1aa62407d2327c975050dd8e009664da12302ea0480b410223
|
7
|
+
data.tar.gz: db53f45306c1ae9307e8527b25c8e95b2523db079f08c9e8e85d727a9b41b41ada35838bb000f5acc20916739483748c2111c3ad1ed3f9d35ae5d12359b1e9bb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Forecast::IO::Cache
|
2
2
|
|
3
|
-
A local caching setup for [Forecast.IO](https://developer.forecast.io)
|
3
|
+
A local caching setup for [Forecast.IO](https://developer.forecast.io).
|
4
|
+
|
5
|
+
The cache is distance and timeframe sensitive, allowing cached forecasts to
|
6
|
+
be returned within `radius` of the location requested and `timeframe` of
|
7
|
+
cached forecast.
|
8
|
+
|
9
|
+
Thus you can make repeated calls to locations in a similar area (within
|
10
|
+
radius) and get a cached forecast. Same with timeframes. This reduces
|
11
|
+
the calls to the [Forecast.IO](https://developer.forecast.io) API for
|
12
|
+
app's that are attempting to map weather to other geo data.
|
13
|
+
|
14
|
+
When the api is called, additionally all hourly forecasts are sliced up
|
15
|
+
into the cache individually to help pad the `timeframe` cache.
|
4
16
|
|
5
17
|
## Installation
|
6
18
|
|
@@ -4,10 +4,10 @@ module Forecast
|
|
4
4
|
class ForecastData < Struct.new(:position, :time, :wind_speed, :wind_bearing,
|
5
5
|
:humidity, :pressure, :visibility, :temperature)
|
6
6
|
|
7
|
-
def self.generate lat, lon,
|
7
|
+
def self.generate lat, lon, forecast
|
8
8
|
new.tap do |data|
|
9
|
-
data.time = time
|
10
9
|
data.position = [lon,lat].map(&:to_f)
|
10
|
+
data.time = forecast['time']
|
11
11
|
data.wind_speed = forecast['windSpeed']
|
12
12
|
data.wind_bearing = forecast['windBearing']
|
13
13
|
data.humidity = forecast['humidity']
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'forecast_io/cache/forecast_data'
|
2
2
|
|
3
3
|
describe 'representing data from the api' do
|
4
|
-
subject { Forecast::IO::Cache::ForecastData.generate "1.1", "-1.2",
|
4
|
+
subject { Forecast::IO::Cache::ForecastData.generate "1.1", "-1.2", data }
|
5
5
|
|
6
6
|
let(:data) do
|
7
7
|
{
|
8
|
+
'time' => time,
|
8
9
|
'windSpeed' => wind_speed,
|
9
10
|
'windBearing' => wind_bearing,
|
10
11
|
'humidity' => humidity,
|
@@ -11,7 +11,7 @@ describe 'generating new cached results' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
14
|
-
Forecast::IO::Cache::ForecastData.stub(:generate) { |lat,lon,
|
14
|
+
Forecast::IO::Cache::ForecastData.stub(:generate) { |lat,lon,data| send data }
|
15
15
|
cache.stub(:store) { |data| data }
|
16
16
|
end
|
17
17
|
|
@@ -20,6 +20,13 @@ describe 'generating new cached results' do
|
|
20
20
|
generate.forecasts
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'generate forecase data objects' do
|
24
|
+
Forecast::IO::Cache::ForecastData.should_receive(:generate).with(lat,lon,"data_1")
|
25
|
+
Forecast::IO::Cache::ForecastData.should_receive(:generate).with(lat,lon,"data_2")
|
26
|
+
Forecast::IO::Cache::ForecastData.should_receive(:generate).with(lat,lon,"data_3")
|
27
|
+
generate.forecasts
|
28
|
+
end
|
29
|
+
|
23
30
|
it 'stores the current forecast and all the hourlies' do
|
24
31
|
cache.should_receive(:store).with(data_1)
|
25
32
|
cache.should_receive(:store).with(data_2)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forecast_io-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Rowe
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
|
30
30
|
/NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-05-
|
32
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: forecast_io
|
metadata.gz.sig
CHANGED
Binary file
|