utopia 1.9.11 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +3 -2
- data/.gitignore +4 -1
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/.yardopts +2 -0
- data/Gemfile +8 -1
- data/README.md +2 -2
- data/Rakefile +10 -10
- data/benchmarks/call_vs_check.rb +36 -0
- data/benchmarks/const_vs_hash.rb +33 -0
- data/documentation/Gemfile +5 -0
- data/documentation/Guardfile +20 -0
- data/documentation/config.ru +6 -13
- data/documentation/config/puma.rb +20 -0
- data/documentation/pages/_editor.xnode +64 -0
- data/documentation/pages/_heading.xnode +2 -2
- data/documentation/pages/_page.xnode +1 -2
- data/documentation/pages/errors/exception.xnode +3 -3
- data/documentation/pages/errors/file-not-found.xnode +3 -3
- data/documentation/pages/wiki/bower-integration/content.md +1 -1
- data/documentation/pages/wiki/content.md +6 -8
- data/documentation/pages/wiki/controller.rb +3 -3
- data/documentation/pages/wiki/edit.xnode +7 -19
- data/documentation/pages/wiki/middleware/content/content.md +4 -10
- data/documentation/pages/wiki/{controller → middleware/controller}/actions/content.md +0 -0
- data/documentation/pages/wiki/{controller → middleware/controller}/links.yaml +0 -0
- data/documentation/pages/wiki/{controller → middleware/controller}/rewrite/content.md +3 -3
- data/documentation/pages/wiki/show.xnode +4 -6
- data/documentation/pages/wiki/updating-utopia/content.md +55 -0
- data/documentation/pages/wiki/your-first-page/content.md +5 -3
- data/documentation/public/materials +1 -0
- data/lib/utopia.rb +3 -4
- data/lib/utopia/command.rb +4 -284
- data/lib/utopia/command/server.rb +115 -0
- data/lib/utopia/command/setup.rb +78 -0
- data/lib/utopia/command/site.rb +183 -0
- data/lib/utopia/content.rb +83 -59
- data/lib/utopia/content/{transaction.rb → document.rb} +116 -110
- data/lib/utopia/content/link.rb +7 -2
- data/lib/utopia/content/links.rb +2 -1
- data/lib/utopia/content/markup.rb +7 -2
- data/lib/utopia/{tags/deferred.rb → content/namespace.rb} +25 -6
- data/lib/utopia/content/node.rb +74 -76
- data/lib/utopia/content/response.rb +22 -3
- data/lib/utopia/content/tags.rb +66 -0
- data/lib/utopia/controller.rb +10 -18
- data/lib/utopia/controller/actions.rb +10 -0
- data/lib/utopia/controller/base.rb +2 -1
- data/lib/utopia/controller/respond.rb +1 -1
- data/lib/utopia/controller/rewrite.rb +8 -4
- data/lib/utopia/exceptions.rb +1 -0
- data/lib/utopia/exceptions/handler.rb +7 -2
- data/lib/utopia/exceptions/mailer.rb +33 -12
- data/lib/utopia/{tags/node.rb → extensions/array_split.rb} +11 -9
- data/lib/utopia/{tags/environment.rb → extensions/date_comparisons.rb} +24 -14
- data/lib/utopia/http.rb +2 -0
- data/lib/utopia/locale.rb +1 -0
- data/lib/utopia/localization.rb +37 -28
- data/lib/utopia/logger.rb +1 -0
- data/lib/utopia/logger/compact_formatter.rb +1 -0
- data/lib/utopia/middleware.rb +11 -1
- data/lib/utopia/path.rb +1 -0
- data/lib/utopia/path/matcher.rb +14 -2
- data/lib/utopia/redirection.rb +13 -16
- data/lib/utopia/session.rb +14 -6
- data/lib/utopia/setup.rb +3 -1
- data/lib/utopia/static.rb +11 -12
- data/lib/utopia/version.rb +1 -1
- data/setup/server/git/hooks/post-receive +0 -4
- data/setup/site/.gitignore +9 -0
- data/setup/site/.rspec +1 -0
- data/setup/site/Gemfile +4 -0
- data/setup/site/Guardfile +17 -0
- data/setup/site/Rakefile +2 -2
- data/setup/site/config.ru +5 -12
- data/setup/site/pages/_heading.xnode +2 -2
- data/setup/site/pages/_page.xnode +1 -1
- data/setup/site/pages/errors/exception.xnode +3 -3
- data/setup/site/pages/errors/file-not-found.xnode +3 -3
- data/setup/site/pages/welcome/index.xnode +3 -3
- data/setup/site/public/_static/site.css +4 -0
- data/setup/site/spec/spec_helper.rb +29 -0
- data/setup/site/tasks/deploy.rake +13 -0
- data/setup/site/tasks/development.rake +34 -0
- data/setup/site/tasks/environment.rake +17 -0
- data/spec/mock_node.rb +15 -0
- data/spec/spec_helper.rb +29 -0
- data/{lib/utopia/extensions/date.rb → spec/utopia/content/document_spec.rb} +31 -21
- data/spec/utopia/content/markup_spec.rb +2 -2
- data/spec/utopia/content/{tag_spec.rb → namespace_spec.rb} +17 -10
- data/spec/utopia/content/tags_spec.rb +80 -0
- data/spec/utopia/content_spec.rb +1 -1
- data/spec/utopia/content_spec.ru +1 -6
- data/spec/utopia/content_spec/_heading.xnode +1 -1
- data/spec/utopia/content_spec/content/test-partial.xnode +1 -1
- data/spec/utopia/content_spec/index.xnode +1 -1
- data/spec/utopia/controller/middleware_spec.ru +1 -3
- data/spec/utopia/controller/respond_spec.rb +2 -22
- data/spec/utopia/controller/respond_spec.ru +1 -5
- data/spec/utopia/controller/respond_spec/errors/file-not-found.xnode +7 -6
- data/spec/utopia/exceptions/handler_spec.ru +1 -2
- data/spec/utopia/exceptions/mailer_spec.ru +1 -2
- data/spec/utopia/extensions_spec.rb +2 -2
- data/spec/utopia/localization_spec.ru +1 -2
- data/spec/utopia/performance_spec.rb +2 -6
- data/spec/utopia/performance_spec/config.ru +5 -12
- data/spec/utopia/performance_spec/pages/_heading.xnode +2 -2
- data/spec/utopia/performance_spec/pages/_page.xnode +1 -1
- data/spec/utopia/performance_spec/pages/errors/exception.xnode +3 -3
- data/spec/utopia/performance_spec/pages/errors/file-not-found.xnode +3 -3
- data/spec/utopia/performance_spec/pages/welcome/index.xnode +3 -3
- data/spec/utopia/setup_spec.rb +79 -15
- data/utopia.gemspec +3 -3
- metadata +41 -27
- data/.simplecov +0 -9
- data/documentation/pages/welcome/index.xnode +0 -41
- data/lib/utopia/content/tag.rb +0 -90
- data/lib/utopia/extensions/array.rb +0 -29
- data/lib/utopia/tags/override.rb +0 -33
- data/setup/site/.simplecov +0 -9
- data/setup/site/tasks/test.rake +0 -10
- data/setup/site/tasks/utopia.rake +0 -41
- data/spec/utopia/controller/respond_spec/rewrite/controller.rb +0 -12
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
desc 'Set up the environment for running your web application'
|
3
|
+
task :environment do
|
4
|
+
require_relative '../config/environment'
|
5
|
+
|
6
|
+
# We ensure this is part of the shell environment so if other commands are invoked they will work correctly.
|
7
|
+
ENV['RACK_ENV'] = RACK_ENV.to_s if defined?(RACK_ENV)
|
8
|
+
ENV['DATABASE_ENV'] = DATABASE_ENV.to_s if defined?(DATABASE_ENV)
|
9
|
+
|
10
|
+
# This generates a consistent session secret if one was not already provided:
|
11
|
+
if ENV['UTOPIA_SESSION_SECRET'].nil?
|
12
|
+
require 'securerandom'
|
13
|
+
|
14
|
+
warn 'Generating transient session key for development...'
|
15
|
+
ENV['UTOPIA_SESSION_SECRET'] = SecureRandom.hex(32)
|
16
|
+
end
|
17
|
+
end
|
data/spec/mock_node.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
class MockNode
|
3
|
+
def initialize(namespaces = {}, &block)
|
4
|
+
@namespaces = namespaces
|
5
|
+
define_singleton_method(:call, block)
|
6
|
+
end
|
7
|
+
|
8
|
+
def lookup_tag(tag)
|
9
|
+
namespace, name = Trenni::Tag.split(tag.name)
|
10
|
+
|
11
|
+
if library = @namespaces[namespace]
|
12
|
+
library.call(name, self)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
if ENV['COVERAGE']
|
3
|
+
begin
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter "/spec/"
|
8
|
+
end
|
9
|
+
|
10
|
+
if ENV['TRAVIS']
|
11
|
+
require 'coveralls'
|
12
|
+
Coveralls.wear!
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
warn "Could not load simplecov: #{$!}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require "bundler/setup"
|
20
|
+
require "utopia"
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
# Enable flags like --only-failures and --next-failure
|
24
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
25
|
+
|
26
|
+
config.expect_with :rspec do |c|
|
27
|
+
c.syntax = :expect
|
28
|
+
end
|
29
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright,
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -18,31 +18,41 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
|
22
|
-
# Use only if required. This implementation works for Ruby 1.9.2.
|
21
|
+
require 'utopia/content/document'
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
class Time
|
27
|
-
alias_method :old_compare, :<=>
|
23
|
+
RSpec.describe Utopia::Content::Document do
|
24
|
+
subject{described_class.new(nil, {})}
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
else
|
33
|
-
old_compare(other)
|
26
|
+
it "should generate valid self-closing markup" do
|
27
|
+
node = proc do |document, state|
|
28
|
+
subject.tag("img", src: "cats.jpg")
|
34
29
|
end
|
30
|
+
|
31
|
+
result = subject.render_node(node)
|
32
|
+
|
33
|
+
expect(result).to be == '<img src="cats.jpg"/>'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should generate valid nested markup" do
|
37
|
+
node = proc do |document, state|
|
38
|
+
subject.tag("div") do
|
39
|
+
subject.tag("img", src: "cats.jpg")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
result = subject.render_node(node)
|
44
|
+
|
45
|
+
expect(result).to be == '<div><img src="cats.jpg"/></div>'
|
35
46
|
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class Date
|
39
|
-
alias_method :old_compare, :<=>
|
40
47
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
it "should fail if tags are unbalanced" do
|
49
|
+
node = proc do |document, state|
|
50
|
+
div = Utopia::Content::Tag.opened('div')
|
51
|
+
span = Utopia::Content::Tag.opened('span')
|
52
|
+
subject.tag_begin(div)
|
53
|
+
subject.tag_end(span)
|
46
54
|
end
|
55
|
+
|
56
|
+
expect{subject.render_node(node)}.to raise_error Utopia::Content::UnbalancedTagError, /tag span/
|
47
57
|
end
|
48
58
|
end
|
@@ -37,9 +37,9 @@ module Utopia::Content::MarkupSpec
|
|
37
37
|
|
38
38
|
describe Utopia::Content::MarkupParser do
|
39
39
|
it "should format open tags correctly" do
|
40
|
-
foo_tag = Utopia::Content::Tag.opened("foo", bar:
|
40
|
+
foo_tag = Utopia::Content::Tag.opened("foo", bar: true, baz: 'bob')
|
41
41
|
|
42
|
-
expect(foo_tag[:bar]).to be
|
42
|
+
expect(foo_tag[:bar]).to be == true
|
43
43
|
expect(foo_tag[:baz]).to be == 'bob'
|
44
44
|
|
45
45
|
expect(foo_tag.to_s('content')).to be == '<foo bar baz="bob">content</foo>'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright,
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -18,19 +18,26 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require 'utopia/content/
|
21
|
+
require 'utopia/content/namespace'
|
22
22
|
|
23
|
-
RSpec.describe Utopia::Content::
|
24
|
-
|
25
|
-
|
23
|
+
RSpec.describe Utopia::Content::Namespace do
|
24
|
+
let(:tags) do
|
25
|
+
Module.new.tap do |mod|
|
26
|
+
mod.extend(Utopia::Content::Namespace)
|
27
|
+
|
28
|
+
mod.tag('foo') do |document, state|
|
29
|
+
end
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
|
-
it "should
|
29
|
-
|
33
|
+
it "should freeze tags" do
|
34
|
+
tags.freeze
|
35
|
+
|
36
|
+
expect(tags).to be_frozen
|
37
|
+
expect(tags.named).to be_frozen
|
30
38
|
end
|
31
39
|
|
32
|
-
it "should have
|
33
|
-
expect(
|
34
|
-
expect(subject['class']).to be == 'main'
|
40
|
+
it "should have named tag" do
|
41
|
+
expect(tags.call('foo', nil)).to_not be_nil
|
35
42
|
end
|
36
43
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'utopia/content/tags'
|
22
|
+
require 'utopia/content/document'
|
23
|
+
|
24
|
+
require 'mock_node'
|
25
|
+
|
26
|
+
RSpec.describe Utopia::Content::Tags do
|
27
|
+
let(:document) {Utopia::Content::Document.new(nil, {})}
|
28
|
+
|
29
|
+
describe '<utopia:environment>' do
|
30
|
+
let(:node) do
|
31
|
+
MockNode.new('utopia' => subject) do |document, state|
|
32
|
+
document.tag("utopia:environment", only: 'test') do
|
33
|
+
document.text("Hello World")
|
34
|
+
end
|
35
|
+
|
36
|
+
document.tag("utopia:environment", only: 'production') do
|
37
|
+
document.text("Goodbye World")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "it should render correct content for test" do
|
43
|
+
document[:environment] = "test"
|
44
|
+
|
45
|
+
result = document.render_node(node)
|
46
|
+
|
47
|
+
expect(result).to be == 'Hello World'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "it should render correct content for production" do
|
51
|
+
document[:environment] = "production"
|
52
|
+
|
53
|
+
result = document.render_node(node)
|
54
|
+
|
55
|
+
expect(result).to be == 'Goodbye World'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '<utopia:node>' do
|
60
|
+
let(:node) do
|
61
|
+
MockNode.new('utopia' => subject) do |document, state|
|
62
|
+
document.tag("utopia:node", path: 'test')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:test_node) do
|
67
|
+
MockNode.new do |document, state|
|
68
|
+
document.text("Test Node")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "it should render correct content for test" do
|
73
|
+
expect(document).to receive(:lookup_node).with('test').and_return(test_node)
|
74
|
+
|
75
|
+
result = document.render_node(node)
|
76
|
+
|
77
|
+
expect(result).to be == 'Test Node'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/utopia/content_spec.rb
CHANGED
@@ -73,7 +73,7 @@ module Utopia::ContentSpec
|
|
73
73
|
|
74
74
|
describe Utopia::Content do
|
75
75
|
let(:root) {File.expand_path('content_spec', __dir__)}
|
76
|
-
let(:content) {Utopia::Content.new(lambda{}, root: root
|
76
|
+
let(:content) {Utopia::Content.new(lambda{}, root: root)}
|
77
77
|
|
78
78
|
it "should parse file and expand variables" do
|
79
79
|
path = Utopia::Path.create('/index')
|
data/spec/utopia/content_spec.ru
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<h1><content
|
1
|
+
<h1><utopia:content/></h1>
|
@@ -1 +1 @@
|
|
1
|
-
#{partial 'show-value', value: 10}
|
1
|
+
#{partial 'content:show-value', value: 10}
|
@@ -1 +1 @@
|
|
1
|
-
<heading>Hello World</heading>
|
1
|
+
<content:heading>Hello World</content:heading>
|
@@ -96,8 +96,8 @@ module Utopia::Controller::RespondSpec
|
|
96
96
|
get '/errors/file-not-found'
|
97
97
|
|
98
98
|
expect(last_response.status).to be == 200
|
99
|
-
expect(last_response.headers['Content-Type']).to
|
100
|
-
expect(last_response.body).to be_include "<
|
99
|
+
expect(last_response.headers['Content-Type']).to include('text/html')
|
100
|
+
expect(last_response.body).to be_include "<h1>File Not Found</h1>"
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should get json error response" do
|
@@ -138,25 +138,5 @@ module Utopia::Controller::RespondSpec
|
|
138
138
|
expect(last_response.headers['Content-Type']).to be == 'application/json; charset=utf-8'
|
139
139
|
expect(last_response.body).to be == '{}'
|
140
140
|
end
|
141
|
-
|
142
|
-
it "should give record as JSON" do
|
143
|
-
header 'Accept', 'application/json'
|
144
|
-
|
145
|
-
get '/rewrite/2/show'
|
146
|
-
|
147
|
-
expect(last_response.status).to be == 200
|
148
|
-
expect(last_response.headers['Content-Type']).to be == 'application/json; charset=utf-8'
|
149
|
-
expect(last_response.body).to be == '{"id":2,"foo":"bar"}'
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should give error as JSON" do
|
153
|
-
header 'Accept', 'application/json'
|
154
|
-
|
155
|
-
get '/rewrite/1/show'
|
156
|
-
|
157
|
-
expect(last_response.status).to be == 404
|
158
|
-
expect(last_response.headers['Content-Type']).to be == 'application/json; charset=utf-8'
|
159
|
-
expect(last_response.body).to be == '{"message":"Could not find record"}'
|
160
|
-
end
|
161
141
|
end
|
162
142
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
|
2
|
-
use Utopia::Redirection::Errors,
|
3
|
-
404 => '/fail'
|
4
|
-
|
5
2
|
use Utopia::Controller,
|
6
|
-
root: File.expand_path('respond_spec', __dir__)
|
7
|
-
base: Utopia::Controller::Base
|
3
|
+
root: File.expand_path('respond_spec', __dir__)
|
8
4
|
|
9
5
|
use Utopia::Content,
|
10
6
|
root: File.expand_path('respond_spec', __dir__)
|
@@ -1,7 +1,8 @@
|
|
1
|
-
<
|
2
|
-
|
1
|
+
<html>
|
2
|
+
<head><title>Error</title></head>
|
3
|
+
<body>
|
4
|
+
<h1>File Not Found</h1>
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
</page>
|
6
|
+
<p>The file you requested is unfortunately not available at this time!</p>
|
7
|
+
</body>
|
8
|
+
</html>
|
@@ -18,8 +18,8 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require 'utopia/extensions/
|
22
|
-
require 'utopia/extensions/
|
21
|
+
require 'utopia/extensions/array_split'
|
22
|
+
require 'utopia/extensions/date_comparisons'
|
23
23
|
|
24
24
|
module Utopia::ExtensionsSpec
|
25
25
|
describe Array do
|
@@ -6,8 +6,7 @@ use Utopia::Localization,
|
|
6
6
|
hosts: {/foobar\.com$/ => 'en', /foobar\.co\.jp$/ => 'ja', /foobar\.de$/ => 'de'}
|
7
7
|
|
8
8
|
use Utopia::Controller,
|
9
|
-
root: localization_spec_root
|
10
|
-
base: Utopia::Controller::Base
|
9
|
+
root: localization_spec_root
|
11
10
|
|
12
11
|
use Utopia::Static,
|
13
12
|
root: localization_spec_root
|
@@ -30,10 +30,6 @@ RSpec.describe "Utopia Performance" do
|
|
30
30
|
if defined? Benchmark
|
31
31
|
def benchmark(name = nil)
|
32
32
|
Benchmark.ips do |benchmark|
|
33
|
-
# Collect more data for benchmark:
|
34
|
-
benchmark.time = 20
|
35
|
-
benchmark.warmup = 10
|
36
|
-
|
37
33
|
benchmark.report(name) do |i|
|
38
34
|
yield i
|
39
35
|
end
|
@@ -44,10 +40,10 @@ RSpec.describe "Utopia Performance" do
|
|
44
40
|
elsif defined? RubyProf
|
45
41
|
def benchmark(name)
|
46
42
|
result = RubyProf.profile do
|
47
|
-
yield
|
43
|
+
yield 2000
|
48
44
|
end
|
49
45
|
|
50
|
-
result.eliminate_methods!([/^((?!Utopia).)*$/])
|
46
|
+
#result.eliminate_methods!([/^((?!Utopia|Trenni).)*$/])
|
51
47
|
printer = RubyProf::FlatPrinter.new(result)
|
52
48
|
printer.print($stderr, min_percent: 1.0)
|
53
49
|
|
@@ -3,7 +3,8 @@
|
|
3
3
|
require 'utopia'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
-
|
6
|
+
require 'rack/freeze'
|
7
|
+
|
7
8
|
use Utopia::ContentLength
|
8
9
|
|
9
10
|
use Utopia::Redirection::Rewrite,
|
@@ -17,24 +18,16 @@ use Utopia::Redirection::Errors,
|
|
17
18
|
# use Utopia::Localization,
|
18
19
|
# :default_locale => 'en',
|
19
20
|
# :locales => ['en', 'de', 'ja', 'zh'],
|
20
|
-
# :
|
21
|
+
# :ignore => ['/_static/', '/_cache/']
|
21
22
|
|
22
23
|
use Utopia::Controller,
|
23
|
-
root: File.expand_path('pages', __dir__)
|
24
|
-
base: Utopia::Controller::Base,
|
25
|
-
cache_controllers: true
|
24
|
+
root: File.expand_path('pages', __dir__)
|
26
25
|
|
27
26
|
use Utopia::Static,
|
28
27
|
root: File.expand_path('pages', __dir__)
|
29
28
|
|
30
29
|
# Serve dynamic content
|
31
30
|
use Utopia::Content,
|
32
|
-
root: File.expand_path('pages', __dir__)
|
33
|
-
cache_templates: true,
|
34
|
-
tags: {
|
35
|
-
'deferred' => Utopia::Tags::Deferred,
|
36
|
-
'override' => Utopia::Tags::Override,
|
37
|
-
'node' => Utopia::Tags::Node,
|
38
|
-
}
|
31
|
+
root: File.expand_path('pages', __dir__)
|
39
32
|
|
40
33
|
run lambda { |env| [404, {}, []] }
|