forecast 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,71 @@
1
+ require 'yaml'
1
2
  require 'forecast'
3
+
2
4
  describe Forecast do
3
5
 
6
+ location = 'Hamburg'
7
+
8
+ # Load Fixtures
9
+ locations = YAML.load_file(File.expand_path(File.dirname(__FILE__) + "/fixtures/locations.yml"))
10
+
11
+ # Get Location
12
+ coords = locations[location] ? locations[location] : location
13
+ latitude = coords['latitude'].to_f
14
+ longitude = coords['longitude'].to_f
15
+
16
+ # Configure Forecast
17
+ Forecast.configure do |config|
18
+ config.scale = :celsius
19
+ config.provider = :open_weather_map
20
+ end
21
+
4
22
  def dump_forecast(forecast)
5
23
  if forecast != nil
6
- puts forecast.date.strftime("%F %T") + " | " + forecast.temp.to_s + " | " + forecast.condition + " | " + forecast.icon
24
+ puts forecast.time.strftime("%F %T") + " | " + forecast.temperature.to_s + " | " + forecast.condition.to_s + " | " + forecast.text.to_s + " | " + forecast.icon.to_s
7
25
  else
8
26
  puts 'nil'
9
27
  end
10
28
  end
11
29
 
12
- # it "current" do
13
- # puts "*** CURRENT ***"
14
- # forecast = Forecast.current(54.9999, 9.534)
15
- # dump_forecast(forecast)
16
- # expect(forecast).not_to be_nil
17
- # end
18
- # it "hourly" do
19
- # puts "*** HOURLY FORECASTS ***"
20
- # forecasts = Forecast.hourly(54.9999, 9.534)
21
- # forecasts.each do |forecast|
22
- # dump_forecast(forecast)
23
- # end
24
- # expect(forecasts.size).to be >= 1
25
- # end
26
- # it "daily" do
27
- # puts "*** DAILY FORECASTS ***"
28
- # forecasts = Forecast.daily(54.9999, 9.534)
29
- # forecasts.each do |forecast|
30
- # #puts forecast.date.strftime("%F %T") + " | " + forecast.temp_min.to_s + " | " + forecast.temp_max.to_s + " | " + forecast.condition + " | " + forecast.icon
31
- # dump_forecast(forecast)
32
- # end
33
- # expect(forecasts.size).to be >= 1
34
- # end
35
- it "select_date" do
36
- puts "*** SELECT FORECAST ***"
37
- forecast = Forecast.daily(54.9999, 9.534).select_date(Time.now + (24*60*60) * 2)
30
+ it "current" do
31
+ puts "\n\n"
32
+ puts "> #{location.to_s} current (" + Forecast.config.provider.to_s + ")"
33
+ puts "*************************************************************"
34
+ forecast = Forecast.current(latitude, longitude)
35
+ dump_forecast(forecast)
36
+ expect(forecast).not_to be_nil
37
+ end
38
+
39
+
40
+
41
+ it "hourly" do
42
+ puts "\n\n"
43
+ puts "> #{location.to_s} hourly (" + Forecast.config.provider.to_s + ")"
44
+ puts "*************************************************************"
45
+ forecasts = Forecast.hourly(latitude, longitude)
46
+ forecasts.each do |forecast|
47
+ dump_forecast(forecast)
48
+ end
49
+ expect(forecasts.size).to be >= 1
50
+ end
51
+
52
+ it "daily" do
53
+ puts "\n\n"
54
+ puts "> #{location.to_s} daily (" + Forecast.config.provider.to_s + ")"
55
+ puts "*************************************************************"
56
+ forecasts = Forecast.daily(latitude, longitude)
57
+ forecasts.each do |forecast|
58
+ dump_forecast(forecast)
59
+ end
60
+ expect(forecasts.size).to be >= 1
61
+ end
62
+
63
+ it "select_time" do
64
+ time = Time.now + (24 * 60 * 60) * 1
65
+ puts "\n\n"
66
+ puts "> #{location.to_s} at tomorrow, #{time.strftime("%T")} (" + Forecast.config.provider.to_s + ")"
67
+ puts "*************************************************************"
68
+ forecast = Forecast.daily(latitude, longitude).select_time(time)
38
69
  dump_forecast(forecast)
39
70
  expect(forecast).not_to be_nil
40
71
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ RSpec.configure do |config|
3
+
4
+ config.global_fixtures = :all
5
+ config.fixture_path = "fixtures"
6
+
7
+ config.before(:suite) do
8
+ puts 'before suite'
9
+ end
10
+
11
+ # after each spec with js, turn transactional fixtures back on
12
+ # rebuild fixtures
13
+ config.after(:each, js: true) do
14
+ puts 'after'
15
+ end
16
+ end
metadata CHANGED
@@ -1,103 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Nowrotek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-09 00:00:00.000000000 Z
11
+ date: 2015-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
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
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.5'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '2.6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.6'
69
- description: A Forecast-Multi-API-Wrapper with a unified model and integrated caching
69
+ description: Forecast Multi-API-Wrapper with unified model and integrated caching
70
70
  email:
71
71
  - mail@benignware.com
72
- executables: []
72
+ executables:
73
+ - forecast
73
74
  extensions: []
74
75
  extra_rdoc_files: []
75
76
  files:
76
- - .README.md.html
77
- - .gitignore
78
- - .project
77
+ - ".gitignore"
78
+ - ".project"
79
+ - CHANGELOG.md
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
82
83
  - Rakefile
84
+ - bin/forecast
83
85
  - dump.rdb
84
86
  - forecast.gemspec
85
87
  - lib/forecast.rb
86
88
  - lib/forecast/adapter.rb
89
+ - lib/forecast/adapters/forecast_io_adapter.rb
87
90
  - lib/forecast/adapters/open_weather_map_adapter.rb
88
- - lib/forecast/adapters/open_weather_map_adapter.yml
89
91
  - lib/forecast/adapters/wunderground_adapter.rb
90
92
  - lib/forecast/adapters/yahoo_adapter.rb
91
- - lib/forecast/cache.rb
92
93
  - lib/forecast/collection.rb
93
94
  - lib/forecast/conditions.yml
94
95
  - lib/forecast/config.rb
95
96
  - lib/forecast/config.yml
96
- - lib/forecast/model.rb
97
+ - lib/forecast/http.rb
98
+ - lib/forecast/synonyms.yml
97
99
  - lib/forecast/themes/weather_icons.yml
98
100
  - lib/forecast/utils.rb
99
101
  - lib/forecast/version.rb
102
+ - spec/fixtures/locations.yml
100
103
  - spec/forecast_spec.rb
104
+ - spec/spec_helper.rb
101
105
  homepage: ''
102
106
  licenses:
103
107
  - MIT
@@ -108,19 +112,21 @@ require_paths:
108
112
  - lib
109
113
  required_ruby_version: !ruby/object:Gem::Requirement
110
114
  requirements:
111
- - - ! '>='
115
+ - - ">="
112
116
  - !ruby/object:Gem::Version
113
117
  version: '0'
114
118
  required_rubygems_version: !ruby/object:Gem::Requirement
115
119
  requirements:
116
- - - ! '>='
120
+ - - ">="
117
121
  - !ruby/object:Gem::Version
118
122
  version: '0'
119
123
  requirements: []
120
124
  rubyforge_project:
121
- rubygems_version: 2.1.11
125
+ rubygems_version: 2.2.2
122
126
  signing_key:
123
127
  specification_version: 4
124
- summary: A Forecast-Multi-API-Wrapper with a unified model and integrated caching
128
+ summary: Forecast Multi-API-Wrapper with unified model and integrated caching
125
129
  test_files:
130
+ - spec/fixtures/locations.yml
126
131
  - spec/forecast_spec.rb
132
+ - spec/spec_helper.rb