diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-01-08 16:44:44 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-01-08 17:01:27 -0800 |
commit | 0b6fe07c10278266e2f428a4355b7edfc13781cd (patch) | |
tree | 917e3510c0ea47fd27f858ada0076cc0864afd1f /t/cramp | |
parent | 23bf8da0774b21d8c55786b4b386faba4b53c97f (diff) | |
download | rainbows-0b6fe07c10278266e2f428a4355b7edfc13781cd.tar.gz |
Tested with cramp-0.7 and eventmachine 0.12.10
Diffstat (limited to 't/cramp')
-rw-r--r-- | t/cramp/README | 3 | ||||
-rw-r--r-- | t/cramp/streaming.ru | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/t/cramp/README b/t/cramp/README new file mode 100644 index 0000000..9fffe89 --- /dev/null +++ b/t/cramp/README @@ -0,0 +1,3 @@ +These examples in this directory are stolen from Cramp with only trivial +changes. All examples in this directory retain their original license +(MIT) and copyrights. diff --git a/t/cramp/streaming.ru b/t/cramp/streaming.ru new file mode 100644 index 0000000..dc470b2 --- /dev/null +++ b/t/cramp/streaming.ru @@ -0,0 +1,28 @@ +# based on examples/streaming.rb in git://github.com/lifo/cramp +# commit ca54f8a944ae582a0c858209daf3c74efea7d27c + +# Rack::Lint does not like async + EM stuff, so disable it: +#\ -E deployment + +require 'cramp/controller' + +class StreamController < Cramp::Controller::Action + periodic_timer :send_data, :every => 1 + periodic_timer :check_limit, :every => 2 + + def start + @limit = 0 + end + + def send_data + render ["Hello World", "\n"] + end + + def check_limit + @limit += 1 + finish if @limit > 1 + end + +end + +run StreamController |