Skip to content
Browse files

some ideas

  • Loading branch information...
1 parent 14d910c commit 2dab5714349474e0f3009fa7bebac5ad6d05c6e5 @bennage committed Mar 21, 2013
Showing with 29 additions and 34 deletions.
  1. +5 −6 src/hairforecast.coffee
  2. +1 −2 src/hf_web_service.coffee
  3. +2 −3 src/json_finder.coffee
  4. +19 −20 src/noaa.coffee
  5. +1 −1 test/hf_web_service.coffee
  6. +1 −2 test/noaa.coffee
View
11 src/hairforecast.coffee
@@ -5,22 +5,21 @@ class HairForecast
constructor: (noaa_xml) ->
@noaa = xml.parseString noaa_xml
- data = {
+ data =
period: null
hairforecast: null
temp: null
- weather: null }
+ weather: null
- @forecast = {
+ @forecast =
start_time: new Date(Date.parse @noaa.childs[0].childs[0].childs[3].childs[0])
time0: data
time1: data
time2: data
time3: data
time4: data
- time5: data }
+ time5: data
humanize_time: (t) ->
-root = exports ? window
-root.HairForecast = HairForecast
+exports = HairForecast
View
3 src/hf_web_service.coffee
@@ -8,5 +8,4 @@ class HFWebService
app.listen(options.port)
-root = exports ? window
-root.HFWebService = HFWebService
+exports = HFWebService
View
5 src/json_finder.coffee
@@ -15,10 +15,9 @@ class JsonFinder
return result
get_attr: (name) ->
- "not impleneted yet"
+ throw new Error "not impleneted yet"
get_children: (name) ->
return this.descend(name, @json)
-root = exports ? window
-root.JsonFinder = JsonFinder
+exports = JsonFinder
View
39 src/noaa.coffee
@@ -1,28 +1,27 @@
request = require 'request'
querystring = require 'querystring'
-class Noaa
+@base_url = 'http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?'
- constructor: () ->
- @base_url = 'http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?'
+by_zip = (zip, callback) ->
+ query = querystring.stringify {
+ zipCodeList: zip
+ product: 'time-series'
+ temp: 'temp'
+ dew: 'dew',
+ pop12: 'pop12',
+ wspd: 'wspd',
+ sky: 'sky',
+ wx: 'wx'
+ }
- get_forecast_by_zip: (zip, callback) ->
- query = querystring.stringify {
- zipCodeList: zip
- product: 'time-series'
- temp: 'temp'
- dew: 'dew',
- pop12: 'pop12',
- wspd: 'wspd',
- sky: 'sky',
- wx: 'wx'
- }
+ url = @base_url + query
- request @base_url + query, (err,res,body) ->
- callback(body)
+ request url, (err,res,body) ->
+ callback(body)
- get_forecast_by_coordinates: (lat,lon) ->
+by_coordinates = (lat,lon) ->
-
-root = exports ? window
-root.Noaa = Noaa
+exports =
+ get_forecast_by_zip: by_zip
+ get_forecast_by_coordinates: by_coordinates
View
2 test/hf_web_service.coffee
@@ -1,4 +1,4 @@
-{HFWebService} = require '../src/hf_web_service'
+HFWebService = require '../src/hf_web_service'
request = require 'request'
chai = require 'chai'
chai.should()
View
3 test/noaa.coffee
@@ -1,11 +1,10 @@
-{Noaa} = require '../src/noaa'
+noaa = require '../src/noaa'
xml = require 'node-xml-lite'
chai = require 'chai'
chai.should()
describe 'Noaa', ->
this.timeout 5000
- noaa = new Noaa()
before (done) ->
noaa.get_forecast_by_zip '40299', (response) =>
@response = response

0 comments on commit 2dab571

Please sign in to comment.
Something went wrong with that request. Please try again.