Permalink
Browse files

Woooo

  • Loading branch information...
airhorns committed Sep 18, 2011
1 parent 8aa7c37 commit b3440c20d2acb71fe309267fe5aef97230ee6632
View
@@ -1 +1,3 @@
node_modules
+*.txt
+*_compiled.js
@@ -1,6 +1,8 @@
nodeio = require 'node.io'
+coffee = require 'coffee-script'
+busters = require '../lib/busters'
-@class = class Listing extends nodeio.JobClass
+@class = class Listing extends busters.Job
input: ["http://www.autotrader.ca/a/Mercedes-Benz/C-Class/MILLGROVE/Ontario/19_4430793_/"]
run: (url) ->
@getHtml url, (err, $) =>
@@ -55,4 +57,3 @@ nodeio = require 'node.io'
null
@job = new Listing()
-
@@ -1,6 +1,7 @@
nodeio = require 'node.io'
+busters = require '../lib/busters'
-@class = class ListingUrls extends nodeio.JobClass
+@class = class ListingUrls extends busters.Job
input: ["http://www.autotrader.ca/a/pv/Used/Mercedes-Benz/C-Class/MERCEDESBENZ+CCLASS/?cat2=7%2c11%2c9%2c10&prv=Ontario"]
run: (url) ->
@getHtml url, (err, $) =>
@@ -1,6 +1,6 @@
-nodeio = require 'node.io'
+busters = require '../lib/busters'
-@class = class ListingSearch extends nodeio.JobClass
+@class = class ListingSearch extends busters.Job
RCS_RE = /rcs=(\d+)/
input: ["http://www.autotrader.ca/a/pv/Used/Mercedes-Benz/C-Class/MERCEDESBENZ+CCLASS/?cat2=7%2c11%2c9%2c10&prv=Ontario"]
@@ -2,7 +2,7 @@ nodeio = require 'node.io'
coffee = require 'coffee-script'
busters = require '../lib/busters'
-@class = class SaveToDB extends nodeio.JobClass
+@class = class SaveToDB extends busters.Job
input: [{"year":"2011","brand":"Mercedes-Benz","model":"C63 AMG","trim":"Affalterbach Edition","drive":"RWD","status":"Used","mileage":"27","body":"Sedan","exteriorcolour":"Not Specified","price":"117000"}]
run: (attributes) ->
for k in ['year', 'mileage', 'price']
@@ -15,4 +15,5 @@ busters = require '../lib/busters'
else
@emit listing
null
+
@job = new SaveToDB()
View
@@ -1,4 +1,5 @@
mongoose = require 'mongoose'
+nodeio = require 'node.io'
mongoose.connect 'mongodb://localhost/busters'
@@ -15,3 +16,20 @@ ListingSchema = new mongoose.Schema
price: Number
exports.Listing = mongoose.model 'Listing', ListingSchema
+
+exports.Job = class Job extends nodeio.JobProto
+ constructor: ->
+ super
+ this.handleSpecialIO()
+
+ extend: (options, methods) ->
+ if typeof methods is "undefined"
+ methods = options
+ options = {}
+
+ class Child extends @constructor
+ @::[k] = v for k, v of methods
+
+ options[k] = v for k, v of @options when !options[k]
+
+ new Child(options)

0 comments on commit b3440c2

Please sign in to comment.