Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

compatibility with coffeescript 0.5.x

  • Loading branch information...
commit 0cf98ad1d817809fa61c9ecbca063ef6d8391a91 2 parents ce62f09 + a2c0735
Matthew Lyon authored
7  Rakefile
@@ -20,12 +20,12 @@ else
20 20
   task "rack-coffee.gemspec" do
21 21
     spec = Gem::Specification.new do |s|
22 22
       s.name            = "rack-coffee"
23  
-      s.version         = "0.2.0"
  23
+      s.version         = "0.3.0"
24 24
       s.platform        = Gem::Platform::RUBY
25 25
       s.summary         = "serve up coffeescript from rack middleware"
26 26
       
27 27
       s.description     = <<-EOF
28  
-Rack Middlware for compiling and serving .coffee files using coffee-script; "/javascripts/app.js" compiles and serves "/javascipts/app.coffee". If there is no .coffee file, passes to Rack::File in case there's a .js file (or other asset) with the requested url.
  28
+Rack Middlware for compiling and serving .coffee files using coffee-script; "/javascripts/app.js" compiles and serves "/javascipts/app.coffee". If there is no .coffee file, can either pass to Rack::File in case there's a .js file (or other asset) with the requested url, or pass entirely.
29 29
       EOF
30 30
 
31 31
       s.files           = `git ls-files`.split("\n")
@@ -33,13 +33,12 @@ Rack Middlware for compiling and serving .coffee files using coffee-script; "/ja
33 33
       s.has_rdoc        = false
34 34
       s.test_files      = Dir['test/*_test.rb']
35 35
       
36  
-      s.author          = 'Matthew Lyon'
  36
+      s.authors         = ['Matthew Lyon', 'Brian Mitchell']
37 37
       s.email           = 'matt@flowerpowered.com'
38 38
       s.homepage        = 'http://github.com/mattly/rack-coffee'
39 39
       s.rubyforge_project = 'rack-coffee'
40 40
       
41 41
       s.add_dependency 'rack'
42  
-      s.add_dependency 'coffee-script'
43 42
     end
44 43
 
45 44
     File.open("rack-coffee.gemspec", "w") { |f| f << spec.to_ruby }
12  Readme.mkdn
Source Rendered
... ...
@@ -1,6 +1,6 @@
1 1
 # rack-coffee
2 2
 
3  
-Simple rack middleware for serving up [CoffeeScript][coffeescript] files as compiled javascript.
  3
+Simple rack middleware for serving up [CoffeeScript][coffee] files as compiled javascript.
4 4
 
5 5
 ## Usage
6 6
 
@@ -26,11 +26,14 @@ Note however that by default this will not play nicely with `javascript_include_
26 26
 
27 27
 ## Requirements
28 28
 
29  
-* coffee-script
30  
-* rack
  29
+* [CoffeeScript][coffee] and [node.js][node] which coffee-script now depends on.
  30
+* [Rack][rack]
31 31
 
32 32
 ## History
33 33
 
  34
+* March 6, 2010: release 0.3 REQUIRES COFFEE-SCRIPT 0.5 OR HIGHER
  35
+    * CoffeeScript is now written in coffeescript. The included compiler is now based on node.js instead of being hosted in a ruby gem, so we're shelling out to the command-line interpreter. Thanks to [Brian Mitchell][binary42] for doing most of the dirty work, at least as far as ruby 1.9 is concerned.
  36
+
34 37
 * January 27, 2010: release 0.2 BACKWARDS INCOMPATIBLE
35 38
     * replace :url parameter in favor of :urls, now it behaves similarly to Rack::Static (Brian Mitchell)
36 39
     * add :static parameter, which when false will disable automatic asset serving of url misses via Rack::File, instead passing through to the app.
@@ -63,3 +66,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63 66
 [coffeescript]: http://jashkenas.github.com/coffee-script/
64 67
 [bistrocar]: http://github.com/jnicklas/bistro_car
65 68
 [issues]: http://github.com/mattly/rack-coffee/issues
  69
+[node]: http://nodejs.org/
  70
+[rack]: http://rack.rubyforge.org/
  71
+[binary42]: http://github.com/binary42
7  lib/rack/coffee.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'time'
2  
-require 'coffee-script'
3 2
 require 'rack/file'
4 3
 require 'rack/utils'
5 4
 
@@ -18,6 +17,10 @@ def initialize(app, opts={})
18 17
       @server = opts[:static] ? Rack::File.new(root) : app
19 18
     end
20 19
     
  20
+    def brew(coffee)
  21
+      IO.popen(['coffee', '-p', coffee].join(' '))
  22
+    end
  23
+    
21 24
     def call(env)
22 25
       path = Utils.unescape(env["PATH_INFO"])
23 26
       return [403, {"Content-Type" => "text/plain"}, ["Forbidden\n"]] if path.include?('..')
@@ -25,7 +28,7 @@ def call(env)
25 28
       coffee = F.join(root, path.sub(/\.js$/,'.coffee'))
26 29
       if F.file?(coffee)
27 30
         headers = {"Content-Type" => "application/javascript", "Last-Modified" => F.mtime(coffee).httpdate}
28  
-        [200, headers, [CoffeeScript.compile(F.read(coffee))]]
  31
+        [200, headers, brew(coffee)]
29 32
       else
30 33
         @server.call(env)
31 34
       end
13  rack-coffee.gemspec
@@ -2,15 +2,15 @@
2 2
 
3 3
 Gem::Specification.new do |s|
4 4
   s.name = %q{rack-coffee}
5  
-  s.version = "0.2.0"
  5
+  s.version = "0.3.0"
6 6
 
7 7
   s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8  
-  s.authors = ["Matthew Lyon"]
9  
-  s.date = %q{2010-01-28}
10  
-  s.description = %q{Rack Middlware for compiling and serving .coffee files using coffee-script; "/javascripts/app.js" compiles and serves "/javascipts/app.coffee". If there is no .coffee file, passes to Rack::File in case there's a .js file (or other asset) with the requested url.
  8
+  s.authors = ["Matthew Lyon", "Brian Mitchell"]
  9
+  s.date = %q{2010-03-06}
  10
+  s.description = %q{Rack Middlware for compiling and serving .coffee files using coffee-script; "/javascripts/app.js" compiles and serves "/javascipts/app.coffee". If there is no .coffee file, can either pass to Rack::File in case there's a .js file (or other asset) with the requested url, or pass entirely.
11 11
 }
12 12
   s.email = %q{matt@flowerpowered.com}
13  
-  s.files = ["Rakefile", "Readme.mkdn", "lib/rack/coffee.rb", "rack-coffee.gemspec", "test/javascripts/static.js", "test/javascripts/test.coffee", "test/other_javascripts/test.coffee", "test/rack_coffee_test.rb"]
  13
+  s.files = [".gitignore", "Rakefile", "Readme.mkdn", "lib/rack/coffee.rb", "rack-coffee.gemspec", "test/javascripts/static.js", "test/javascripts/test.coffee", "test/other_javascripts/test.coffee", "test/rack_coffee_test.rb"]
14 14
   s.homepage = %q{http://github.com/mattly/rack-coffee}
15 15
   s.require_paths = ["lib"]
16 16
   s.rubyforge_project = %q{rack-coffee}
@@ -24,13 +24,10 @@ Gem::Specification.new do |s|
24 24
 
25 25
     if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26 26
       s.add_runtime_dependency(%q<rack>, [">= 0"])
27  
-      s.add_runtime_dependency(%q<coffee-script>, [">= 0"])
28 27
     else
29 28
       s.add_dependency(%q<rack>, [">= 0"])
30  
-      s.add_dependency(%q<coffee-script>, [">= 0"])
31 29
     end
32 30
   else
33 31
     s.add_dependency(%q<rack>, [">= 0"])
34  
-    s.add_dependency(%q<coffee-script>, [">= 0"])
35 32
   end
36 33
 end
10  test/rack_coffee_test.rb
... ...
@@ -1,7 +1,11 @@
1 1
 require 'test/unit'
2  
-require 'rack/mock'
3  
-require 'rack/lint'
4  
-require 'ruby-debug'
  2
+begin
  3
+  require 'rack/mock'
  4
+  require 'rack/lint'
  5
+rescue LoadError
  6
+  require 'rubygems'
  7
+  retry
  8
+end
5 9
 
6 10
 require File.dirname(__FILE__) + "/../lib/rack/coffee"
7 11
 

0 notes on commit 0cf98ad

Please sign in to comment.
Something went wrong with that request. Please try again.