hyperloop 0.0.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +41 -16
- data/LICENSE +21 -0
- data/hyperloop.gemspec +29 -30
- data/lib/generators/hyper/component_generator.rb +20 -0
- data/lib/generators/hyper/router_generator.rb +19 -0
- data/lib/generators/hyper/templates/component_template.rb +41 -0
- data/lib/generators/hyper/templates/router_template.rb +44 -0
- data/lib/generators/hyperloop/install_generator.rb +46 -0
- data/lib/hyperloop.rb +16 -8
- data/lib/hyperloop/version.rb +1 -1
- metadata +63 -222
- data/.ruby-version +0 -1
- data/.travis.yml +0 -4
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -107
- data/Rakefile +0 -6
- data/bin/hyperloop +0 -7
- data/lib/hyperloop/application.rb +0 -103
- data/lib/hyperloop/cli.rb +0 -11
- data/lib/hyperloop/generators/site.rb +0 -47
- data/lib/hyperloop/generators/site/Gemfile +0 -3
- data/lib/hyperloop/generators/site/_partial.html.erb +0 -1
- data/lib/hyperloop/generators/site/about.html.erb +0 -3
- data/lib/hyperloop/generators/site/app.css +0 -2
- data/lib/hyperloop/generators/site/app.js +0 -2
- data/lib/hyperloop/generators/site/application.html.erb +0 -23
- data/lib/hyperloop/generators/site/bootstrap.css +0 -6805
- data/lib/hyperloop/generators/site/config.ru +0 -4
- data/lib/hyperloop/generators/site/current-time.coffee +0 -3
- data/lib/hyperloop/generators/site/index.html.erb +0 -11
- data/lib/hyperloop/generators/site/jquery.js +0 -8829
- data/lib/hyperloop/generators/site/main.scss +0 -7
- data/lib/hyperloop/generators/site/socool.jpg +0 -0
- data/lib/hyperloop/response.rb +0 -10
- data/lib/hyperloop/view.rb +0 -73
- data/lib/hyperloop/view/registry.rb +0 -90
- data/lib/hyperloop/view/scope.rb +0 -23
- data/spec/application_spec.rb +0 -300
- data/spec/fixtures/assets/app/assets/images/my-gif.gif +0 -0
- data/spec/fixtures/assets/app/assets/images/my-jpg.jpg +0 -0
- data/spec/fixtures/assets/app/assets/images/my-png.png +0 -0
- data/spec/fixtures/assets/app/assets/javascripts/app.js +0 -1
- data/spec/fixtures/assets/app/assets/javascripts/my-scripts.coffee +0 -1
- data/spec/fixtures/assets/app/assets/shouldfail/shouldfail.css +0 -3
- data/spec/fixtures/assets/app/assets/stylesheets/app.css +0 -1
- data/spec/fixtures/assets/app/assets/stylesheets/my-styles.scss +0 -3
- data/spec/fixtures/assets/app/views/index.html.erb +0 -7
- data/spec/fixtures/assets/app/views/layouts/application.html.erb +0 -15
- data/spec/fixtures/assets/vendor/assets/javascripts/vendored.js +0 -1
- data/spec/fixtures/assets/vendor/assets/stylesheets/vendored.css +0 -3
- data/spec/fixtures/erb/app/views/about.html.erb +0 -10
- data/spec/fixtures/erb/app/views/index.html.erb +0 -10
- data/spec/fixtures/layouts/app/views/index.html.erb +0 -3
- data/spec/fixtures/layouts/app/views/layouts/application.html.erb +0 -12
- data/spec/fixtures/layouts/app/views/subdir/index.html.erb +0 -3
- data/spec/fixtures/partials/app/views/index.html.erb +0 -3
- data/spec/fixtures/partials/app/views/layouts/application.html.erb +0 -12
- data/spec/fixtures/partials/app/views/subdir/_partial.html.erb +0 -1
- data/spec/fixtures/partials/app/views/subdir/index.html.erb +0 -3
- data/spec/fixtures/partials/app/views/subdir/nonroot.html.erb +0 -3
- data/spec/fixtures/simple/app/views/about.html +0 -10
- data/spec/fixtures/simple/app/views/index.html +0 -10
- data/spec/fixtures/subdirectories/app/views/about.html +0 -10
- data/spec/fixtures/subdirectories/app/views/index.html +0 -10
- data/spec/fixtures/subdirectories/app/views/subdir1/index.html +0 -10
- data/spec/fixtures/subdirectories/app/views/subdir1/kanye.html +0 -10
- data/spec/response_spec.rb +0 -8
- data/spec/spec_helper.rb +0 -139
- data/spec/view/registry_spec.rb +0 -56
- data/spec/view/scope_spec.rb +0 -21
- data/spec/view_spec.rb +0 -93
Binary file
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree
|
@@ -1 +0,0 @@
|
|
1
|
-
alert "such javascript wow"
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>App With Assets</title>
|
5
|
-
|
6
|
-
<link href="/assets/app.css" media="all" rel="stylesheet" type="text/css">
|
7
|
-
<script src="/assets/app.js" type="text/javascript"></script>
|
8
|
-
</head>
|
9
|
-
|
10
|
-
<body>
|
11
|
-
<h1>This app has so many assets</h1>
|
12
|
-
|
13
|
-
<%= yield %>
|
14
|
-
</body>
|
15
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
alert("i am vendored");
|
@@ -1 +0,0 @@
|
|
1
|
-
<p class="spec-in-partial">This is coming from a partial.</p>
|
data/spec/response_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require "nokogiri"
|
2
|
-
require "pry"
|
3
|
-
|
4
|
-
require "hyperloop"
|
5
|
-
|
6
|
-
module Helpers
|
7
|
-
# Public: Clean up all prepared fixtures.
|
8
|
-
#
|
9
|
-
# Returns nothing.
|
10
|
-
def cleanup_fixtures
|
11
|
-
tmp_fixtures_dir = File.join("tmp", "spec", "fixtures")
|
12
|
-
FileUtils.rm_rf(tmp_fixtures_dir)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Public: Change the contents of a file in a fixture.
|
16
|
-
#
|
17
|
-
# fixture_path - Path to the fixture containing the file we want to change.
|
18
|
-
# file_path - Path (relative to fixture_path) of the file we want to
|
19
|
-
# change.
|
20
|
-
# options - Hash containing the following keys:
|
21
|
-
# :pattern - (Required) Regexp or String to find in the
|
22
|
-
# file. Only the first occurrence will be
|
23
|
-
# matched.
|
24
|
-
# :replacement - (Required) String to replace the found pattern
|
25
|
-
# with.
|
26
|
-
#
|
27
|
-
# Examples:
|
28
|
-
#
|
29
|
-
# change_fixture("tmp/spec/fixtures/erb", "app/views/index.html.erb",
|
30
|
-
# :pattern => "<title>ERB</title>",
|
31
|
-
# :replacement => "<title>Changed</title>"
|
32
|
-
# )
|
33
|
-
#
|
34
|
-
# change_fixture("tmp/spec/fixtures/erb", "app/views/index.html.erb",
|
35
|
-
# :pattern => /<title>[^<]*<\/title>/,
|
36
|
-
# :replacement => "<title>Changed</title>"
|
37
|
-
# )
|
38
|
-
#
|
39
|
-
# Returns nothing.
|
40
|
-
def change_fixture(fixture_path, file_path, options = {})
|
41
|
-
pattern = options[:pattern]
|
42
|
-
replacement = options[:replacement]
|
43
|
-
|
44
|
-
raise ArgumentError, "change_fixture must include a :pattern option" unless pattern
|
45
|
-
raise ArgumentError, "change_fixture must include a :replacement option" unless replacement
|
46
|
-
|
47
|
-
File.open(File.join(fixture_path, file_path), "r+") do |f|
|
48
|
-
data = f.read.sub(pattern, replacement)
|
49
|
-
f.rewind
|
50
|
-
f.write(data)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def html(str)
|
55
|
-
Nokogiri::HTML(str)
|
56
|
-
end
|
57
|
-
|
58
|
-
def mock_view_registry
|
59
|
-
@mock_view_registry ||= double("Hyperloop::View::Registry",
|
60
|
-
:find_partial_view => nil,
|
61
|
-
:find_template_view => nil
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
# Public: Prepare a fixture with the specified name.
|
66
|
-
#
|
67
|
-
# name - Symbol name of the fixture to prepare. The name passed here will be
|
68
|
-
# looked up in the spec/fixtures directory.
|
69
|
-
#
|
70
|
-
# Note:
|
71
|
-
#
|
72
|
-
# This method exists along with change_fixture and cleanup_fixtures. If
|
73
|
-
# these get used a lot more or more fixture-related functionality is added,
|
74
|
-
# it may make sense to extract a Fixture class and move these methods into
|
75
|
-
# it.
|
76
|
-
#
|
77
|
-
# Returns a string filepath representing the new location of the prepared
|
78
|
-
# fixture.
|
79
|
-
def prepare_fixture(name)
|
80
|
-
root = File.join("spec", "fixtures", name.to_s)
|
81
|
-
contents = File.join(root, ".")
|
82
|
-
tmp_root = File.join("tmp", root)
|
83
|
-
|
84
|
-
# Delete and recreate the tmp/spec/fixtures/:name directory, then copy the
|
85
|
-
# fixture into it.
|
86
|
-
FileUtils.rm_rf(tmp_root)
|
87
|
-
FileUtils.mkdir_p(tmp_root)
|
88
|
-
FileUtils.cp_r(contents, tmp_root)
|
89
|
-
|
90
|
-
tmp_root
|
91
|
-
end
|
92
|
-
|
93
|
-
# Public: Set the RACK_ENV environment variable back to whatever it was when
|
94
|
-
# the spec started running. If RACK_ENV wasn't set before the spec started
|
95
|
-
# running, it will be deleted.
|
96
|
-
#
|
97
|
-
# Returns nothing.
|
98
|
-
def reset_rack_env
|
99
|
-
if defined?(@old_rack_env)
|
100
|
-
ENV["RACK_ENV"] = @old_rack_env
|
101
|
-
else
|
102
|
-
ENV.delete("RACK_ENV")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Public: Set the RACK_ENV environment variable to the specified value.
|
107
|
-
#
|
108
|
-
# name - Symbol environment name to set RACK_ENV to. Should be :development,
|
109
|
-
# :test, or :production.
|
110
|
-
#
|
111
|
-
# Returns nothing.
|
112
|
-
def set_rack_env(name)
|
113
|
-
@old_rack_env = ENV["RACK_ENV"] if ENV.key?("RACK_ENV")
|
114
|
-
ENV["RACK_ENV"] = name.to_s
|
115
|
-
end
|
116
|
-
|
117
|
-
def text_in(html_str, selector)
|
118
|
-
node = html(html_str).at_css(selector)
|
119
|
-
node && node.text
|
120
|
-
end
|
121
|
-
|
122
|
-
def mock_app
|
123
|
-
@mock_app ||= double("rack app", :call => Hyperloop::Response.new.finish )
|
124
|
-
end
|
125
|
-
|
126
|
-
def mock_request(app = nil)
|
127
|
-
Rack::MockRequest.new(app || mock_app)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
ENV["RACK_ENV"] ||= "test"
|
132
|
-
|
133
|
-
RSpec.configure do |c|
|
134
|
-
c.include(Helpers)
|
135
|
-
|
136
|
-
c.after :all do
|
137
|
-
cleanup_fixtures
|
138
|
-
end
|
139
|
-
end
|
data/spec/view/registry_spec.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
describe Hyperloop::View::Registry do
|
2
|
-
before :each do
|
3
|
-
@registry = Hyperloop::View::Registry.new("spec/fixtures/partials/")
|
4
|
-
end
|
5
|
-
|
6
|
-
describe "#find_template_view" do
|
7
|
-
it "finds the root view" do
|
8
|
-
expect(@registry.find_template_view("/").name).to eql("index")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "finds a root view in a subdirectory" do
|
12
|
-
expect(@registry.find_template_view("/subdir").name).to eql("index")
|
13
|
-
end
|
14
|
-
|
15
|
-
it "finds a non-root view in a subdirectory" do
|
16
|
-
expect(@registry.find_template_view("/subdir/nonroot").name).to eql("nonroot")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "doesn't find partials" do
|
20
|
-
expect(@registry.find_template_view("/subdir/partial")).to be_nil
|
21
|
-
expect(@registry.find_template_view("/subdir/_partial")).to be_nil
|
22
|
-
expect(@registry.find_template_view("subdir/partial")).to be_nil
|
23
|
-
expect(@registry.find_template_view("subdir/_partial")).to be_nil
|
24
|
-
end
|
25
|
-
|
26
|
-
it "doesn't find layouts" do
|
27
|
-
expect(@registry.find_template_view("/layouts/application")).to be_nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#find_partial_view" do
|
32
|
-
it "finds partials" do
|
33
|
-
expect(@registry.find_partial_view("subdir/partial").name).to eql("partial")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "doesn't find partials if the filename in the path is prefixed with an underscore" do
|
37
|
-
expect(@registry.find_partial_view("subdir/_partial")).to be_nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "doesn't find partials if the path is prefixed with a forward slash" do
|
41
|
-
expect(@registry.find_partial_view("/subdir/partial")).to be_nil
|
42
|
-
end
|
43
|
-
|
44
|
-
it "doesn't find template views" do
|
45
|
-
expect(@registry.find_partial_view("/")).to be_nil
|
46
|
-
expect(@registry.find_partial_view("/subdir")).to be_nil
|
47
|
-
expect(@registry.find_partial_view("/subdir/nonroot")).to be_nil
|
48
|
-
expect(@registry.find_partial_view("subdir/nonroot")).to be_nil
|
49
|
-
end
|
50
|
-
|
51
|
-
it "doesn't find layouts" do
|
52
|
-
expect(@registry.find_partial_view("/subdir/layouts/application")).to be_nil
|
53
|
-
expect(@registry.find_partial_view("subdir/layouts/application")).to be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/spec/view/scope_spec.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
describe Hyperloop::View::Scope do
|
2
|
-
before :each do
|
3
|
-
view_registry = Hyperloop::View::Registry.new("spec/fixtures/partials/")
|
4
|
-
@request = mock_request
|
5
|
-
@scope = Hyperloop::View::Scope.new(@request, view_registry)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#request" do
|
9
|
-
it "is the request that the scope will be used in response to" do
|
10
|
-
expect(@scope.request).to eql(@request)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#render" do
|
15
|
-
it "renders the specified partial" do
|
16
|
-
html = @scope.render("subdir/partial")
|
17
|
-
|
18
|
-
expect(text_in(html, "p")).to eql("This is coming from a partial.")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/spec/view_spec.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require File.expand_path("../spec_helper", __FILE__)
|
2
|
-
|
3
|
-
describe Hyperloop::View do
|
4
|
-
before :each do
|
5
|
-
@html_view = Hyperloop::View.new(mock_view_registry,
|
6
|
-
"spec/fixtures/simple/app/views/about.html"
|
7
|
-
)
|
8
|
-
|
9
|
-
@erb_view = Hyperloop::View.new(mock_view_registry,
|
10
|
-
"spec/fixtures/erb/app/views/about.html.erb"
|
11
|
-
)
|
12
|
-
|
13
|
-
@layout_view = Hyperloop::View.new(mock_view_registry,
|
14
|
-
"spec/fixtures/layouts/app/views/index.html.erb",
|
15
|
-
"spec/fixtures/layouts/app/views/layouts/application.html.erb"
|
16
|
-
)
|
17
|
-
|
18
|
-
partials_view_registry = Hyperloop::View::Registry.new("spec/fixtures/partials/")
|
19
|
-
@partial_container = partials_view_registry.find_template_view("/")
|
20
|
-
@partial_view = partials_view_registry.find_partial_view("subdir/partial")
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#format" do
|
24
|
-
it "is :html for HTML files" do
|
25
|
-
expect(@html_view.format).to eql(:html)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "is :erb for ERB files" do
|
29
|
-
expect(@erb_view.format).to eql(:erb)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#name" do
|
34
|
-
it "strips the extension from plain HTML files" do
|
35
|
-
expect(@html_view.name).to eql("about")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "strips the extension from ERB files" do
|
39
|
-
expect(@erb_view.name).to eql("about")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "strips the leading underscore for partials" do
|
43
|
-
expect(@partial_view.name).to eql("partial")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#partial?" do
|
48
|
-
it "is false for a template view" do
|
49
|
-
expect(@partial_container).not_to be_partial
|
50
|
-
end
|
51
|
-
|
52
|
-
it "is true for a partial view" do
|
53
|
-
expect(@partial_view).to be_partial
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#render" do
|
58
|
-
it "renders plain HTML files" do
|
59
|
-
html = @html_view.render(mock_request)
|
60
|
-
|
61
|
-
expect(text_in(html, "h1")).to eql("About")
|
62
|
-
end
|
63
|
-
|
64
|
-
it "renders ERB files" do
|
65
|
-
html = @erb_view.render(mock_request)
|
66
|
-
|
67
|
-
expect(text_in(html, "h1")).to eql("I was born on December 21")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "renders ERB files in layouts" do
|
71
|
-
html = @layout_view.render(mock_request)
|
72
|
-
|
73
|
-
expect(text_in(html, "h1")).to eql("Layout Header")
|
74
|
-
expect(text_in(html, "h2")).to eql("This is the root page!")
|
75
|
-
end
|
76
|
-
|
77
|
-
it "renders ERB files containing partials" do
|
78
|
-
html = @partial_container.render(mock_request)
|
79
|
-
|
80
|
-
expect(text_in(html, "h1")).to eql("Partials work in this app")
|
81
|
-
expect(text_in(html, "h2")).to eql("This part of the root page is not in a partial!")
|
82
|
-
expect(text_in(html, "p")).to eql("This is coming from a partial.")
|
83
|
-
end
|
84
|
-
|
85
|
-
it "renders ERB partials" do
|
86
|
-
html = @partial_view.render(mock_request)
|
87
|
-
|
88
|
-
expect(text_in(html, "h1")).not_to eql("Partials work in this app")
|
89
|
-
expect(text_in(html, "h2")).not_to eql("This part of the root page is not in a partial!")
|
90
|
-
expect(text_in(html, "p")).to eql("This is coming from a partial.")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|