weather_forecaster 0.1.0 → 0.3.0
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/README.md +21 -19
- data/lib/weather_forecaster/version.rb +1 -1
- data/lib/weather_forecaster/weather_forecast_api.rb +26 -21
- data/weather_forecaster.gemspec +4 -4
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ff552660526e63c67f33f5fad2faba5f2829db
|
4
|
+
data.tar.gz: bc19832ce5dca45a3d2b11786b55bd5322600e64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b17e189f49e6d4e8543eabdebf1329e6ec0d68ac31f8173285544f230b8bbc95c8cb259a3c659df34d932f117a9a128a4fddaf4c2361cbd5db4e7bbc8930dbfb
|
7
|
+
data.tar.gz: dc552fe9db4551d8539962cf399631ce054106c4460e2cc242d5329a630df761dfc6dd02019d4e51be1ba38e2f3ef06254f0465fcd87d478d212400d609073c5
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
Weather Forecast finder by city name
|
1
|
+
Weather Forecast finder by city name.
|
2
2
|
|
3
|
-
Description
|
3
|
+
#Description
|
4
4
|
|
5
5
|
WeatherForecaster accepts the city name Ex: London or city name followed by country code Ex: London, GB
|
6
6
|
It can accept the number of days from the current day to get the weather details. It provides the weather information as follows.
|
@@ -10,32 +10,34 @@ It can accept the number of days from the current day to get the weather details
|
|
10
10
|
- Day and night temperature values in Kelvin.
|
11
11
|
- Pressure and humidity
|
12
12
|
- Weather Description.
|
13
|
-
-
|
13
|
+
- Dates of corresponding days.
|
14
14
|
|
15
|
-
Installation
|
15
|
+
#Installation
|
16
16
|
|
17
|
-
gem install
|
17
|
+
- gem install httparty
|
18
|
+
- gem install weather_forecaster -v 0.1.0
|
18
19
|
|
19
|
-
or Add
|
20
|
+
or Add
|
21
|
+
gem "httparty" and
|
22
|
+
gem 'weather_forecaster', '~> 0.1.0' in gemfile.
|
20
23
|
|
21
|
-
Usage
|
24
|
+
# Usage
|
22
25
|
|
23
|
-
require '
|
26
|
+
require 'weather_forecaster'
|
24
27
|
|
25
|
-
|
28
|
+
To get the weather forecast for 5 days from today, default is 1 day.
|
29
|
+
|
26
30
|
forecast = WeatherForecaster.forecast("London", 5)
|
27
31
|
|
28
|
-
forecast.city = London
|
29
|
-
forecast.country = GB
|
30
|
-
forecast.latitude = 51.50853
|
31
|
-
forecast.longitude = -0.12574
|
32
|
-
|
33
|
-
|
34
|
-
forecast.pressure = 1015.35
|
35
|
-
forecast.humidity = 76
|
36
|
-
forecast.weather_description = light rain
|
37
|
-
forecast.date
|
32
|
+
- forecast.city = London
|
33
|
+
- forecast.country = GB
|
34
|
+
- forecast.latitude = 51.50853
|
35
|
+
- forecast.longitude = -0.12574
|
36
|
+
|
37
|
+
To get the details of day , night temperature values, humidity, pressure, weather condition(description), dates of corresponding days
|
38
38
|
|
39
|
+
- forecast.list_details
|
40
|
+
|
39
41
|
Author
|
40
42
|
|
41
43
|
Santosh Turamari
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'json'
|
3
3
|
require 'timeout'
|
4
|
-
require 'httparty'
|
5
4
|
|
6
5
|
module WeatherForecaster
|
7
6
|
class WeatherForecastApi
|
@@ -13,7 +12,7 @@ module WeatherForecaster
|
|
13
12
|
result = {}
|
14
13
|
begin
|
15
14
|
status = Timeout::timeout(5){
|
16
|
-
result = HTTParty.get(@client, :query => {:q=> city, :cnt => count})
|
15
|
+
result = HTTParty.get(@client, :query => {:q=> city, :cnt => count})
|
17
16
|
}
|
18
17
|
rescue Timeout::Error => e
|
19
18
|
puts "Taking too long time", :status => 500
|
@@ -24,26 +23,32 @@ module WeatherForecaster
|
|
24
23
|
end
|
25
24
|
|
26
25
|
class WeatherForecastResponse
|
27
|
-
attr_reader :city, :day_temp, :pressure, :country, :list_details, :latitude, :longitude, :status
|
26
|
+
attr_reader :city, :day_temp, :pressure, :country, :list_details, :latitude, :longitude, :status, :message
|
28
27
|
|
29
28
|
def initialize(result)
|
30
29
|
detail = result.parsed_response
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
30
|
+
if detail['cod'] == "200"
|
31
|
+
@city = detail['city']['name']
|
32
|
+
@country = detail['city']['country']
|
33
|
+
@latitude = detail['city']['coord']['lat']
|
34
|
+
@longitude = detail['city']['coord']['lon']
|
35
|
+
@status = "ok"
|
36
|
+
@list_details = [ ]
|
37
|
+
detail['list'].each do |list|
|
38
|
+
@list_details << {
|
39
|
+
:date => DateTime.strptime(list['dt'].to_s,'%s').strftime,
|
40
|
+
:day_temp => list['temp']['day'],
|
41
|
+
:night_temp => list['temp']['night'],
|
42
|
+
:weather_description => list['weather'][0]['description'],
|
43
|
+
:pressure => list['pressure'],
|
44
|
+
:humidity => list['humidity']
|
45
|
+
}
|
46
|
+
end
|
47
|
+
else
|
48
|
+
@status = "not_ok"
|
49
|
+
@message = [ ]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
48
53
|
end
|
49
|
-
end
|
54
|
+
end
|
data/weather_forecaster.gemspec
CHANGED
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.
|
31
|
-
spec.
|
32
|
-
spec.
|
33
|
-
spec.
|
30
|
+
spec.add_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_dependency "rspec", "~> 0"
|
33
|
+
spec.add_dependency "httparty", "~> 0"
|
34
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weather_forecaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SANTOSH TURAMARI
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
|
-
type: :
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
|
-
type: :
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -42,28 +42,28 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
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: httparty
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
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: '0'
|
69
69
|
description: "WeatherForecaster accepts the city name Ex: London or city name followed
|