rasti-web 2.0.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/rasti/web/controller.rb +2 -2
- data/lib/rasti/web/endpoint.rb +1 -1
- data/lib/rasti/web/headers.rb +48 -0
- data/lib/rasti/web/render.rb +23 -20
- data/lib/rasti/web/request.rb +3 -3
- data/lib/rasti/web/router.rb +1 -1
- data/lib/rasti/web/template.rb +3 -3
- data/lib/rasti/web/version.rb +1 -1
- data/lib/rasti/web.rb +1 -0
- data/rasti-web.gemspec +2 -2
- data/spec/application_spec.rb +4 -4
- data/spec/controller_spec.rb +9 -7
- data/spec/endpoint_spec.rb +1 -1
- data/spec/render_spec.rb +53 -11
- data/spec/request_spec.rb +1 -1
- data/spec/route_spec.rb +4 -4
- data/spec/router_spec.rb +1 -1
- data/spec/template_spec.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe8798970c44506545c6be1ae219b0e7217f5b3a467df410b37fbe1418db0306
|
4
|
+
data.tar.gz: 829ffa32848ef3f9e9fe1eaba28f97ff43f1f11989221a90ec774bfc6298c5be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb131289ca337c522ef423b489e71ece45846900501fc07d8b054a7f9fdafc6c4c3e09989f996a05a3613bb215ac593b8a6f295858f42ae03aa05d8c74784070
|
7
|
+
data.tar.gz: 9b0ad902cf04084474e49e54f8da8fc166bff805c99d0eb813d326433322c5c172f35f136241585ac1b59dce872e5f2ff9f78fae7c7142b313136db9d7f59631
|
data/README.md
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/gabynaiman/rasti-web.svg?branch=master)](https://travis-ci.org/gabynaiman/rasti-web)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/gabynaiman/rasti-web/badge.svg?branch=master)](https://coveralls.io/r/gabynaiman/rasti-web?branch=master)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/gabynaiman/rasti-web.svg)](https://codeclimate.com/github/gabynaiman/rasti-web)
|
7
|
-
[![Dependency Status](https://gemnasium.com/gabynaiman/rasti-web.svg)](https://gemnasium.com/gabynaiman/rasti-web)
|
8
7
|
|
9
8
|
Web blocks to build robust applications
|
10
9
|
|
data/lib/rasti/web/controller.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Rasti
|
2
2
|
module Web
|
3
3
|
class Controller
|
4
|
-
|
4
|
+
|
5
5
|
extend Forwardable
|
6
6
|
|
7
7
|
def_delegators :request, :params, :session
|
@@ -19,7 +19,7 @@ module Rasti
|
|
19
19
|
|
20
20
|
def action(action_name)
|
21
21
|
raise "Undefined action '#{action_name}' in #{name}" unless instance_methods.include? action_name.to_sym
|
22
|
-
|
22
|
+
|
23
23
|
Endpoint.new do |req, res, render|
|
24
24
|
controller = new req, res, render
|
25
25
|
begin
|
data/lib/rasti/web/endpoint.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Rasti
|
2
|
+
module Web
|
3
|
+
class Headers
|
4
|
+
|
5
|
+
CONTENT_TYPES = {
|
6
|
+
text: 'text/plain',
|
7
|
+
html: 'text/html',
|
8
|
+
json: 'application/json',
|
9
|
+
js: 'application/javascript',
|
10
|
+
css: 'text/css'
|
11
|
+
}
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
CONTENT_TYPES.each do |key, value|
|
16
|
+
define_method "for_#{key}" do |charset:'utf-8'|
|
17
|
+
content_type value, charset: charset
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def for_file(filename, attachment:true, charset:'utf-8')
|
22
|
+
merge content_type(MIME::Types.of(filename).first.content_type, charset: charset),
|
23
|
+
content_disposition(filename, attachment: attachment)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def content_type(type, charset:'utf-8')
|
29
|
+
{'Content-Type' => "#{type}; charset=#{charset}"}
|
30
|
+
end
|
31
|
+
|
32
|
+
def content_disposition(filename, attachment:true)
|
33
|
+
args = []
|
34
|
+
args << 'attachment' if attachment
|
35
|
+
args << "filename=\"#{File.basename(filename)}\""
|
36
|
+
{'Content-Disposition' => args.join("; ")}
|
37
|
+
end
|
38
|
+
|
39
|
+
def merge(*poperties)
|
40
|
+
poperties.inject({}) do |result, prop|
|
41
|
+
result.merge prop
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/rasti/web/render.rb
CHANGED
@@ -11,60 +11,63 @@ module Rasti
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def status(status, *args)
|
14
|
-
respond_with status,
|
15
|
-
extract_headers(args),
|
14
|
+
respond_with status,
|
15
|
+
extract_headers(args),
|
16
16
|
extract_body(args)
|
17
17
|
end
|
18
18
|
|
19
19
|
def text(text, *args)
|
20
|
-
respond_with extract_status(args),
|
21
|
-
extract_headers(args).merge(
|
20
|
+
respond_with extract_status(args),
|
21
|
+
extract_headers(args).merge(Headers.for_text),
|
22
22
|
text
|
23
23
|
end
|
24
24
|
|
25
25
|
def html(html, *args)
|
26
|
-
respond_with extract_status(args),
|
27
|
-
extract_headers(args).merge(
|
26
|
+
respond_with extract_status(args),
|
27
|
+
extract_headers(args).merge(Headers.for_html),
|
28
28
|
html
|
29
29
|
end
|
30
30
|
|
31
31
|
def json(object, *args)
|
32
|
-
respond_with extract_status(args),
|
33
|
-
extract_headers(args).merge(
|
32
|
+
respond_with extract_status(args),
|
33
|
+
extract_headers(args).merge(Headers.for_json),
|
34
34
|
object.is_a?(String) ? object : JSON.dump(object)
|
35
35
|
end
|
36
36
|
|
37
37
|
def js(script, *args)
|
38
|
-
respond_with extract_status(args),
|
39
|
-
extract_headers(args).merge(
|
38
|
+
respond_with extract_status(args),
|
39
|
+
extract_headers(args).merge(Headers.for_js),
|
40
40
|
script
|
41
41
|
end
|
42
42
|
|
43
43
|
def css(stylesheet, *args)
|
44
|
-
respond_with extract_status(args),
|
45
|
-
extract_headers(args).merge(
|
44
|
+
respond_with extract_status(args),
|
45
|
+
extract_headers(args).merge(Headers.for_css),
|
46
46
|
stylesheet
|
47
47
|
end
|
48
48
|
|
49
49
|
def file(filename, *args)
|
50
|
-
|
51
|
-
|
50
|
+
respond_with extract_status(args),
|
51
|
+
Headers.for_file(filename).merge(extract_headers(args)),
|
52
|
+
File.read(filename)
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
def data(content, *args)
|
56
|
+
respond_with extract_status(args),
|
57
|
+
extract_headers(args),
|
58
|
+
content
|
56
59
|
end
|
57
60
|
|
58
61
|
def partial(template, locals={})
|
59
|
-
response
|
62
|
+
response.headers.merge! Headers.for_html
|
60
63
|
response.write view_context.render(template, locals)
|
61
64
|
end
|
62
65
|
|
63
66
|
def layout(template=nil, &block)
|
64
67
|
content = block.call if block
|
65
68
|
layout = view_context.render(template || Web.default_layout) { content }
|
66
|
-
|
67
|
-
response
|
69
|
+
|
70
|
+
response.headers.merge! Headers.for_html
|
68
71
|
response.write layout
|
69
72
|
end
|
70
73
|
|
data/lib/rasti/web/request.rb
CHANGED
@@ -12,7 +12,7 @@ module Rasti
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def body_text
|
15
|
-
@body_text ||= begin
|
15
|
+
@body_text ||= begin
|
16
16
|
text = body.read
|
17
17
|
body.rewind
|
18
18
|
text
|
@@ -20,8 +20,8 @@ module Rasti
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def json?
|
23
|
-
!content_type.nil? && ContentType.parse(content_type).mime_type == 'application/json'
|
24
|
-
rescue
|
23
|
+
!content_type.nil? && ContentType.parse(content_type).mime_type == 'application/json'
|
24
|
+
rescue
|
25
25
|
false
|
26
26
|
end
|
27
27
|
|
data/lib/rasti/web/router.rb
CHANGED
data/lib/rasti/web/template.rb
CHANGED
@@ -4,10 +4,10 @@ module Rasti
|
|
4
4
|
|
5
5
|
def self.render(template, context=nil, locals={}, &block)
|
6
6
|
files = Web.template_engines.map { |e| File.join Web.views_path, "#{template}.#{e}" }
|
7
|
-
template_file = files.detect { |f| File.
|
7
|
+
template_file = files.detect { |f| File.exist? f }
|
8
8
|
|
9
9
|
raise "Missing template #{template} [#{files.join(', ')}]" unless template_file
|
10
|
-
|
10
|
+
|
11
11
|
tilt = cache.fetch(template_file) { Tilt.new template_file }
|
12
12
|
tilt.render(context, locals, &block)
|
13
13
|
end
|
@@ -17,7 +17,7 @@ module Rasti
|
|
17
17
|
def self.cache
|
18
18
|
Thread.current[:templates_cache] ||= Tilt::Cache.new
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/rasti/web/version.rb
CHANGED
data/lib/rasti/web.rb
CHANGED
@@ -16,6 +16,7 @@ require_relative 'web/application'
|
|
16
16
|
require_relative 'web/template'
|
17
17
|
require_relative 'web/view_context'
|
18
18
|
require_relative 'web/render'
|
19
|
+
require_relative 'web/headers'
|
19
20
|
require_relative 'web/request'
|
20
21
|
require_relative 'web/controller'
|
21
22
|
require_relative 'web/version'
|
data/rasti-web.gemspec
CHANGED
@@ -26,12 +26,12 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency 'content-type', '~> 0.0'
|
27
27
|
spec.add_dependency 'class_ancestry_sort', '~> 0.1'
|
28
28
|
|
29
|
-
spec.add_development_dependency 'rake', '~>
|
29
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
30
30
|
spec.add_development_dependency 'minitest', '~> 5.0', '< 5.11'
|
31
31
|
spec.add_development_dependency 'minitest-colorin', '~> 0.1'
|
32
32
|
spec.add_development_dependency 'minitest-line', '~> 0.6'
|
33
33
|
spec.add_development_dependency 'simplecov', '~> 0.12'
|
34
34
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
35
|
-
spec.add_development_dependency 'pry-nav', '~> 0
|
35
|
+
spec.add_development_dependency 'pry-nav', '~> 1.0'
|
36
36
|
spec.add_development_dependency 'rack-test', '~> 0.6'
|
37
37
|
end
|
data/spec/application_spec.rb
CHANGED
@@ -8,7 +8,7 @@ class TestMiddleware
|
|
8
8
|
def call(env)
|
9
9
|
if env['PATH_INFO'] == '/private'
|
10
10
|
[403, {}, ['Permission denied']]
|
11
|
-
else
|
11
|
+
else
|
12
12
|
@app.call env
|
13
13
|
end
|
14
14
|
end
|
@@ -50,7 +50,7 @@ describe Rasti::Web::Application do
|
|
50
50
|
|
51
51
|
it 'Defined route' do
|
52
52
|
get '/'
|
53
|
-
|
53
|
+
|
54
54
|
last_response.status.must_equal 200
|
55
55
|
last_response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
56
56
|
last_response.body.must_equal 'Page content'
|
@@ -58,7 +58,7 @@ describe Rasti::Web::Application do
|
|
58
58
|
|
59
59
|
it 'Not found' do
|
60
60
|
get '/not_found'
|
61
|
-
|
61
|
+
|
62
62
|
last_response.status.must_equal 404
|
63
63
|
last_response.body.must_equal 'Page not found'
|
64
64
|
end
|
@@ -77,5 +77,5 @@ describe Rasti::Web::Application do
|
|
77
77
|
last_response['Content-Type'].must_equal 'application/json; charset=utf-8'
|
78
78
|
last_response.body.must_equal '{"id":123}'
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
end
|
data/spec/controller_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'minitest_helper'
|
2
2
|
|
3
3
|
class TestController < Rasti::Web::Controller
|
4
|
-
|
4
|
+
|
5
5
|
CustomError = Class.new StandardError
|
6
6
|
|
7
7
|
def self.hooks_log
|
@@ -16,14 +16,14 @@ class TestController < Rasti::Web::Controller
|
|
16
16
|
self.class.hooks_log << "After all: #{action_name}"
|
17
17
|
end
|
18
18
|
|
19
|
-
before_action :test do
|
19
|
+
before_action :test do
|
20
20
|
self.class.hooks_log << 'Before single: test'
|
21
21
|
end
|
22
22
|
|
23
|
-
after_action :test do
|
23
|
+
after_action :test do
|
24
24
|
self.class.hooks_log << 'After single: test'
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def test
|
28
28
|
render.html 'Test HTML'
|
29
29
|
end
|
@@ -55,7 +55,7 @@ describe Rasti::Web::Controller do
|
|
55
55
|
before do
|
56
56
|
TestController.hooks_log.clear
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it 'Action endpoint' do
|
60
60
|
action = TestController.action :test
|
61
61
|
env = Rack::MockRequest.env_for '/test'
|
@@ -65,7 +65,7 @@ describe Rasti::Web::Controller do
|
|
65
65
|
status.must_equal 200
|
66
66
|
headers['Content-Type'].must_equal 'text/html; charset=utf-8'
|
67
67
|
response.body.must_equal ['Test HTML']
|
68
|
-
|
68
|
+
|
69
69
|
TestController.hooks_log.must_equal [
|
70
70
|
'Before single: test',
|
71
71
|
'After single: test'
|
@@ -84,6 +84,7 @@ describe Rasti::Web::Controller do
|
|
84
84
|
status, headers, response = action.call env
|
85
85
|
|
86
86
|
status.must_equal 500
|
87
|
+
headers['Content-Type'].must_be_nil
|
87
88
|
response.body.must_equal ['Explicit error']
|
88
89
|
|
89
90
|
TestController.hooks_log.must_equal [
|
@@ -98,6 +99,7 @@ describe Rasti::Web::Controller do
|
|
98
99
|
status, headers, response = action.call env
|
99
100
|
|
100
101
|
status.must_equal 500
|
102
|
+
headers['Content-Type'].must_be_nil
|
101
103
|
response.body.must_equal ['Implicit error']
|
102
104
|
|
103
105
|
TestController.hooks_log.must_equal [
|
@@ -109,7 +111,7 @@ describe Rasti::Web::Controller do
|
|
109
111
|
it 'Unexpected exception' do
|
110
112
|
action = TestController.action :exception
|
111
113
|
env = Rack::MockRequest.env_for '/exception'
|
112
|
-
|
114
|
+
|
113
115
|
error = proc { action.call env }.must_raise RuntimeError
|
114
116
|
error.message.must_equal 'Unexpected error'
|
115
117
|
|
data/spec/endpoint_spec.rb
CHANGED
data/spec/render_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Rasti::Web::Render do
|
|
10
10
|
|
11
11
|
it 'Code' do
|
12
12
|
render.status 404
|
13
|
-
|
13
|
+
|
14
14
|
response.status.must_equal 404
|
15
15
|
response['Content-Type'].must_be_nil
|
16
16
|
response.body.must_equal []
|
@@ -18,7 +18,7 @@ describe Rasti::Web::Render do
|
|
18
18
|
|
19
19
|
it 'Code and body' do
|
20
20
|
render.status 500, 'Internal server error'
|
21
|
-
|
21
|
+
|
22
22
|
response.status.must_equal 500
|
23
23
|
response['Content-Type'].must_be_nil
|
24
24
|
response.body.must_equal ['Internal server error']
|
@@ -167,7 +167,7 @@ describe Rasti::Web::Render do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
describe 'Javascript' do
|
170
|
-
|
170
|
+
|
171
171
|
it 'Body' do
|
172
172
|
render.js 'alert("hello");'
|
173
173
|
|
@@ -205,7 +205,7 @@ describe Rasti::Web::Render do
|
|
205
205
|
end
|
206
206
|
|
207
207
|
describe 'CSS' do
|
208
|
-
|
208
|
+
|
209
209
|
it 'Body' do
|
210
210
|
render.css 'body{margin:0}'
|
211
211
|
|
@@ -250,7 +250,8 @@ describe Rasti::Web::Render do
|
|
250
250
|
render.file filename
|
251
251
|
|
252
252
|
response.status.must_equal 200
|
253
|
-
response['Content-Type'].must_equal 'application/zip'
|
253
|
+
response['Content-Type'].must_equal 'application/zip; charset=utf-8'
|
254
|
+
response['Content-Disposition'].must_equal 'attachment; filename="sample_file.zip"'
|
254
255
|
response.body.must_equal [File.read(filename)]
|
255
256
|
end
|
256
257
|
|
@@ -258,7 +259,8 @@ describe Rasti::Web::Render do
|
|
258
259
|
render.file filename, 206
|
259
260
|
|
260
261
|
response.status.must_equal 206
|
261
|
-
response['Content-Type'].must_equal 'application/zip'
|
262
|
+
response['Content-Type'].must_equal 'application/zip; charset=utf-8'
|
263
|
+
response['Content-Disposition'].must_equal 'attachment; filename="sample_file.zip"'
|
262
264
|
response.body.must_equal [File.read(filename)]
|
263
265
|
end
|
264
266
|
|
@@ -266,7 +268,7 @@ describe Rasti::Web::Render do
|
|
266
268
|
render.file filename, 'Content-Disposition' => 'attachment; filename=test_file.zip'
|
267
269
|
|
268
270
|
response.status.must_equal 200
|
269
|
-
response['Content-Type'].must_equal 'application/zip'
|
271
|
+
response['Content-Type'].must_equal 'application/zip; charset=utf-8'
|
270
272
|
response['Content-Disposition'].must_equal 'attachment; filename=test_file.zip'
|
271
273
|
response.body.must_equal [File.read(filename)]
|
272
274
|
end
|
@@ -275,13 +277,53 @@ describe Rasti::Web::Render do
|
|
275
277
|
render.file filename, 206, 'Content-Disposition' => 'attachment; filename=test_file.zip'
|
276
278
|
|
277
279
|
response.status.must_equal 206
|
278
|
-
response['Content-Type'].must_equal 'application/zip'
|
280
|
+
response['Content-Type'].must_equal 'application/zip; charset=utf-8'
|
279
281
|
response['Content-Disposition'].must_equal 'attachment; filename=test_file.zip'
|
280
282
|
response.body.must_equal [File.read(filename)]
|
281
283
|
end
|
282
284
|
|
283
285
|
end
|
284
286
|
|
287
|
+
describe 'Data' do
|
288
|
+
|
289
|
+
let(:content) { 'Response data' }
|
290
|
+
|
291
|
+
it 'Body' do
|
292
|
+
render.data content
|
293
|
+
|
294
|
+
response.status.must_equal 200
|
295
|
+
response['Content-Type'].must_be_nil
|
296
|
+
response.body.must_equal [content]
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'Body and status' do
|
300
|
+
render.data content, 206
|
301
|
+
|
302
|
+
response.status.must_equal 206
|
303
|
+
response['Content-Type'].must_be_nil
|
304
|
+
response.body.must_equal [content]
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'Body and headers' do
|
308
|
+
render.data content, Rasti::Web::Headers.for_file('test_file.txt')
|
309
|
+
|
310
|
+
response.status.must_equal 200
|
311
|
+
response['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
312
|
+
response['Content-Disposition'].must_equal 'attachment; filename="test_file.txt"'
|
313
|
+
response.body.must_equal [content]
|
314
|
+
end
|
315
|
+
|
316
|
+
it 'Body, status and headers' do
|
317
|
+
render.data content, 206, Rasti::Web::Headers.for_file('test_file.txt')
|
318
|
+
|
319
|
+
response.status.must_equal 206
|
320
|
+
response['Content-Type'].must_equal 'text/plain; charset=utf-8'
|
321
|
+
response['Content-Disposition'].must_equal 'attachment; filename="test_file.txt"'
|
322
|
+
response.body.must_equal [content]
|
323
|
+
end
|
324
|
+
|
325
|
+
end
|
326
|
+
|
285
327
|
it 'Partial' do
|
286
328
|
render.partial 'context_and_locals', title: 'Welcome', text: 'Hello world'
|
287
329
|
|
@@ -291,7 +333,7 @@ describe Rasti::Web::Render do
|
|
291
333
|
end
|
292
334
|
|
293
335
|
describe 'Layout' do
|
294
|
-
|
336
|
+
|
295
337
|
it 'Default' do
|
296
338
|
render.layout { 'Page content' }
|
297
339
|
|
@@ -322,7 +364,7 @@ describe Rasti::Web::Render do
|
|
322
364
|
|
323
365
|
it 'Default layout' do
|
324
366
|
render.view 'context_and_locals', title: 'Welcome', text: 'Hello world'
|
325
|
-
|
367
|
+
|
326
368
|
response.status.must_equal 200
|
327
369
|
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
328
370
|
response.body.must_equal ['<html><body><h1>Welcome</h1><div>Hello world</div></body></html>']
|
@@ -330,7 +372,7 @@ describe Rasti::Web::Render do
|
|
330
372
|
|
331
373
|
it 'Custom layout' do
|
332
374
|
render.view 'context_and_locals', {title: 'Welcome', text: 'Hello world'}, 'custom_layout'
|
333
|
-
|
375
|
+
|
334
376
|
response.status.must_equal 200
|
335
377
|
response['Content-Type'].must_equal 'text/html; charset=utf-8'
|
336
378
|
response.body.must_equal ['<html><body class="custom"><h1>Welcome</h1><div>Hello world</div></body></html>']
|
data/spec/request_spec.rb
CHANGED
data/spec/route_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require 'minitest_helper'
|
|
3
3
|
describe Rasti::Web::Route do
|
4
4
|
|
5
5
|
ROUTES = [
|
6
|
-
'/',
|
6
|
+
'/',
|
7
7
|
'/*/wildcard/action',
|
8
8
|
'/wildcard/*/action',
|
9
9
|
'/wildcard/*/action/:id',
|
10
10
|
'/wildcard/*',
|
11
|
-
'/resource',
|
11
|
+
'/resource',
|
12
12
|
'/resource/:id/:action',
|
13
13
|
'/:resource(/:id(/:action))'
|
14
14
|
]
|
@@ -72,7 +72,7 @@ describe Rasti::Web::Route do
|
|
72
72
|
|
73
73
|
route.pattern.must_equal '/*/wildcard/action'
|
74
74
|
route.extract_params(path).must_equal wildcard: 'section/sub_section'
|
75
|
-
route.call({}).must_equal RESPONSE
|
75
|
+
route.call({}).must_equal RESPONSE
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'Middle' do
|
@@ -97,7 +97,7 @@ describe Rasti::Web::Route do
|
|
97
97
|
|
98
98
|
it 'Params' do
|
99
99
|
path = '/wildcard/section/sub_section/action/123'
|
100
|
-
|
100
|
+
|
101
101
|
route = route_for path
|
102
102
|
|
103
103
|
route.pattern.must_equal '/wildcard/*/action/:id'
|
data/spec/router_spec.rb
CHANGED
data/spec/template_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasti-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '13.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '13.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: minitest
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,14 +204,14 @@ dependencies:
|
|
204
204
|
requirements:
|
205
205
|
- - "~>"
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: '0
|
207
|
+
version: '1.0'
|
208
208
|
type: :development
|
209
209
|
prerelease: false
|
210
210
|
version_requirements: !ruby/object:Gem::Requirement
|
211
211
|
requirements:
|
212
212
|
- - "~>"
|
213
213
|
- !ruby/object:Gem::Version
|
214
|
-
version: '0
|
214
|
+
version: '1.0'
|
215
215
|
- !ruby/object:Gem::Dependency
|
216
216
|
name: rack-test
|
217
217
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/rasti/web/application.rb
|
248
248
|
- lib/rasti/web/controller.rb
|
249
249
|
- lib/rasti/web/endpoint.rb
|
250
|
+
- lib/rasti/web/headers.rb
|
250
251
|
- lib/rasti/web/render.rb
|
251
252
|
- lib/rasti/web/request.rb
|
252
253
|
- lib/rasti/web/route.rb
|