forecast_io-cache 0.0.1 → 0.0.2

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: ef116f597c9ede4482828322869a00aa395b6393
4
- data.tar.gz: ad798a1fe9c3277bbba85b9d5491bacf9dae46c3
3
+ metadata.gz: 897ea0cd9885c02e90c353e5c2f58453f7dd57ae
4
+ data.tar.gz: b1110de708c9841c124676c2bbc15e272d48dc63
5
5
  SHA512:
6
- metadata.gz: c7cc51e0c2d98fae59f8b8b93d15272ae44e1c9c57c9ba5904043a248dacc007c20a058b2f81c010f36364693a50846aea47d39c36c258bd60aec8cf586319f8
7
- data.tar.gz: 3d22fc5b23f791948db6277bcadd6ac6a7b085feef49ea093680a27df3bb327806966c721ca9c7c6294bd5c279266ef04d0fdd8b0c51cbae60f6450c1e7d8ca5
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, time, forecast
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']
@@ -33,7 +33,7 @@ module Forecast
33
33
  end
34
34
 
35
35
  def generate data
36
- ForecastData.generate @lat, @lon, @time, data
36
+ ForecastData.generate @lat, @lon, data
37
37
  end
38
38
 
39
39
  end
@@ -1,7 +1,7 @@
1
1
  module Forecast
2
2
  module IO
3
3
  module Cache
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -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", time, data }
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,time,data| send data }
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.1
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-02 00:00:00.000000000 Z
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