rack-cappuccino 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +27 -0
- data/LICENSE +20 -0
- data/README.markdown +38 -0
- data/Rakefile +6 -0
- data/changelog.markdown +3 -0
- data/lib/rack/cappuccino.rb +29 -0
- data/rack-cappuccino.gemspec +34 -0
- data/spec/rack/cappuccino_spec.rb +55 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/index.html +1 -0
- data/spec/support/script.js +0 -0
- data/spec/support/style.css +0 -0
- metadata +106 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
rack (1.2.1)
|
6
|
+
rake (0.8.7)
|
7
|
+
rcov (0.9.9)
|
8
|
+
rspec (2.1.0)
|
9
|
+
rspec-core (~> 2.1.0)
|
10
|
+
rspec-expectations (~> 2.1.0)
|
11
|
+
rspec-mocks (~> 2.1.0)
|
12
|
+
rspec-core (2.1.0)
|
13
|
+
rspec-expectations (2.1.0)
|
14
|
+
diff-lcs (~> 1.1.2)
|
15
|
+
rspec-mocks (2.1.0)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
rack
|
22
|
+
rake
|
23
|
+
rcov
|
24
|
+
rspec (>= 2.0.0)
|
25
|
+
|
26
|
+
METADATA
|
27
|
+
version: 1.0.6
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Matte Noble
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# rack-cappuccino
|
2
|
+
|
3
|
+
Create a Rack app from your Cappuccino app. Makes it easy to quickly get a Cappuccino app online using Heroku.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add a Gemfile in the root of your app with the following:
|
8
|
+
|
9
|
+
source :rubygems
|
10
|
+
gem "rack-cappuccino"
|
11
|
+
|
12
|
+
Create a config.ru with the following:
|
13
|
+
|
14
|
+
require "bundler/setup"
|
15
|
+
require "rack/cappuccino"
|
16
|
+
|
17
|
+
run Rack::Cappuccino.new(:appname => APPNAME)
|
18
|
+
|
19
|
+
Replace APPNAME with the name of your app as it appears in the Build/Release directory.
|
20
|
+
|
21
|
+
## Build before you deploy
|
22
|
+
|
23
|
+
Make sure you build your Release target before you deploy your app. Rack::Cappuccino uses it as the root directory for the Rack app.
|
24
|
+
|
25
|
+
## Contributing to rack-cappuccino
|
26
|
+
|
27
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
28
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
29
|
+
* Fork the project
|
30
|
+
* Start a feature/bugfix branch
|
31
|
+
* Commit and push until you are happy with your contribution
|
32
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
33
|
+
* Please try not to mess with the Rakefile or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
34
|
+
|
35
|
+
## Copyright
|
36
|
+
|
37
|
+
Copyright (c) 2010 Matte Noble. See LICENSE for further details.
|
38
|
+
|
data/Rakefile
ADDED
data/changelog.markdown
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "rack/request"
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
class Cappuccino
|
6
|
+
VERSION = "0.0.1"
|
7
|
+
|
8
|
+
attr_accessor :root
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
appname = args.last.delete(:appname)
|
12
|
+
@root = "Build/Release/#{appname}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
info = Request.new(env).path_info
|
17
|
+
info = "/index.html" if info == "/"
|
18
|
+
path = Pathname.new(::File.join(@root, info))
|
19
|
+
mime = Mime.mime_type(path.extname)
|
20
|
+
|
21
|
+
if path.exist? && !path.directory? && path.to_s !~ /\.\./
|
22
|
+
[200, { "Content-Type" => mime, "Content-Length" => path.size.to_s }, [path.read]]
|
23
|
+
else
|
24
|
+
[404, {"Content-Type" => "text/plain"}, [""]]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$LOAD_PATH.unshift lib unless $:.include?(lib)
|
4
|
+
require "rack/cappuccino"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rack-cappuccino"
|
8
|
+
s.version = Rack::Cappuccino::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = "Transform a Cappuccino app into a Rack app."
|
11
|
+
s.description = "Rack::Cappucciono serves up your Build/Release/__APPNAME__ folder as a Rack application."
|
12
|
+
|
13
|
+
s.author = 'Matte Noble'
|
14
|
+
s.email = 'me@mattenoble.com'
|
15
|
+
s.homepage = 'http://github.com/mnoble/rack-cappuccino'
|
16
|
+
|
17
|
+
s.require_path = "lib"
|
18
|
+
s.files = [
|
19
|
+
"changelog.markdown",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE",
|
23
|
+
"rack-cappuccino.gemspec",
|
24
|
+
"Rakefile",
|
25
|
+
"README.markdown",
|
26
|
+
"lib/rack/cappuccino.rb"
|
27
|
+
]
|
28
|
+
s.test_files = Dir["spec/**/*"]
|
29
|
+
s.extra_rdoc_files = ["LICENSE", "README.markdown"]
|
30
|
+
|
31
|
+
s.add_dependency "rake"
|
32
|
+
s.add_development_dependency "rack"
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Rack::Cappuccino do
|
4
|
+
include SpecHelper
|
5
|
+
NOT_FOUND = 404
|
6
|
+
OK = 200
|
7
|
+
|
8
|
+
let(:resp) { get("/index.html") }
|
9
|
+
|
10
|
+
it "should construct the root path based on 'appname'" do
|
11
|
+
app = Rack::Cappuccino.new(:appname => "Hasslehoff")
|
12
|
+
app.root.should == "Build/Release/Hasslehoff"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should send a 200" do
|
16
|
+
resp.status.should == OK
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return a 404 for non-existent resources" do
|
20
|
+
resp = get("/doesnt_exist.html")
|
21
|
+
resp.status.should == NOT_FOUND
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not allow .. in the path" do
|
25
|
+
resp = get("/../spec_helper.rb")
|
26
|
+
resp.status.should == NOT_FOUND
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have a content-length of 20" do
|
30
|
+
resp.headers["Content-Length"].to_i.should == 20
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should handle html content-type" do
|
34
|
+
resp.content_type.should == "text/html"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the file contents as the response body" do
|
38
|
+
resp.body.should == "<h1>Hello World</h1>"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return the body on index.html if an empty path is given" do
|
42
|
+
resp = get("/")
|
43
|
+
resp.body.should == "<h1>Hello World</h1>"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should handle css content-type" do
|
47
|
+
resp = get("/style.css")
|
48
|
+
resp.content_type.should == "text/css"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should handle javascript content-type" do
|
52
|
+
resp = get("/script.js")
|
53
|
+
resp.content_type.should == "application/javascript"
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require "rack/mock"
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
require "rack/cappuccino"
|
5
|
+
|
6
|
+
module SpecHelper
|
7
|
+
def initialize
|
8
|
+
@app = Rack::Cappuccino.new(:appname => "Foobar")
|
9
|
+
@app.root = File.join(File.dirname(__FILE__), "support")
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(path)
|
13
|
+
request = Rack::MockRequest.new(@app)
|
14
|
+
request.get(path)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Hello World</h1>
|
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-cappuccino
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matte Noble
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-17 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rack
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
description: Rack::Cappucciono serves up your Build/Release/__APPNAME__ folder as a Rack application.
|
47
|
+
email: me@mattenoble.com
|
48
|
+
executables: []
|
49
|
+
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- LICENSE
|
54
|
+
- README.markdown
|
55
|
+
files:
|
56
|
+
- changelog.markdown
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
59
|
+
- LICENSE
|
60
|
+
- rack-cappuccino.gemspec
|
61
|
+
- Rakefile
|
62
|
+
- README.markdown
|
63
|
+
- lib/rack/cappuccino.rb
|
64
|
+
- spec/rack/cappuccino_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- spec/support/index.html
|
67
|
+
- spec/support/script.js
|
68
|
+
- spec/support/style.css
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/mnoble/rack-cappuccino
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.3.7
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Transform a Cappuccino app into a Rack app.
|
101
|
+
test_files:
|
102
|
+
- spec/rack/cappuccino_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
- spec/support/index.html
|
105
|
+
- spec/support/script.js
|
106
|
+
- spec/support/style.css
|