Skip to content

Commit

Permalink
adding some useful utilities, like a rack middleware and
Browse files Browse the repository at this point in the history
  • Loading branch information
collin committed Nov 30, 2009
1 parent 8bb1f41 commit 11f2e03
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Rakefile.rb
Expand Up @@ -59,6 +59,7 @@
gemspec.add_dependency('fold', '0.5.0')
gemspec.add_dependency('johnson', '1.1.2')
gemspec.add_dependency('colored', '1.1')
gemspec.add_dependency('rack', '1.0.1')
end
Jeweler::GemcutterTasks.new
rescue LoadError
Expand Down
4 changes: 4 additions & 0 deletions bin/jabs
@@ -0,0 +1,4 @@
ruby -e "\
require 'rubygems'; require 'jabs'
puts Jabs::Engine.new(STDIN.read).render
"
13 changes: 13 additions & 0 deletions lib/middleware.rb
@@ -0,0 +1,13 @@
require 'rack'

module Jabs
class Middleware < Rack::File
def serving
@path += ".jabs" unless @path[/\.jabs$/]
status, headers, body = *super
return [status, headers, body] unless status == 200
headers['Content-Type'] = 'text/javascript'
[status, headers, Jabs::Engine.new(body).render]
end
end
end

0 comments on commit 11f2e03

Please sign in to comment.