clean stuff up

This commit is contained in:
John Bintz 2012-07-09 16:57:47 -04:00
parent 832e320edd
commit bccee388db
4 changed files with 34 additions and 20 deletions

View File

@ -1,29 +1,42 @@
# Rack::Emstream
# Super-simple Rack streaming with Thin and other EventMachine-based servers
TODO: Write a gem description
This is the absolute simplest way to turn any Rack app into a streaming- and deferrable-capable service using Thin.
It handles the necessary async calls to make Thin start streaming, then delivers your
response body on each next tick until sent. If you're sending something big, make sure it responds to `each`
in chunks:
## Installation
``` ruby
class FileStreamer
def initialize(file)
@file = file
end
Add this line to your application's Gemfile:
def each
while !@file.eof?
yield @file.read(8192)
end
end
end
gem 'rack-emstream'
# then respond with a FileStreamer
And then execute:
def call(env)
# ... do stuff ...
$ bundle
[ 200, {}, FileStreamer.new(File.open('big-file.mpg')) ]
end
```
Or install it yourself as:
Nothing to configure, just drop it in to your Rack middleware stack and
use Thin as your server:
$ gem install rack-emstream
``` ruby
# for Rails:
## Usage
config.middleware.insert_before(::Rack::Lock, ::Rack::EMStream)
TODO: Write usage instructions here
# for Rack::Builder and derivatives:
## Contributing
use Rack::EMStream
```
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

View File

@ -1,5 +1,5 @@
module Rack
module Emstream
VERSION = "0.0.1"
module EMStream
VERSION = "0.1.0"
end
end

1
lib/rack/emstream.rb Normal file
View File

@ -0,0 +1 @@
require 'rack-emstream'

View File

@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "rack-emstream"
gem.require_paths = ["lib"]
gem.version = Rack::Emstream::VERSION
gem.version = Rack::EMStream::VERSION
gem.add_dependency 'eventmachine'
end