forecast_io-cache 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/forecast_io-cache.gemspec +1 -1
- data/lib/forecast_io/cache/version.rb +1 -1
- data/spec/forecast_io/cache/configuration_spec.rb +1 -1
- data/spec/forecast_io/cache/forecast_data_spec.rb +27 -13
- data/spec/forecast_io/cache/forecast_spec.rb +6 -6
- data/spec/forecast_io/cache/generate_spec.rb +9 -9
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a3a830da7beaf6331d52777a3f4063cee109e2a
|
4
|
+
data.tar.gz: 6520296466e74b33bc0bb9376cd13cdfd6402bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb851a96237711c48c802ad39ce747453c3e2604a1c12ec07f55403477ade4d640e630911f38de3553c8b5449c23b1a9f731d4685e40482b89aba52be7bf5725
|
7
|
+
data.tar.gz: c15589b920e5b570c6021b648fcc38f2add074dfa32d74c88f3b8bc95007b3b89444852c021fe1349e70d5f2c5975624daaa36790ffbc462aea5faeaf3b443be
|
data/forecast_io-cache.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "forecast_io"
|
21
|
+
spec.add_runtime_dependency "forecast_io", '~> 2.0.1'
|
22
22
|
spec.add_runtime_dependency "sinatra"
|
23
23
|
spec.add_runtime_dependency "mongo_adaptor"
|
24
24
|
|
@@ -23,7 +23,7 @@ describe 'service configuration' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'loads mongo config urls' do
|
26
|
-
Mongo::Configure.
|
26
|
+
expect(Mongo::Configure).to receive(:from_uri).with 'mongodb://example.com'
|
27
27
|
config.mongo_uri 'mongodb://example.com'
|
28
28
|
end
|
29
29
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'forecast_io/cache/forecast_data'
|
2
2
|
|
3
3
|
describe 'representing data from the api' do
|
4
|
-
|
4
|
+
let(:forecast) { Forecast::IO::Cache::ForecastData.generate "1.1", "-1.2", data }
|
5
5
|
|
6
6
|
let(:data) do
|
7
7
|
{
|
@@ -12,22 +12,36 @@ describe 'representing data from the api' do
|
|
12
12
|
'temperature' => temperature,
|
13
13
|
'pressure' => pressure,
|
14
14
|
'visibility' => visibility,
|
15
|
-
'percipIntensity' =>
|
15
|
+
'percipIntensity' => precip_intensity
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
%W[time wind_speed wind_bearing humidity temperature pressure visibility
|
19
|
+
%W[time wind_speed wind_bearing humidity temperature pressure visibility precip_intensity].each do |name|
|
20
20
|
let(name) { double name }
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
it "exposes time" do
|
24
|
+
expect(forecast.time).to eq time
|
25
|
+
end
|
26
|
+
it "exposes position" do
|
27
|
+
expect(forecast.position).to eq [-1.2, 1.1]
|
28
|
+
end
|
29
|
+
it "exposes wind_speed" do
|
30
|
+
expect(forecast.wind_speed).to eq wind_speed
|
31
|
+
end
|
32
|
+
it "exposes wind_bearing" do
|
33
|
+
expect(forecast.wind_bearing).to eq wind_bearing
|
34
|
+
end
|
35
|
+
it "exposes humidity" do
|
36
|
+
expect(forecast.humidity).to eq humidity
|
37
|
+
end
|
38
|
+
it "exposes temperature" do
|
39
|
+
expect(forecast.temperature).to eq temperature
|
40
|
+
end
|
41
|
+
it "exposes pressure" do
|
42
|
+
expect(forecast.pressure).to eq pressure
|
43
|
+
end
|
44
|
+
it "exposes visibility" do
|
45
|
+
expect(forecast.visibility).to eq visibility
|
46
|
+
end
|
33
47
|
end
|
@@ -9,10 +9,10 @@ describe 'producing a forecast' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'when cached data exists' do
|
12
|
-
before { store.
|
12
|
+
before { allow(store).to receive(:fetch).and_return data }
|
13
13
|
|
14
14
|
it 'checks the store for a previous cached result' do
|
15
|
-
store.
|
15
|
+
expect(store).to receive(:fetch).with(lat, lon, time)
|
16
16
|
forecast.for lat, lon, time
|
17
17
|
end
|
18
18
|
|
@@ -23,13 +23,13 @@ describe 'producing a forecast' do
|
|
23
23
|
|
24
24
|
context 'when cached data doesnt exist' do
|
25
25
|
before do
|
26
|
-
generate.
|
27
|
-
store.
|
26
|
+
allow(generate).to receive(:for).and_return data
|
27
|
+
allow(store).to receive(:fetch)
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'checks the store for a previous cached result but then calls the generate' do
|
31
|
-
store.
|
32
|
-
generate.
|
31
|
+
expect(store).to receive(:fetch).with(lat, lon, time)
|
32
|
+
expect(generate).to receive(:for).with(lat, lon, time, store)
|
33
33
|
forecast.for lat, lon, time
|
34
34
|
end
|
35
35
|
|
@@ -11,26 +11,26 @@ describe 'generating new cached results' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
14
|
-
Forecast::IO::Cache::ForecastData.
|
15
|
-
cache.
|
14
|
+
allow(Forecast::IO::Cache::ForecastData).to receive(:generate) { |lat,lon,data| send data }
|
15
|
+
allow(cache).to receive(:store) { |data| data }
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'gets the forecast from the api' do
|
19
|
-
api.
|
19
|
+
expect(api).to receive(:forecast).with(lat,lon,time: time)
|
20
20
|
generate.forecasts
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'generate forecase data objects' do
|
24
|
-
Forecast::IO::Cache::ForecastData.
|
25
|
-
Forecast::IO::Cache::ForecastData.
|
26
|
-
Forecast::IO::Cache::ForecastData.
|
24
|
+
expect(Forecast::IO::Cache::ForecastData).to receive(:generate).with(lat,lon,"data_1")
|
25
|
+
expect(Forecast::IO::Cache::ForecastData).to receive(:generate).with(lat,lon,"data_2")
|
26
|
+
expect(Forecast::IO::Cache::ForecastData).to receive(:generate).with(lat,lon,"data_3")
|
27
27
|
generate.forecasts
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'stores the current forecast and all the hourlies' do
|
31
|
-
cache.
|
32
|
-
cache.
|
33
|
-
cache.
|
31
|
+
expect(cache).to receive(:store).with(data_1)
|
32
|
+
expect(cache).to receive(:store).with(data_2)
|
33
|
+
expect(cache).to receive(:store).with(data_3)
|
34
34
|
generate.forecasts
|
35
35
|
end
|
36
36
|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
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: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Rowe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forecast_io
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sinatra
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
240
|
version: '0'
|
241
241
|
requirements: []
|
242
242
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.
|
243
|
+
rubygems_version: 2.5.1
|
244
244
|
signing_key:
|
245
245
|
specification_version: 4
|
246
246
|
summary: Caching layer for forecast_io
|