wwo 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wwo.rb +7 -36
- data/lib/wwo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 235b3b66844641b8c428a44a2ac5bc95c81406d8
|
4
|
+
data.tar.gz: 033258d57a8fead1f35c700d6d4a0d4d357210e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ff0aeb574c2dd5bc3d966f58af24f2563ba61adc8c4cadf8febccadae39b18474a0f91d9b624abbe51b78681d36df3453ea1dd60508b7a3dae9efbcc7e3087c
|
7
|
+
data.tar.gz: 3eb440c6340ca943b6d9c08ebf4e4e23bf3f94fec39fb413887b53f1571f7010f60a8378830683ef3eec93db28cd657505e34c66eaa073ff11cb571e4c3a8297
|
data/lib/wwo.rb
CHANGED
@@ -14,6 +14,9 @@ module Wwo
|
|
14
14
|
|
15
15
|
class << self
|
16
16
|
|
17
|
+
# Returns a daily breakdown for weather for the provided start and end data at the
|
18
|
+
# specified location.
|
19
|
+
#
|
17
20
|
def date_range(start_date, end_date, latitude, longitude, forecast_compat = false)
|
18
21
|
start_date_string = start_date.strftime('%F')
|
19
22
|
end_date_string = end_date.strftime('%F')
|
@@ -65,41 +68,6 @@ module Wwo
|
|
65
68
|
end_date.to_i >= Time.now.to_i && start_date.to_i >= Time.now.to_i
|
66
69
|
end
|
67
70
|
|
68
|
-
# Returns a daily breakdown for weather for the provided start and end data at the
|
69
|
-
# specified location.
|
70
|
-
#
|
71
|
-
def old_date_range(start_date, end_date, latitude, longitude, forecast_compat = false)
|
72
|
-
starting = start_date.strftime('%F')
|
73
|
-
ending = end_date.strftime('%F')
|
74
|
-
|
75
|
-
if starting == Time.now.strftime('%F') || start_date.to_i > Time.now.utc.to_i || end_date.to_i > Time.now.utc.to_i
|
76
|
-
forecast_uri = "#{Wwo.api_endpoint}/weather.ashx?q=#{latitude},#{longitude}&format=json&num_of_days=7&date=today&cc=no&mca=no&tp=24&key=#{Wwo.api_key}"
|
77
|
-
forecast_response = api_call(forecast_uri)
|
78
|
-
else
|
79
|
-
forecast_response = {}
|
80
|
-
end
|
81
|
-
|
82
|
-
if starting == Time.now.strftime('%F') || start_date.to_i > Time.now.utc.to_i
|
83
|
-
uri = "#{Wwo.api_endpoint}/past-weather.ashx?q=#{latitude},#{longitude}&format=json&extra=utcDateTime&date=#{starting}&enddate=#{ending}&show_comments=no&tp=24&key=#{Wwo.api_key}&mca=false&show_comments=false"
|
84
|
-
api_response = api_call(uri)
|
85
|
-
else
|
86
|
-
api_response = {}
|
87
|
-
end
|
88
|
-
|
89
|
-
if forecast_compat
|
90
|
-
past = make_into_forecast_response(api_response)
|
91
|
-
future = forecast_response.empty? ? {} : make_into_forecast_response(forecast_response)
|
92
|
-
|
93
|
-
unless future.empty?
|
94
|
-
past[:daily][:data] = (past[:daily][:data] + future[:daily][:data]).flatten.uniq
|
95
|
-
end
|
96
|
-
|
97
|
-
return Hashie::Mash.new(past)
|
98
|
-
else
|
99
|
-
return api_response
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
71
|
# Returns an hourly breakdown for the weather "today" at the given location. We get
|
104
72
|
# the current time and then turn it into UTC. Returns a Hashie Mash with every hour of
|
105
73
|
# weather broken down.
|
@@ -195,9 +163,10 @@ module Wwo
|
|
195
163
|
icon = weather.hourly.first.weatherIconUrl.first.value
|
196
164
|
maxTemp = weather.maxtempC
|
197
165
|
minTemp = weather.mintempC
|
166
|
+
condition = weather.weatherCode
|
198
167
|
date = Time.parse("#{weather.date} 12:00:00")
|
199
168
|
|
200
|
-
data[:daily][:data] << { icon: icon, "temperatureMax" => maxTemp, "temperatureMin" => minTemp, date: date }
|
169
|
+
data[:daily][:data] << { icon: icon, "temperatureMax" => maxTemp, "temperatureMin" => minTemp, date: date, conditionCode: condition }
|
201
170
|
end
|
202
171
|
return data
|
203
172
|
else
|
@@ -205,6 +174,8 @@ module Wwo
|
|
205
174
|
data[:daily][:data][0][:icon] = response.data.weather.first.hourly.first.weatherIconUrl.first.value
|
206
175
|
data[:daily][:data][0]['temperatureMax'] = response.data.weather.first.maxtempC
|
207
176
|
data[:daily][:data][0]['temperatureMin'] = response.data.weather.first.mintempC
|
177
|
+
data[:daily][:data][0]["conditionCode"] = response.data.weather.first.weatherCode
|
178
|
+
|
208
179
|
return data
|
209
180
|
end
|
210
181
|
end
|
data/lib/wwo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wwo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 株式会社アルム Allm Inc
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-03-
|
13
|
+
date: 2016-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|