noaa-weather 0.1.0 → 0.1.1
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.tar.gz.sig +0 -0
- data/History.txt +3 -56
- data/lib/noaa-weather.rb +58 -8
- data/spec/noaa-weather.spec +24 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
|
Binary file
|
data/History.txt
CHANGED
|
@@ -1,59 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Author: Joshua Smith <kognate@gmail.com>
|
|
3
|
-
Date: Wed Mar 18 23:45:49 2009 -0400
|
|
1
|
+
=== 1.0.0 / 2009-03-17
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
* 1 major enhancement
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
Author: Joshua Smith <kognate@gmail.com>
|
|
9
|
-
Date: Wed Mar 18 23:45:39 2009 -0400
|
|
5
|
+
* Birthday!
|
|
10
6
|
|
|
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/lib/noaa-weather.rb
CHANGED
|
@@ -1,21 +1,65 @@
|
|
|
1
1
|
require 'soap/wsdlDriver'
|
|
2
2
|
require 'logger'
|
|
3
3
|
require 'libxml'
|
|
4
|
+
require 'geokit'
|
|
4
5
|
require 'xml'
|
|
6
|
+
require 'digest'
|
|
5
7
|
|
|
6
|
-
class
|
|
7
|
-
|
|
8
|
-
attr_accessor :lattitude,:longitude, :start_time
|
|
8
|
+
class BadLocation < Exception
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
class CachedGeocode
|
|
12
|
+
attr_accessor :address, :geocoding
|
|
13
|
+
include GeoKit::Geocoders
|
|
14
|
+
def geocode
|
|
15
|
+
self.geocoding = gcode_cache_read
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
{:lat => self.geocoding.lat,
|
|
18
|
+
:lon => self.geocoding.lng,
|
|
19
|
+
:site => self.geocoding.city.gsub(/[^a-zA-Z0-9]/,'_')}
|
|
20
|
+
end
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
def cached?
|
|
23
|
+
@cached ||= false
|
|
24
|
+
end
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
private
|
|
27
|
+
def gcode_cache_read
|
|
28
|
+
_hdad = Digest::SHA1.hexdigest(self.address)
|
|
29
|
+
if File.exists?("/tmp/#{_hdad}")
|
|
30
|
+
@cached = true
|
|
31
|
+
YAML::load_file("/tmp/#{_hdad}")
|
|
32
|
+
else
|
|
33
|
+
_z = MultiGeocoder.geocode(self.address)
|
|
34
|
+
raise BadLocation.new("Address Not Found: #{self.address}") unless _z.success
|
|
35
|
+
f = open("/tmp/#{_hdad}","w")
|
|
36
|
+
f.write(_z.to_yaml)
|
|
37
|
+
f.close
|
|
38
|
+
@cached = true
|
|
39
|
+
_z
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
18
43
|
|
|
44
|
+
class Noaaweather < CachedGeocode
|
|
45
|
+
VERSION = '0.1.1'
|
|
46
|
+
attr_accessor :lattitude,:longitude, :start_time
|
|
47
|
+
|
|
48
|
+
def initialize(site,as_address=false)
|
|
49
|
+
|
|
50
|
+
if as_address
|
|
51
|
+
self.address = site
|
|
52
|
+
_z = geocode
|
|
53
|
+
self.lattitude = _z[:lat]
|
|
54
|
+
self.longitude = _z[:lon]
|
|
55
|
+
@site = _z[:site]
|
|
56
|
+
else
|
|
57
|
+
self.lattitude = 41.190856
|
|
58
|
+
self.longitude = -81.446962
|
|
59
|
+
@site = site
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
@logger = Logger.new(STDOUT)
|
|
19
63
|
self.start_time = Time.now()
|
|
20
64
|
@is_cached = false
|
|
21
65
|
end
|
|
@@ -74,5 +118,11 @@ class Noaaweather
|
|
|
74
118
|
f.write(dat.to_s)
|
|
75
119
|
f.close()
|
|
76
120
|
end
|
|
121
|
+
|
|
122
|
+
def cache_geo_to_file(site,dat)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def load_geo_from_file(site)
|
|
126
|
+
end
|
|
77
127
|
|
|
78
128
|
end
|
data/spec/noaa-weather.spec
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'lib/noaa-weather'
|
|
3
|
+
|
|
4
|
+
describe CachedGeocode do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@cg = CachedGeocode.new
|
|
7
|
+
@cg.address = "1060 W. Addison St., Chicago, IL"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should respond to address and address=" do
|
|
11
|
+
@cg.should respond_to(:address)
|
|
12
|
+
@cg.should respond_to(:address=)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should respond to geocode and not be nil" do
|
|
16
|
+
@cg.should respond_to(:geocode)
|
|
17
|
+
@cg.geocode.should_not be_nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should respond to cached?" do
|
|
21
|
+
@cg.should respond_to(:cached?)
|
|
22
|
+
@cg.cached?.should satisfy {|x| [true,false].include?(x) }
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
3
26
|
describe Noaaweather do
|
|
4
27
|
|
|
5
28
|
before(:each) do
|
|
6
|
-
@w = Noaaweather.new(
|
|
29
|
+
@w = Noaaweather.new("1060 W. Addison St., Chicago, IL",true)
|
|
7
30
|
end
|
|
8
31
|
|
|
9
32
|
it "should have lattitude as a float" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: noaa-weather
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kognate
|
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
|
30
30
|
M36Zgg==
|
|
31
31
|
-----END CERTIFICATE-----
|
|
32
32
|
|
|
33
|
-
date: 2009-03-
|
|
33
|
+
date: 2009-03-21 00:00:00 -04:00
|
|
34
34
|
default_executable:
|
|
35
35
|
dependencies:
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
|
Binary file
|