coffeeshop 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,6 +1,6 @@
1
1
  # coffeeshop
2
2
 
3
- `coffeeshop` is a simple Sinatra app that serves up all CoffeeScript files in a directory as JavaScript. For example, if you had `/my/project/src/rad.coffee`, and ran `coffeeshop` in `/my/project` you could hit `http://localhost:4567/src/rad.coffee` and it will be served up as JavaScript.
3
+ `coffeeshop` is a simple Sinatra app that serves up all CoffeeScript files in a directory as JavaScript. For example, if you had `/my/project/src/rad.coffee`, and ran `coffeeshop` in `/my/project` you could hit `http://localhost:4567/src/rad.js` and it will be served up as JavaScript.
4
4
 
5
5
  `coffeeshop` uses Redis for simple 1-hour caching of the generated JavaScript to keep things snappy.
6
6
 
data/bin/coffeeshop CHANGED
@@ -1,16 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require "bundler"
4
3
  require "sinatra"
5
4
  require_relative "../lib/coffeeshop"
6
5
 
7
- get /\/(.+)/ do
8
- content_type "text/javascript"
9
- path = params[:captures].first
6
+ set :static, true
7
+ set :public_folder, ENV["PWD"]
8
+ set :root, ENV["PWD"]
9
+
10
+ not_found do
11
+ path = settings.root + env["PATH_INFO"]
12
+ coffee_path = path.sub( /\.js$/, ".coffee" )
10
13
 
11
- if File.exists?( path )
12
- Coffeeshop.to_js path
14
+ if path =~ /\.js$/ && File.exists?( coffee_path )
15
+ content_type "text/javascript"
16
+ Coffeeshop.to_js( coffee_path )
13
17
  else
14
- raise Sinatra::NotFound
18
+ if path =~ /\/$/
19
+ index_path = "#{path}index.html"
20
+ else
21
+ index_path = "#{path}/index.html"
22
+ end
23
+ if File.exists?( index_path )
24
+ File.read( index_path )
25
+ end
15
26
  end
16
27
  end
data/foo.coffee ADDED
@@ -0,0 +1 @@
1
+ rad.cool()
data/index.html ADDED
@@ -0,0 +1 @@
1
+ index
@@ -1,3 +1,3 @@
1
- class Coffeeshop
2
- VERSION = "0.0.2"
1
+ module Coffeeshop
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/coffeeshop.rb CHANGED
@@ -3,7 +3,7 @@ require "digest/md5"
3
3
  require "redis"
4
4
  require_relative "coffeeshop/version"
5
5
 
6
- class Coffeeshop
6
+ module Coffeeshop
7
7
  REDIS = Redis.new
8
8
  EXPIRE = 60 * 60
9
9
 
data/test/index.html ADDED
@@ -0,0 +1 @@
1
+ fsdhfs
data/test.html ADDED
@@ -0,0 +1 @@
1
+ test
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffeeshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &70137123041340 !ruby/object:Gem::Requirement
16
+ requirement: &70222942618800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70137123041340
24
+ version_requirements: *70222942618800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: coffee-script
27
- requirement: &70137123040300 !ruby/object:Gem::Requirement
27
+ requirement: &70222942617600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70137123040300
35
+ version_requirements: *70222942617600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: redis
38
- requirement: &70137123039500 !ruby/object:Gem::Requirement
38
+ requirement: &70222942616580 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70137123039500
46
+ version_requirements: *70222942616580
47
47
  description: coffeeshop is a quick and dirty Sinatra app that serves up any CoffeeScript
48
48
  in a directory as JavaScript. It uses Redis for basic caching because that's how
49
49
  I roll.
@@ -60,8 +60,12 @@ files:
60
60
  - Rakefile
61
61
  - bin/coffeeshop
62
62
  - coffeeshop.gemspec
63
+ - foo.coffee
64
+ - index.html
63
65
  - lib/coffeeshop.rb
64
66
  - lib/coffeeshop/version.rb
67
+ - test.html
68
+ - test/index.html
65
69
  homepage: http://github.com/tysontate/coffeeshop
66
70
  licenses: []
67
71
  post_install_message:
@@ -86,4 +90,5 @@ rubygems_version: 1.8.11
86
90
  signing_key:
87
91
  specification_version: 3
88
92
  summary: Simple Sinatra app to serve up CoffeeScript as JavaScript quickly.
89
- test_files: []
93
+ test_files:
94
+ - test/index.html