roker 0.0.0 → 0.1.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.
- data/VERSION +1 -1
- data/lib/roker.rb +4 -2
- data/roker +58 -29
- data/roker.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/roker.rb
CHANGED
@@ -142,7 +142,9 @@ protected
|
|
142
142
|
|
143
143
|
def weather_xml_soap
|
144
144
|
soap_driver = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
|
145
|
-
|
145
|
+
request_started_at = (self.started_at-1).strftime("%Y-%m-%dT%H:%M:%S-05:00")
|
146
|
+
request_ended_at = self.ended_at.strftime("%Y-%m-%dT%H:%M:%S-05:00")
|
147
|
+
soap_driver.NDFDgen(self.lat, self.lng, WSDL_PRODUCT, request_started_at, request_ended_at, WSDL_PARAMETERS)
|
146
148
|
end
|
147
149
|
|
148
150
|
def weather_xml_uri
|
@@ -158,7 +160,7 @@ protected
|
|
158
160
|
sprintf("http://www.weather.gov/forecasts/xml/sample_products/" +
|
159
161
|
"browser_interface/ndfdBrowserClientByDay.php?" +
|
160
162
|
"&format=24+hourly&numDays=%s&lat=%s&lon=%s&startDate=%s",
|
161
|
-
num_days, self.lat, self.lng, self.started_at.
|
163
|
+
num_days, self.lat, self.lng, self.started_at.strftime("%Y-%m-%d"))
|
162
164
|
end
|
163
165
|
|
164
166
|
def self.parse_time(str='')
|
data/roker
CHANGED
@@ -2,41 +2,70 @@
|
|
2
2
|
require File.dirname(__FILE__) + '/lib/roker'
|
3
3
|
require 'ruby-debug'
|
4
4
|
|
5
|
-
|
6
|
-
ended_at = started_at.end_of_day
|
7
|
-
lat = 37.0625
|
8
|
-
lng = -95.677068
|
5
|
+
args = ARGV.join(' ')
|
9
6
|
|
10
|
-
|
11
|
-
|
7
|
+
help = !(args =~ /--help/).nil?
|
8
|
+
|
9
|
+
if help
|
10
|
+
puts "Roker provides weather forecasts from weather.gov."
|
11
|
+
puts "\tUsage: roker [options...]\n"
|
12
|
+
puts "\tOptions:"
|
13
|
+
puts "\t\t--date DATE\t\t\tForecast date (mm/dd/yyyy)"
|
14
|
+
puts "\t\t--lat LATITUDE\t\t\tForecast latitude (37.0625)"
|
15
|
+
puts "\t\t--lng LONGITUDE\t\t\tForecast longitude (-95.677)"
|
16
|
+
puts "\t\t--xml\t\t\t\tDisplay xml result from weather.gov"
|
17
|
+
puts "\t\t--help\t\t\t\tDisplay this help message"
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
if args =~ /--date *(\d+\/\d+\/\d+)/
|
22
|
+
$1 =~ /(\d+)\/(\d+)\/(\d+)/
|
23
|
+
started_at = Time.mktime($3.to_i, $1.to_i, $2.to_i, 0, 0, 0, 0, 0).beginning_of_day
|
12
24
|
end
|
25
|
+
|
26
|
+
lat = $1.to_f if args =~ /--lat *([0-9\.\-\+]+)/
|
27
|
+
lng = $1.to_f if args =~ /--lng *([0-9\.\-\+]+)/
|
28
|
+
|
29
|
+
xml = !(args =~ /--xml/).nil?
|
30
|
+
|
31
|
+
started_at ||= Time.now.beginning_of_day + 1.day
|
32
|
+
ended_at ||= started_at.end_of_day
|
33
|
+
lat ||= 37.0625
|
34
|
+
lng ||= -95.677068
|
35
|
+
|
36
|
+
puts "Roker says the forecast for #{started_at.strftime("%B %d, %Y")} in #{lat}, #{lng} is:\n"
|
37
|
+
|
13
38
|
roker = Roker.new(:started_at => started_at, :ended_at => ended_at, :lat => lat, :lng => lng)
|
14
39
|
|
15
|
-
|
40
|
+
forecast_str = ''
|
16
41
|
|
17
|
-
|
18
|
-
weather_forecasts_attributes.each do |wfa|
|
42
|
+
roker.weather_forecasts_attributes.each do |wfa|
|
19
43
|
# wfa => {
|
20
|
-
# :started_at=>Sat Dec 05 00:17:32 -0500 2009,
|
21
|
-
# :
|
22
|
-
# :
|
23
|
-
# :
|
24
|
-
# :
|
25
|
-
# :
|
26
|
-
# :
|
27
|
-
# :
|
28
|
-
# :
|
29
|
-
# :
|
30
|
-
# :
|
31
|
-
# :
|
32
|
-
# :maximum_temperature=>nil,
|
33
|
-
# :wave_height=>0.0,
|
34
|
-
# :probability_of_precipitation=>0.0
|
44
|
+
# :started_at => Sat Dec 05 00:17:32 -0500 2009,
|
45
|
+
# :ended_at => Sat Dec 05 03:17:32 -0500 2009,
|
46
|
+
# :lat => 37.0625,
|
47
|
+
# :lng => -95.677068,
|
48
|
+
# :wind_speed => 7.0,
|
49
|
+
# :minimum_temperature => 21.0,
|
50
|
+
# :wind_direction => 180.0,
|
51
|
+
# :temperature => 24.0,
|
52
|
+
# :cloud_cover => 0.0,
|
53
|
+
# :dewpoint_temperature => 12.0,
|
54
|
+
# :relative_humidity => 60.0,
|
55
|
+
# :liquid_precipitation => 0.0,
|
56
|
+
# :maximum_temperature => nil,
|
57
|
+
# :wave_height => 0.0,
|
58
|
+
# :probability_of_precipitation => 0.0
|
35
59
|
# }
|
36
|
-
temp = wfa[:temperature].nan? ? '?' : wfa[:temperature].to_i.to_s
|
37
|
-
pop = wfa[:probability_of_precipitation].nan? ? '?' : wfa[:probability_of_precipitation].to_i.to_s
|
38
|
-
|
39
|
-
|
60
|
+
temp = (wfa[:temperature].nil? || wfa[:temperature].nan?) ? '?' : wfa[:temperature].to_i.to_s
|
61
|
+
pop = (wfa[:probability_of_precipitation].nil? || wfa[:probability_of_precipitation].nan?) ? '?' : wfa[:probability_of_precipitation].to_i.to_s
|
62
|
+
forecast_str << wfa[:started_at].strftime("%I:%M%p") + "\t" + temp + " deg" + "\t" + pop + "% P.O.P."
|
63
|
+
forecast_str << "\n"
|
40
64
|
end
|
41
65
|
|
42
|
-
puts
|
66
|
+
puts forecast_str
|
67
|
+
|
68
|
+
if xml
|
69
|
+
puts "XML:\n"
|
70
|
+
puts roker.weather_xml
|
71
|
+
end
|
data/roker.gemspec
CHANGED