open-weather-api 0.0.6 → 0.0.7
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
- data/.rspec +1 -1
- data/CONTRIBUTING.md +9 -9
- data/Gemfile +2 -2
- data/lib/open-weather-api/api.rb +56 -56
- data/lib/open-weather-api/config.rb +8 -8
- data/lib/open-weather-api/resources/base.rb +66 -66
- data/lib/open-weather-api/resources/current.rb +44 -44
- data/lib/open-weather-api/resources/forecast_daily.rb +18 -18
- data/lib/open-weather-api/resources/forecast_hourly.rb +27 -27
- data/lib/open-weather-api/resources/handlers/base.rb +98 -98
- data/lib/open-weather-api/resources/handlers/current.rb +54 -54
- data/lib/open-weather-api/resources/raw.rb +14 -14
- data/lib/open-weather-api/version.rb +1 -1
- data/open-weather-api.gemspec +1 -1
- data/rakefile +29 -28
- data/spec/current_weather_spec.rb +50 -50
- data/spec/forecast_daily_spec.rb +33 -33
- data/spec/forecast_hourly_spec.rb +33 -33
- data/spec/raw_spec.rb +16 -16
- data/spec/spec_helper.rb +11 -11
- metadata +15 -16
data/spec/forecast_daily_spec.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenWeatherAPI::API do
|
4
|
-
let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) }
|
5
|
-
|
6
|
-
describe 'When fetching daily forecast weather' do
|
7
|
-
it 'should retrieve data by city name' do
|
8
|
-
expect(api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3)[:cod].to_i).to eq(200)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should retrieve data by city id' do
|
12
|
-
expect(api.forecast(:daily, id: 6360638, days: 3)[:cod].to_i).to eq(200)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should retrieve data by geolocation' do
|
16
|
-
expect(api.forecast(:daily, lon: -16.20302, lat: 28.53924, days: 3)[:cod].to_i).to eq(200)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'works with a given block' do
|
20
|
-
json1, json2 = nil
|
21
|
-
json1 = api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3) { |json| json2 = json }
|
22
|
-
|
23
|
-
expect(json1).to eq(json2)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'works with xml format' do
|
27
|
-
expect(api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3, mode: :xml)).not_to be_nil
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'works with html format' do
|
31
|
-
expect(api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3, mode: :html)).not_to be_nil
|
32
|
-
end
|
33
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OpenWeatherAPI::API do
|
4
|
+
let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) }
|
5
|
+
|
6
|
+
describe 'When fetching daily forecast weather' do
|
7
|
+
it 'should retrieve data by city name' do
|
8
|
+
expect(api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3)[:cod].to_i).to eq(200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should retrieve data by city id' do
|
12
|
+
expect(api.forecast(:daily, id: 6360638, days: 3)[:cod].to_i).to eq(200)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should retrieve data by geolocation' do
|
16
|
+
expect(api.forecast(:daily, lon: -16.20302, lat: 28.53924, days: 3)[:cod].to_i).to eq(200)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'works with a given block' do
|
20
|
+
json1, json2 = nil
|
21
|
+
json1 = api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3) { |json| json2 = json }
|
22
|
+
|
23
|
+
expect(json1).to eq(json2)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works with xml format' do
|
27
|
+
expect(api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3, mode: :xml)).not_to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'works with html format' do
|
31
|
+
expect(api.forecast(:daily, city: 'Santa Cruz de Tenerife', days: 3, mode: :html)).not_to be_nil
|
32
|
+
end
|
33
|
+
end
|
34
34
|
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenWeatherAPI::API do
|
4
|
-
describe 'When fetching hourly forecast weather' do
|
5
|
-
let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) }
|
6
|
-
|
7
|
-
it 'should retrieve data by city name' do
|
8
|
-
expect(api.forecast(:hourly, city: 'Santa Cruz de Tenerife')[:cod].to_i).to eq(200)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should retrieve data by city id' do
|
12
|
-
expect(api.forecast(:hourly, id: 6360638)[:cod].to_i).to eq(200)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should retrieve data by geolocation' do
|
16
|
-
expect(api.forecast(:hourly, lon: -16.20302, lat: 28.53924)[:cod].to_i).to eq(200)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'works with a given block' do
|
20
|
-
json1, json2 = nil
|
21
|
-
json1 = api.forecast(:hourly, city: 'Santa Cruz de Tenerife') { |json| json2 = json }
|
22
|
-
|
23
|
-
expect(json1).to eq(json2)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'works with xml format' do
|
27
|
-
expect(api.forecast(:hourly, city: 'Santa Cruz de Tenerife', mode: :xml)).not_to be_nil
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'works with html format' do
|
31
|
-
expect(api.forecast(:hourly, city: 'Santa Cruz de Tenerife', mode: :html)).not_to be_nil
|
32
|
-
end
|
33
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OpenWeatherAPI::API do
|
4
|
+
describe 'When fetching hourly forecast weather' do
|
5
|
+
let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) }
|
6
|
+
|
7
|
+
it 'should retrieve data by city name' do
|
8
|
+
expect(api.forecast(:hourly, city: 'Santa Cruz de Tenerife')[:cod].to_i).to eq(200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should retrieve data by city id' do
|
12
|
+
expect(api.forecast(:hourly, id: 6360638)[:cod].to_i).to eq(200)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should retrieve data by geolocation' do
|
16
|
+
expect(api.forecast(:hourly, lon: -16.20302, lat: 28.53924)[:cod].to_i).to eq(200)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'works with a given block' do
|
20
|
+
json1, json2 = nil
|
21
|
+
json1 = api.forecast(:hourly, city: 'Santa Cruz de Tenerife') { |json| json2 = json }
|
22
|
+
|
23
|
+
expect(json1).to eq(json2)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'works with xml format' do
|
27
|
+
expect(api.forecast(:hourly, city: 'Santa Cruz de Tenerife', mode: :xml)).not_to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'works with html format' do
|
31
|
+
expect(api.forecast(:hourly, city: 'Santa Cruz de Tenerife', mode: :html)).not_to be_nil
|
32
|
+
end
|
33
|
+
end
|
34
34
|
end
|
data/spec/raw_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe OpenWeatherAPI::API do
|
4
|
-
let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) }
|
5
|
-
|
6
|
-
describe 'When fetching raw rest requests with valid data' do
|
7
|
-
it 'should work' do
|
8
|
-
expect(api.raw("weather", q: 'Santa Cruz de Tenerife,ES')[:cod].to_i).to eq(200)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'When fetching raw rest requests with invalid data' do
|
13
|
-
it 'should fail' do
|
14
|
-
expect { api.raw("undefined_resource", q: 'whatever', mode: :raw) }.to raise_error
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OpenWeatherAPI::API do
|
4
|
+
let(:api) { OpenWeatherAPI::API.new( api_key: ENV['OPEN_WEATHER_API_KEY'], default_language: 'es', default_country_code: 'es' ) }
|
5
|
+
|
6
|
+
describe 'When fetching raw rest requests with valid data' do
|
7
|
+
it 'should work' do
|
8
|
+
expect(api.raw("weather", q: 'Santa Cruz de Tenerife,ES')[:cod].to_i).to eq(200)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'When fetching raw rest requests with invalid data' do
|
13
|
+
it 'should fail' do
|
14
|
+
expect { api.raw("undefined_resource", q: 'whatever', mode: :raw) }.to raise_error
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
raise "You MUST setup 'OPEN_WEATHER_API_KEY' env variable before running tests!" unless ENV['OPEN_WEATHER_API_KEY']
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
Bundler.setup
|
5
|
-
|
6
|
-
lib = File.expand_path('../../lib', __FILE__)
|
7
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
8
|
-
require 'open-weather-api'
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
# some (optional) config here
|
1
|
+
raise "You MUST setup 'OPEN_WEATHER_API_KEY' env variable before running tests!" unless ENV['OPEN_WEATHER_API_KEY']
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
lib = File.expand_path('../../lib', __FILE__)
|
7
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
8
|
+
require 'open-weather-api'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# some (optional) config here
|
12
12
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open-weather-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wikiti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.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
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
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: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: fuubar
|
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
|
description: 'Simple wrapper for Open Weather Map API. The API description may be
|
@@ -60,8 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
64
|
-
- .rspec
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
65
|
- CONTRIBUTING.md
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE.txt
|
@@ -95,17 +95,17 @@ require_paths:
|
|
95
95
|
- lib
|
96
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- -
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '0'
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.4.5.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Simple wrapper for Open Weather Map API
|
@@ -115,4 +115,3 @@ test_files:
|
|
115
115
|
- spec/forecast_hourly_spec.rb
|
116
116
|
- spec/raw_spec.rb
|
117
117
|
- spec/spec_helper.rb
|
118
|
-
has_rdoc:
|