roda 2.9.0 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/MIT-LICENSE +1 -1
- data/doc/release_notes/2.10.0.txt +27 -0
- data/lib/roda.rb +2 -0
- data/lib/roda/plugins/_erubis_escaping.rb +2 -0
- data/lib/roda/plugins/all_verbs.rb +2 -0
- data/lib/roda/plugins/assets.rb +3 -1
- data/lib/roda/plugins/backtracking_array.rb +2 -0
- data/lib/roda/plugins/caching.rb +2 -0
- data/lib/roda/plugins/chunked.rb +3 -1
- data/lib/roda/plugins/class_level_routing.rb +2 -0
- data/lib/roda/plugins/content_for.rb +3 -1
- data/lib/roda/plugins/cookies.rb +2 -0
- data/lib/roda/plugins/csrf.rb +2 -0
- data/lib/roda/plugins/default_headers.rb +2 -0
- data/lib/roda/plugins/default_status.rb +2 -0
- data/lib/roda/plugins/delay_build.rb +2 -0
- data/lib/roda/plugins/delegate.rb +2 -0
- data/lib/roda/plugins/delete_empty_headers.rb +2 -0
- data/lib/roda/plugins/drop_body.rb +2 -0
- data/lib/roda/plugins/empty_root.rb +2 -0
- data/lib/roda/plugins/environments.rb +2 -0
- data/lib/roda/plugins/error_email.rb +4 -1
- data/lib/roda/plugins/error_handler.rb +2 -0
- data/lib/roda/plugins/flash.rb +2 -0
- data/lib/roda/plugins/h.rb +2 -0
- data/lib/roda/plugins/halt.rb +2 -0
- data/lib/roda/plugins/hash_matcher.rb +2 -0
- data/lib/roda/plugins/head.rb +2 -0
- data/lib/roda/plugins/header_matchers.rb +2 -0
- data/lib/roda/plugins/heartbeat.rb +2 -0
- data/lib/roda/plugins/hooks.rb +2 -0
- data/lib/roda/plugins/indifferent_params.rb +2 -0
- data/lib/roda/plugins/json.rb +12 -3
- data/lib/roda/plugins/json_parser.rb +2 -0
- data/lib/roda/plugins/mailer.rb +2 -0
- data/lib/roda/plugins/match_affix.rb +2 -0
- data/lib/roda/plugins/middleware.rb +2 -0
- data/lib/roda/plugins/module_include.rb +2 -0
- data/lib/roda/plugins/multi_route.rb +2 -0
- data/lib/roda/plugins/multi_run.rb +2 -0
- data/lib/roda/plugins/multi_view.rb +2 -0
- data/lib/roda/plugins/named_templates.rb +2 -0
- data/lib/roda/plugins/not_allowed.rb +2 -0
- data/lib/roda/plugins/not_found.rb +2 -0
- data/lib/roda/plugins/padrino_render.rb +2 -0
- data/lib/roda/plugins/param_matchers.rb +2 -0
- data/lib/roda/plugins/partials.rb +2 -0
- data/lib/roda/plugins/pass.rb +2 -0
- data/lib/roda/plugins/path.rb +2 -0
- data/lib/roda/plugins/path_matchers.rb +2 -0
- data/lib/roda/plugins/path_rewriter.rb +2 -0
- data/lib/roda/plugins/per_thread_caching.rb +2 -0
- data/lib/roda/plugins/precompile_templates.rb +2 -0
- data/lib/roda/plugins/render.rb +2 -0
- data/lib/roda/plugins/render_each.rb +2 -0
- data/lib/roda/plugins/response_request.rb +2 -0
- data/lib/roda/plugins/run_handler.rb +2 -0
- data/lib/roda/plugins/shared_vars.rb +2 -0
- data/lib/roda/plugins/sinatra_helpers.rb +2 -0
- data/lib/roda/plugins/slash_path_empty.rb +2 -0
- data/lib/roda/plugins/static.rb +2 -0
- data/lib/roda/plugins/status_handler.rb +2 -0
- data/lib/roda/plugins/streaming.rb +8 -1
- data/lib/roda/plugins/symbol_matchers.rb +2 -0
- data/lib/roda/plugins/symbol_views.rb +2 -0
- data/lib/roda/plugins/view_options.rb +2 -0
- data/lib/roda/plugins/websockets.rb +2 -0
- data/lib/roda/version.rb +1 -1
- data/spec/opts_spec.rb +1 -1
- data/spec/plugin/chunked_spec.rb +1 -1
- data/spec/plugin/json_spec.rb +14 -0
- data/spec/plugin/sinatra_helpers_spec.rb +2 -3
- data/spec/plugin/streaming_spec.rb +2 -2
- data/spec/plugin/websockets_spec.rb +3 -0
- data/spec/session_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f294c5f09434c3db4c5c1e8f883071a1381b398c
|
4
|
+
data.tar.gz: bfa22f2e6fdb5bf030dd9bcdb74cc130ac42e005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62058ce501a97f2f4ce334d8a00b24a922f19545f414978b986e840a8b722bff80878c7998fe3c6403f326183341dffca76b894c598dbfd1c5024e02844aed76
|
7
|
+
data.tar.gz: 87256dacdf54f10450ed05a2e750e6c312b224f53039175faf34a7084539097d916cd91785abd71be678db96f63c489c6b6d2f1ebca40a1299627cf9f5a9a77b
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
= 2.10.0 (2016-01-15)
|
2
|
+
|
3
|
+
* Do not override existing Content-Type header in json plugin (jeremyevans)
|
4
|
+
|
5
|
+
* Add :content_type option to json plugin to override Content-Type header used (Kyrremann) (#58)
|
6
|
+
|
7
|
+
* Add support for running with --enable-frozen-string-literal on ruby 2.3 (jeremyevans)
|
8
|
+
|
9
|
+
* Add Streaming::Stream#write method so that IO.copy_stream will work (janko-m) (#56)
|
10
|
+
|
1
11
|
= 2.9.0 (2015-12-15)
|
2
12
|
|
3
13
|
* Support passing the content as a string argument instead of a block in the content_for plugin (badosu) (#52)
|
data/MIT-LICENSE
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* The json plugin now accepts a :content_type option, which will
|
4
|
+
override the default Content-Type response header used for
|
5
|
+
responses.
|
6
|
+
|
7
|
+
* Stream#write has been added to the streaming plugin, allowing
|
8
|
+
the following type of code to work:
|
9
|
+
|
10
|
+
stream do |out|
|
11
|
+
IO.copy_stream(StringIO.new(content), out)
|
12
|
+
end
|
13
|
+
|
14
|
+
= Other Improvements
|
15
|
+
|
16
|
+
* Roda now works with ruby 2.3's --enable-frozen-string-literal,
|
17
|
+
and all of the library files are set to use frozen string
|
18
|
+
literals by default.
|
19
|
+
|
20
|
+
Most of roda's plugin-specific dependencies were found to have
|
21
|
+
issues with frozen string literals, and while pull requests have
|
22
|
+
been sent to fix the issues, it's unlikely that you would
|
23
|
+
currently be able to use --enable-frozen-string-literal in
|
24
|
+
production.
|
25
|
+
|
26
|
+
* The json plugin will no longer override a Content-Type header if
|
27
|
+
one is already set.
|
data/lib/roda.rb
CHANGED
data/lib/roda/plugins/assets.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
class Roda
|
2
4
|
module RodaPlugins
|
3
5
|
# The assets plugin adds support for rendering your CSS and javascript
|
@@ -614,7 +616,7 @@ class Roda
|
|
614
616
|
|
615
617
|
if o[:gzip] && env[HTTP_ACCEPT_ENCODING] =~ /\bgzip\b/
|
616
618
|
@_response[CONTENT_ENCODING] = GZIP
|
617
|
-
file
|
619
|
+
file += DOTGZ
|
618
620
|
end
|
619
621
|
|
620
622
|
check_asset_request(file, type, ::File.stat(file).mtime)
|
data/lib/roda/plugins/caching.rb
CHANGED
data/lib/roda/plugins/chunked.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
class Roda
|
2
4
|
module RodaPlugins
|
3
5
|
# The chunked plugin allows you to stream responses to clients using
|
@@ -265,7 +267,7 @@ class Roda
|
|
265
267
|
# of the response.
|
266
268
|
@_flusher = lambda do
|
267
269
|
yield @_out_buf
|
268
|
-
@_out_buf =
|
270
|
+
@_out_buf = String.new
|
269
271
|
end
|
270
272
|
|
271
273
|
if layout_opts = view_layout_opts(opts)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
class Roda
|
2
4
|
module RodaPlugins
|
3
5
|
# The content_for plugin is designed to be used with the
|
@@ -40,7 +42,7 @@ class Roda
|
|
40
42
|
outvar = render_opts[:template_opts][:outvar]
|
41
43
|
buf_was = instance_variable_get(outvar)
|
42
44
|
# clean the output buffer for ERB-based rendering systems
|
43
|
-
instance_variable_set(outvar,
|
45
|
+
instance_variable_set(outvar, String.new)
|
44
46
|
|
45
47
|
@_content_for ||= {}
|
46
48
|
@_content_for[key] = Tilt[render_opts[:engine]].new(&block).render
|
data/lib/roda/plugins/cookies.rb
CHANGED
data/lib/roda/plugins/csrf.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require 'net/smtp'
|
2
4
|
|
3
5
|
class Roda
|
@@ -41,7 +43,8 @@ class Roda
|
|
41
43
|
:body=>lambda do |s, e|
|
42
44
|
format = lambda{|h| h.map{|k, v| "#{k.inspect} => #{v.inspect}"}.sort.join("\n")}
|
43
45
|
|
44
|
-
message =
|
46
|
+
message = String.new
|
47
|
+
message << <<END
|
45
48
|
Path: #{s.request.path}
|
46
49
|
|
47
50
|
Backtrace:
|
data/lib/roda/plugins/flash.rb
CHANGED
data/lib/roda/plugins/h.rb
CHANGED
data/lib/roda/plugins/halt.rb
CHANGED
data/lib/roda/plugins/head.rb
CHANGED
data/lib/roda/plugins/hooks.rb
CHANGED
data/lib/roda/plugins/json.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
class Roda
|
@@ -44,10 +46,16 @@ class Roda
|
|
44
46
|
# +:include_request+ option, which will pass in the request
|
45
47
|
# object as the second argument when calling the serializer.
|
46
48
|
#
|
47
|
-
# plugin :json, include_request=>true, serializer=>proc{|o, request| ...}
|
49
|
+
# plugin :json, :include_request=>true, :serializer=>proc{|o, request| ...}
|
50
|
+
#
|
51
|
+
# The default content-type is 'application/json', but you can change that
|
52
|
+
# using the +:content_type+ option:
|
53
|
+
#
|
54
|
+
# plugin :json, :content_type=>'application/xml'
|
48
55
|
module Json
|
49
56
|
OPTS = {}.freeze
|
50
57
|
DEFAULT_SERIALIZER = lambda{|o| o.to_json}
|
58
|
+
DEFAULT_CONTENT_TYPE = 'application/json'.freeze
|
51
59
|
|
52
60
|
# Set the classes to automatically convert to JSON, and the serializer to use.
|
53
61
|
def self.configure(app, opts=OPTS)
|
@@ -60,6 +68,8 @@ class Roda
|
|
60
68
|
app.opts[:json_result_serializer] = opts[:serializer] || app.opts[:json_result_serializer] || DEFAULT_SERIALIZER
|
61
69
|
|
62
70
|
app.opts[:json_result_include_request] = opts[:include_request] || app.opts[:json_result_include_request]
|
71
|
+
|
72
|
+
app.opts[:json_result_content_type] = opts[:content_type] || DEFAULT_CONTENT_TYPE
|
63
73
|
end
|
64
74
|
|
65
75
|
module ClassMethods
|
@@ -71,7 +81,6 @@ class Roda
|
|
71
81
|
|
72
82
|
module RequestMethods
|
73
83
|
CONTENT_TYPE = 'Content-Type'.freeze
|
74
|
-
APPLICATION_JSON = 'application/json'.freeze
|
75
84
|
|
76
85
|
private
|
77
86
|
|
@@ -81,7 +90,7 @@ class Roda
|
|
81
90
|
def block_result_body(result)
|
82
91
|
case result
|
83
92
|
when *roda_class.json_result_classes
|
84
|
-
response[CONTENT_TYPE]
|
93
|
+
response[CONTENT_TYPE] ||= roda_class.opts[:json_result_content_type]
|
85
94
|
convert_to_json(result)
|
86
95
|
else
|
87
96
|
super
|
data/lib/roda/plugins/mailer.rb
CHANGED
data/lib/roda/plugins/pass.rb
CHANGED
data/lib/roda/plugins/path.rb
CHANGED
data/lib/roda/plugins/render.rb
CHANGED
data/lib/roda/plugins/static.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
1
3
|
class Roda
|
2
4
|
module RodaPlugins
|
3
5
|
# The streaming plugin adds support for streaming responses
|
@@ -100,11 +102,16 @@ class Roda
|
|
100
102
|
end
|
101
103
|
|
102
104
|
# Add output to the streaming response body.
|
103
|
-
def
|
105
|
+
def write(data)
|
104
106
|
@scheduler.schedule{@front.call(data.to_s)}
|
105
107
|
self
|
106
108
|
end
|
107
109
|
|
110
|
+
# Alias for +write+.
|
111
|
+
def <<(data)
|
112
|
+
write(data)
|
113
|
+
end
|
114
|
+
|
108
115
|
# Add the given block as a callback to call when the block closes.
|
109
116
|
def callback(&block)
|
110
117
|
return yield if closed?
|
data/lib/roda/version.rb
CHANGED
data/spec/opts_spec.rb
CHANGED
data/spec/plugin/chunked_spec.rb
CHANGED
data/spec/plugin/json_spec.rb
CHANGED
@@ -23,6 +23,11 @@ describe "json plugin" do
|
|
23
23
|
r.is 'c' do
|
24
24
|
c.new
|
25
25
|
end
|
26
|
+
|
27
|
+
r.is 'd' do
|
28
|
+
response['Content-Type'] = 'foo'
|
29
|
+
c.new
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end
|
@@ -34,6 +39,10 @@ describe "json plugin" do
|
|
34
39
|
header('Content-Type').must_equal 'text/html'
|
35
40
|
end
|
36
41
|
|
42
|
+
it "should not override existing content type for a json response" do
|
43
|
+
header('Content-Type', "/d").must_equal 'foo'
|
44
|
+
end
|
45
|
+
|
37
46
|
it "should convert objects to json" do
|
38
47
|
body('/array').gsub(/\s/, '').must_equal '[1,2,3]'
|
39
48
|
body('/hash').gsub(/\s/, '').must_equal '{"a":"b"}'
|
@@ -59,4 +68,9 @@ describe "json plugin" do
|
|
59
68
|
|
60
69
|
body("/hash").must_equal 'b:/hash'
|
61
70
|
end
|
71
|
+
|
72
|
+
it "should allow custom content type for a response" do
|
73
|
+
app.plugin :json, :content_type => "application/xml"
|
74
|
+
header('Content-Type', "/array").must_equal 'application/xml'
|
75
|
+
end
|
62
76
|
end
|
@@ -235,7 +235,6 @@ describe "sinatra_helpers plugin" do
|
|
235
235
|
it "looks up mime types in Rack's MIME registry" do
|
236
236
|
Rack::Mime::MIME_TYPES['.foo'] = 'application/foo'
|
237
237
|
body('foo').must_equal 'application/foo'
|
238
|
-
body(:foo).must_equal 'application/foo'
|
239
238
|
body('.foo').must_equal 'application/foo'
|
240
239
|
end
|
241
240
|
|
@@ -252,8 +251,8 @@ describe "sinatra_helpers plugin" do
|
|
252
251
|
end
|
253
252
|
|
254
253
|
it 'supports mime types registered at the class level' do
|
255
|
-
app.mime_type :foo, 'application/
|
256
|
-
body(
|
254
|
+
app.mime_type :foo, 'application/foo2'
|
255
|
+
body('foo').must_equal 'application/foo2'
|
257
256
|
end
|
258
257
|
end
|
259
258
|
|
@@ -4,14 +4,14 @@ describe "streaming plugin" do
|
|
4
4
|
it "adds stream method for streaming responses" do
|
5
5
|
app(:streaming) do |r|
|
6
6
|
stream do |out|
|
7
|
-
%w'a b c'.each{|v| out << v}
|
7
|
+
%w'a b c'.each{|v| out << v; out.write(v) }
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
s, h, b = req
|
12
12
|
s.must_equal 200
|
13
13
|
h.must_equal('Content-Type'=>'text/html')
|
14
|
-
b.to_a.must_equal %w'a b c'
|
14
|
+
b.to_a.must_equal %w'a a b b c c'
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should handle errors when streaming, and run callbacks" do
|
@@ -43,6 +43,8 @@ describe "websockets plugin" do
|
|
43
43
|
@port = 9791
|
44
44
|
q = Queue.new
|
45
45
|
Thread.new do
|
46
|
+
#$DEBUG=true
|
47
|
+
#Thin::Logging.trace = true
|
46
48
|
Thin::Logging.silent = true
|
47
49
|
Rack::Handler.get('thin').run(app, :Port => @port) do |s|
|
48
50
|
@server = s
|
@@ -52,6 +54,7 @@ describe "websockets plugin" do
|
|
52
54
|
q.pop
|
53
55
|
end
|
54
56
|
after do
|
57
|
+
#$DEBUG=nil
|
55
58
|
@server.stop
|
56
59
|
end
|
57
60
|
|
data/spec/session_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -47,7 +47,7 @@ class Minitest::Spec
|
|
47
47
|
if path.is_a?(Hash)
|
48
48
|
env = path
|
49
49
|
else
|
50
|
-
env['PATH_INFO'] = path
|
50
|
+
env['PATH_INFO'] = path.dup
|
51
51
|
end
|
52
52
|
|
53
53
|
env = {"REQUEST_METHOD" => "GET", "PATH_INFO" => "/", "SCRIPT_NAME" => ""}.merge(env)
|
@@ -63,7 +63,7 @@ class Minitest::Spec
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def body(path='/', env={})
|
66
|
-
s =
|
66
|
+
s = String.new
|
67
67
|
b = req(path, env)[2]
|
68
68
|
b.each{|x| s << x}
|
69
69
|
b.close if b.respond_to?(:close)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -175,6 +175,7 @@ extra_rdoc_files:
|
|
175
175
|
- doc/release_notes/2.7.0.txt
|
176
176
|
- doc/release_notes/2.8.0.txt
|
177
177
|
- doc/release_notes/2.9.0.txt
|
178
|
+
- doc/release_notes/2.10.0.txt
|
178
179
|
files:
|
179
180
|
- CHANGELOG
|
180
181
|
- MIT-LICENSE
|
@@ -187,6 +188,7 @@ files:
|
|
187
188
|
- doc/release_notes/1.3.0.txt
|
188
189
|
- doc/release_notes/2.0.0.txt
|
189
190
|
- doc/release_notes/2.1.0.txt
|
191
|
+
- doc/release_notes/2.10.0.txt
|
190
192
|
- doc/release_notes/2.2.0.txt
|
191
193
|
- doc/release_notes/2.3.0.txt
|
192
194
|
- doc/release_notes/2.4.0.txt
|
@@ -373,7 +375,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
373
375
|
requirements:
|
374
376
|
- - ">="
|
375
377
|
- !ruby/object:Gem::Version
|
376
|
-
version:
|
378
|
+
version: 1.8.7
|
377
379
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
378
380
|
requirements:
|
379
381
|
- - ">="
|
@@ -381,7 +383,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
381
383
|
version: '0'
|
382
384
|
requirements: []
|
383
385
|
rubyforge_project:
|
384
|
-
rubygems_version: 2.
|
386
|
+
rubygems_version: 2.5.1
|
385
387
|
signing_key:
|
386
388
|
specification_version: 4
|
387
389
|
summary: Routing tree web framework toolkit
|