noaa-weather 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +59 -0
- data/Manifest.txt +8 -0
- data/README.txt +48 -0
- data/Rakefile +21 -0
- data/bin/noaa-weather +0 -0
- data/lib/noaa-weather.rb +78 -0
- data/spec/noaa-weather.spec +58 -0
- data/test/test_noaaweather.rb +0 -0
- metadata +104 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/History.txt
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
commit 9821b5425f76bed852282937893949ef7047007d
|
2
|
+
Author: Joshua Smith <kognate@gmail.com>
|
3
|
+
Date: Wed Mar 18 23:45:49 2009 -0400
|
4
|
+
|
5
|
+
added icon return
|
6
|
+
|
7
|
+
commit 45979bf0cbfb335a3a95cdf60522dcccc8c7ea27
|
8
|
+
Author: Joshua Smith <kognate@gmail.com>
|
9
|
+
Date: Wed Mar 18 23:45:39 2009 -0400
|
10
|
+
|
11
|
+
added icon download and method to return the current icon from NOAA
|
12
|
+
|
13
|
+
commit 67886568c353c8488f268e609cf89972e83e243c
|
14
|
+
Author: Joshua Smith <kognate@gmail.com>
|
15
|
+
Date: Wed Mar 18 16:50:19 2009 -0400
|
16
|
+
|
17
|
+
fixed file caching (still pretty niave)
|
18
|
+
|
19
|
+
commit 6c5e0f92cb83b271ea50e91cbec8bb50de41b6c7
|
20
|
+
Author: Joshua Smith <kognate@gmail.com>
|
21
|
+
Date: Wed Mar 18 10:57:06 2009 -0400
|
22
|
+
|
23
|
+
fixed file based caching and fetching, made calls to private methods for specific stuff (like fetching from noaa)
|
24
|
+
|
25
|
+
commit c202409a54553295ee8002564e9294fb28bfe18b
|
26
|
+
Author: Joshua Smith <kognate@gmail.com>
|
27
|
+
Date: Wed Mar 18 10:56:27 2009 -0400
|
28
|
+
|
29
|
+
added logger
|
30
|
+
|
31
|
+
commit e96f79f00a757a102fd0cc5c724e924a6768a8d2
|
32
|
+
Author: Joshua Smith <kognate@gmail.com>
|
33
|
+
Date: Wed Mar 18 10:56:07 2009 -0400
|
34
|
+
|
35
|
+
changed conditions to actually work
|
36
|
+
|
37
|
+
commit 6d9b1d79e2171f11c5d956cbb5e1cefdc2f8fdee
|
38
|
+
Author: Joshua Smith <kognate@gmail.com>
|
39
|
+
Date: Wed Mar 18 10:54:55 2009 -0400
|
40
|
+
|
41
|
+
missed a name change
|
42
|
+
|
43
|
+
commit 14e253f305a1e50aaf8ce0dec04d8aaa6064a5b7
|
44
|
+
Author: Joshua Smith <kognate@gmail.com>
|
45
|
+
Date: Wed Mar 18 10:08:50 2009 -0400
|
46
|
+
|
47
|
+
renamed all the files to their final name. removed bogus packages
|
48
|
+
|
49
|
+
commit a0f70d4969d9cbf019bd65bf0c5e360198633305
|
50
|
+
Author: Joshua B. Smith <jsmith@dixcom.com>
|
51
|
+
Date: Wed Mar 18 10:00:51 2009 -0400
|
52
|
+
|
53
|
+
refactored the fetch method and added some more behaviors
|
54
|
+
|
55
|
+
commit 5e37508bcac786de6a78eb12300ebd156b25ae7d
|
56
|
+
Author: Joshua B. Smith <jsmith@dixcom.com>
|
57
|
+
Date: Wed Mar 18 09:32:47 2009 -0400
|
58
|
+
|
59
|
+
initial commit
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= dixweather
|
2
|
+
|
3
|
+
* FIX (url)
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2009 FIX
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/noaa-weather.rb'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
|
8
|
+
Hoe.new('noaa-weather', Noaaweather::VERSION) do |p|
|
9
|
+
p.rubyforge_name = 'noaa-weather' # if different than lowercase project name
|
10
|
+
p.developer('kognate', 'kognate@gmail.com')
|
11
|
+
p.extra_deps << ['libxml-ruby']
|
12
|
+
end
|
13
|
+
|
14
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
15
|
+
t.spec_files = FileList['spec/*.spec']
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => :spec
|
19
|
+
|
20
|
+
|
21
|
+
# vim: syntax=Ruby
|
data/bin/noaa-weather
ADDED
File without changes
|
data/lib/noaa-weather.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'soap/wsdlDriver'
|
2
|
+
require 'logger'
|
3
|
+
require 'libxml'
|
4
|
+
require 'xml'
|
5
|
+
|
6
|
+
class Noaaweather
|
7
|
+
VERSION = '0.1.0'
|
8
|
+
attr_accessor :lattitude,:longitude, :start_time
|
9
|
+
|
10
|
+
def initialize(site)
|
11
|
+
|
12
|
+
self.lattitude = 41.190856
|
13
|
+
self.longitude = -81.446962
|
14
|
+
|
15
|
+
@logger = Logger.new(STDOUT)
|
16
|
+
|
17
|
+
@site = site
|
18
|
+
|
19
|
+
self.start_time = Time.now()
|
20
|
+
@is_cached = false
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_temp
|
24
|
+
self.fetch unless @fetched
|
25
|
+
@ctemp ||= @doc.find('/dwml/data/parameters/temperature/value')[0].content.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
def location
|
29
|
+
@site.to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def current_conditions(ashash=false)
|
33
|
+
|
34
|
+
self.fetch unless @fetched
|
35
|
+
_c = @doc.find('/dwml/data/parameters/weather/weather-conditions/value')[0]
|
36
|
+
if ashash
|
37
|
+
{:coverage => _c['coverage'],:weathertype => _c['weather-type']}
|
38
|
+
else
|
39
|
+
@ccond ||= sprintf("%s %s",_c['coverage'],_c['weather-type'])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def current_icon
|
44
|
+
self.fetch unless @fetched
|
45
|
+
@cicon ||= @doc.find('/dwml/data/parameters/conditions-icon/icon-link')[0].content
|
46
|
+
end
|
47
|
+
|
48
|
+
def cached?
|
49
|
+
@is_cached
|
50
|
+
end
|
51
|
+
|
52
|
+
def fetch
|
53
|
+
@doc = fetch_from_noaa
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def fetch_from_noaa
|
58
|
+
|
59
|
+
_dat = if File.exists?("/tmp/weatherfile-#{@site}") && (File.ctime("/tmp/weatherfile-#{@site}") > (Time.now - 3600))
|
60
|
+
f = open("/tmp/weatherfile-#{@site}")
|
61
|
+
f.read()
|
62
|
+
else
|
63
|
+
@soap ||= SOAP::WSDLDriverFactory.new('http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl').create_rpc_driver
|
64
|
+
_res = @soap.NDFDgen(self.lattitude,self.longitude,'time-series',self.start_time,nil,{:temp => true,:wx => true, :icons => true })
|
65
|
+
cache_to_file(_res)
|
66
|
+
_res
|
67
|
+
end
|
68
|
+
par = XML::Parser.string(_dat)
|
69
|
+
@doc = par.parse
|
70
|
+
end
|
71
|
+
|
72
|
+
def cache_to_file(dat)
|
73
|
+
f = open("/tmp/weatherfile-#{@site}",'w')
|
74
|
+
f.write(dat.to_s)
|
75
|
+
f.close()
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'lib/noaa-weather'
|
3
|
+
describe Noaaweather do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@w = Noaaweather.new(:ravenna)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have lattitude as a float" do
|
10
|
+
@w.lattitude.should_not be_nil
|
11
|
+
@w.lattitude.should be_an_instance_of(Float)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have longitude as a float" do
|
15
|
+
@w.longitude.should_not be_nil
|
16
|
+
@w.longitude.should be_an_instance_of(Float)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should give us a string telling us what location it is getting weather for" do
|
20
|
+
@w.location.should_not be_nil
|
21
|
+
@w.location.should be_an_instance_of(String)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should report current temperature as a Fixnum" do
|
25
|
+
@w.current_temp.should_not be_nil
|
26
|
+
@w.current_temp.should be_an_instance_of(Fixnum)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should report current conditions as a string" do
|
30
|
+
@w.current_conditions.should_not be_nil
|
31
|
+
@w.current_conditions.should be_an_instance_of(String)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should report the current conditions as a hash with attributes when passed true" do
|
35
|
+
@w.current_conditions(true).should_not be_nil
|
36
|
+
@w.current_conditions(true).should be_an_instance_of(Hash)
|
37
|
+
@w.current_conditions(true)[:coverage].should_not be_nil
|
38
|
+
@w.current_conditions(true)[:weathertype].should_not be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should report if the data is from a cached store or not" do
|
42
|
+
@w.cached?.should satisfy {|x| [true,false].include?(x) }
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have an attribute of start_time" do
|
46
|
+
@w.start_time.should_not be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a weather icon" do
|
50
|
+
@w.current_icon.should_not be_nil
|
51
|
+
@w.current_icon.should be_an_instance_of(String)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have a fetch method that returns greater than 0" do
|
55
|
+
@w.should respond_to(:fetch)
|
56
|
+
@w.fetch.should_not be_nil
|
57
|
+
end
|
58
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: noaa-weather
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kognate
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MRAwDgYDVQQDDAdrb2du
|
14
|
+
YXRlMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEz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7jnQwCUz0RR9UPJyiB5+sf4pAzcz24difqcvm0Wo9icq35fUP4bghlBSQxjPa
|
30
|
+
M36Zgg==
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2009-03-20 00:00:00 -04:00
|
34
|
+
default_executable:
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: libxml-ruby
|
38
|
+
type: :runtime
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hoe
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.8.3
|
55
|
+
version:
|
56
|
+
description: FIX (describe your package)
|
57
|
+
email:
|
58
|
+
- kognate@gmail.com
|
59
|
+
executables:
|
60
|
+
- noaa-weather
|
61
|
+
extensions: []
|
62
|
+
|
63
|
+
extra_rdoc_files:
|
64
|
+
- History.txt
|
65
|
+
- Manifest.txt
|
66
|
+
- README.txt
|
67
|
+
files:
|
68
|
+
- History.txt
|
69
|
+
- Manifest.txt
|
70
|
+
- README.txt
|
71
|
+
- Rakefile
|
72
|
+
- bin/noaa-weather
|
73
|
+
- lib/noaa-weather.rb
|
74
|
+
- test/test_noaaweather.rb
|
75
|
+
- spec/noaa-weather.spec
|
76
|
+
has_rdoc: true
|
77
|
+
homepage: FIX (url)
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options:
|
80
|
+
- --main
|
81
|
+
- README.txt
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
version:
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project: noaa-weather
|
99
|
+
rubygems_version: 1.3.1
|
100
|
+
signing_key:
|
101
|
+
specification_version: 2
|
102
|
+
summary: FIX (describe your package)
|
103
|
+
test_files:
|
104
|
+
- test/test_noaaweather.rb
|
metadata.gz.sig
ADDED
Binary file
|