hyperloop 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/hyperloop.gemspec +26 -0
- data/lib/hyperloop.rb +7 -0
- data/lib/hyperloop/application.rb +45 -0
- data/lib/hyperloop/response.rb +10 -0
- data/lib/hyperloop/version.rb +3 -0
- data/spec/application_spec.rb +51 -0
- data/spec/fixtures/simple/app/views/about.html +10 -0
- data/spec/fixtures/simple/app/views/index.html +10 -0
- data/spec/fixtures/subdirectories/app/views/about.html +10 -0
- data/spec/fixtures/subdirectories/app/views/index.html +10 -0
- data/spec/fixtures/subdirectories/app/views/subdir1/index.html +10 -0
- data/spec/fixtures/subdirectories/app/views/subdir1/kanye.html +10 -0
- data/spec/response_spec.rb +8 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 535e10622d43abc48b580faae7406dd583de7088
|
4
|
+
data.tar.gz: f7a0bf12b3c795f531534dea263a6ab0bea2d752
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06e67575817dae6fb4d83458255ac4abf763ccf6d577c273b5a9b48db4e86bde746274cd64b6c91a1486f29a83bccca4a56ac36255fe961a49a6029cfddee66c
|
7
|
+
data.tar.gz: 1fa91fce8a2fc81f8d8de9a464216ab689723ce7723f030279b24153215f26ccdea1a58e2253d5b687777a6fe15a76ccac4475152001f8e3638a866a12f2f251
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jake Boxer
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Hyperloop
|
2
|
+
|
3
|
+
Make simple websites with a technology stack familiar to Rails programmers.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hyperloop'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hyperloop
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/hyperloop.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hyperloop/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hyperloop"
|
8
|
+
spec.version = Hyperloop::VERSION
|
9
|
+
spec.authors = ["Jake Boxer"]
|
10
|
+
spec.email = ["jake@github.com"]
|
11
|
+
spec.description = %q{Hyperloop lets you make simple websites with a technology stack familiar to Rails programmers.}
|
12
|
+
spec.summary = %q{Make simple websites with Rails conventions and conveniences.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'rack', '~> 1.5'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
26
|
+
end
|
data/lib/hyperloop.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module Hyperloop
|
4
|
+
class Application
|
5
|
+
include Rack::Utils
|
6
|
+
|
7
|
+
def initialize(root=nil)
|
8
|
+
@root = root
|
9
|
+
@views_path = File.join([@root, 'app/views'].compact)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Rack call interface.
|
13
|
+
def call(env)
|
14
|
+
request = Rack::Request.new(env)
|
15
|
+
response = Response.new
|
16
|
+
path = view_path(request)
|
17
|
+
|
18
|
+
if File.exist?(path)
|
19
|
+
# If there's a file at the view path, use its data as the response body.
|
20
|
+
data = File.read(path)
|
21
|
+
response.write(data)
|
22
|
+
else
|
23
|
+
# If there's no file at the view path, 404.
|
24
|
+
response.status = 404
|
25
|
+
end
|
26
|
+
|
27
|
+
response.finish
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Internal: Get the view path for the specified request.
|
33
|
+
#
|
34
|
+
# request - Rack::Request to get the view path for.
|
35
|
+
#
|
36
|
+
# Returns a String.
|
37
|
+
def view_path(request)
|
38
|
+
path = File.join(@views_path, request.path).chomp('/')
|
39
|
+
|
40
|
+
# If we're currently pointing to a directory, get index in it.
|
41
|
+
path = File.join(path, 'index') if Dir.exist?(path)
|
42
|
+
path + '.html'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'hyperloop'
|
2
|
+
|
3
|
+
describe Hyperloop::Application do
|
4
|
+
describe 'with a flat views directory' do
|
5
|
+
before :each do
|
6
|
+
@app = Hyperloop::Application.new('spec/fixtures/simple/')
|
7
|
+
@request = Rack::MockRequest.new(@app)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'responds successfully to a request for root' do
|
11
|
+
response = @request.get('/')
|
12
|
+
|
13
|
+
expect(response).to be_ok
|
14
|
+
expect(response.body).to match(/<h1>Simple/)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'responds successfully to a request for a different page' do
|
18
|
+
response = @request.get('/about')
|
19
|
+
|
20
|
+
expect(response).to be_ok
|
21
|
+
expect(response.body).to match(/<h1>About/)
|
22
|
+
end
|
23
|
+
|
24
|
+
it '404s on a request for a nonexistent page' do
|
25
|
+
response = @request.get('/nonexistent')
|
26
|
+
|
27
|
+
expect(response).to be_not_found
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'with subdirectories' do
|
32
|
+
before :each do
|
33
|
+
@app = Hyperloop::Application.new('spec/fixtures/subdirectories/')
|
34
|
+
@request = Rack::MockRequest.new(@app)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'responds successfully to a request for the subdirectory root' do
|
38
|
+
response = @request.get('/subdir1')
|
39
|
+
|
40
|
+
expect(response).to be_ok
|
41
|
+
expect(response.body).to match(/<h1>Subdirectory Index/)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'responds successfully to a request for a different page in the subdirectory' do
|
45
|
+
response = @request.get('/subdir1/kanye')
|
46
|
+
|
47
|
+
expect(response).to be_ok
|
48
|
+
expect(response.body).to match(/<h1>Hurry up with my damn croissant/)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hyperloop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jake Boxer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.14'
|
69
|
+
description: Hyperloop lets you make simple websites with a technology stack familiar
|
70
|
+
to Rails programmers.
|
71
|
+
email:
|
72
|
+
- jake@github.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .ruby-version
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- hyperloop.gemspec
|
84
|
+
- lib/hyperloop.rb
|
85
|
+
- lib/hyperloop/application.rb
|
86
|
+
- lib/hyperloop/response.rb
|
87
|
+
- lib/hyperloop/version.rb
|
88
|
+
- spec/application_spec.rb
|
89
|
+
- spec/fixtures/simple/app/views/about.html
|
90
|
+
- spec/fixtures/simple/app/views/index.html
|
91
|
+
- spec/fixtures/subdirectories/app/views/about.html
|
92
|
+
- spec/fixtures/subdirectories/app/views/index.html
|
93
|
+
- spec/fixtures/subdirectories/app/views/subdir1/index.html
|
94
|
+
- spec/fixtures/subdirectories/app/views/subdir1/kanye.html
|
95
|
+
- spec/response_spec.rb
|
96
|
+
homepage: ''
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.0.3
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Make simple websites with Rails conventions and conveniences.
|
120
|
+
test_files:
|
121
|
+
- spec/application_spec.rb
|
122
|
+
- spec/fixtures/simple/app/views/about.html
|
123
|
+
- spec/fixtures/simple/app/views/index.html
|
124
|
+
- spec/fixtures/subdirectories/app/views/about.html
|
125
|
+
- spec/fixtures/subdirectories/app/views/index.html
|
126
|
+
- spec/fixtures/subdirectories/app/views/subdir1/index.html
|
127
|
+
- spec/fixtures/subdirectories/app/views/subdir1/kanye.html
|
128
|
+
- spec/response_spec.rb
|