-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed node-recorder to node-sampler
- Loading branch information
Showing
5 changed files
with
69 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,27 +5,24 @@ | |
"email" : "[email protected]", | ||
"url" : "http://github.com/daizoru" | ||
}, | ||
"name": "recorder", | ||
"name": "sampler", | ||
"description": "Record things, play them back", | ||
"version": "0.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/daizoru/node-recorder.git" | ||
"url": "git://github.com/daizoru/node-sampler.git" | ||
}, | ||
"directories" : { | ||
"lib" : "./lib", | ||
"examples" : "./examples", | ||
"test" : "./test" | ||
}, | ||
"main" : "./lib/recorder", | ||
"main" : "./lib/sampler", | ||
"scripts" : { | ||
"build" : "coffee --compile --output lib/ src/", | ||
"watch" : "coffee --watch --compile --output lib/ src/", | ||
"pretest" : "coffee --compile --output lib/ src/", | ||
"watch" : "coffee --watch --compile --output lib/ src/", | ||
"test" : "mocha", | ||
"html" : "mocha --reporter doc", | ||
"prestart" : "coffee --compile --output lib/ src/", | ||
"start" : "./bin/hydrant" | ||
"html" : "mocha --reporter doc" | ||
}, | ||
"engines": { | ||
"node": "0.6.x || 0.7.x" | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,57 @@ | ||
Recorder = require '../lib/recorder' | ||
Sampler = require '../lib/sampler' | ||
{log,error,inspect} = require 'util' | ||
delay = (t,f) -> setTimeout f, t | ||
|
||
# these are not real tests, it's more like a demo | ||
# more complete tests should check for returned values!!! | ||
|
||
# our tests | ||
describe 'Recorder', -> | ||
describe '#new Recorder()', -> | ||
it 'should work', (done) -> | ||
|
||
record = new Recorder() | ||
record.on 'event', (event) -> log "#{event.timestamp}: #{inspect event.data}" | ||
|
||
# record some dummy events | ||
log "recording events.." | ||
delay 100, -> record.rec companyhelpdesk: "hi how can I help you" | ||
delay 500, -> record.rec facebook: "wow! this was a big earthquake" | ||
delay 1000, -> record.rec twitter: "just saw my dead neighbor walking in my street. It's weird. wait I'm gonna check it out" | ||
delay 1500, -> record.rec twitter: "ZOMBIE APOCALYPSE!!1!!" | ||
describe 'Sampler', -> | ||
describe '#Sampler()', -> | ||
it 'should record', (done) -> | ||
sample = new Sampler() | ||
sample.on 'event', (event) -> log "#{event.timestamp}: #{inspect event.data}" | ||
|
||
# sample some dummy events | ||
log "sampling events.." | ||
delay 100, -> sample.rec companyhelpdesk: "hi how can I help you" | ||
delay 500, -> sample.rec facebook: "wow! this was a big earthquake" | ||
delay 1000, -> sample.rec twitter: "just saw my dead neighbor walking in my street. It's weird. wait I'm gonna check it out" | ||
delay 1500, -> sample.rec twitter: "ZOMBIE APOCALYPSE!!1!!" | ||
delay 1600, -> done() | ||
|
||
it 'should playback at normal speed', (done) -> | ||
sample = new Sampler() | ||
sample.on 'event', (event) -> log "#{event.timestamp}: #{inspect event.data}" | ||
|
||
# sample some dummy events | ||
log "sampling events.." | ||
delay 100, -> sample.rec companyhelpdesk: "hi how can I help you" | ||
delay 500, -> sample.rec facebook: "wow! this was a big earthquake" | ||
delay 1000, -> sample.rec twitter: "just saw my dead neighbor walking in my street. It's weird. wait I'm gonna check it out" | ||
delay 1500, -> sample.rec twitter: "ZOMBIE APOCALYPSE!!1!!" | ||
|
||
delay 1600, -> | ||
log "playing events back.." | ||
record.play() | ||
sample.play() | ||
done() | ||
|
||
#if (err) throw err | ||
|
||
delay 100, -> | ||
log "playing events back. and faster." | ||
record.play 5.0 # 2.0x | ||
done() | ||
it 'should playback faster', (done) -> | ||
sample = new Sampler() | ||
sample.on 'event', (event) -> log "#{event.timestamp}: #{inspect event.data}" | ||
|
||
# sample some dummy events | ||
log "sampling events.." | ||
delay 100, -> sample.rec companyhelpdesk: "hi how can I help you" | ||
delay 500, -> sample.rec facebook: "wow! this was a big earthquake" | ||
delay 1000, -> sample.rec twitter: "just saw my dead neighbor walking in my street. It's weird. wait I'm gonna check it out" | ||
delay 1500, -> sample.rec twitter: "ZOMBIE APOCALYPSE!!1!!" | ||
|
||
delay 1600, -> | ||
log "playing events faster.." | ||
sample.play 4.0 | ||
done() | ||
|
||
#if (err) throw err | ||
#if (err) throw err |