sinatra-contrib 2.0.0 → 2.0.1.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -15
- data/Rakefile +11 -2
- data/lib/sinatra/contrib/version.rb +1 -1
- data/lib/sinatra/engine_tracking.rb +23 -0
- data/lib/sinatra/namespace.rb +1 -3
- data/lib/sinatra/runner.rb +44 -44
- data/lib/sinatra/test_helpers.rb +125 -0
- data/sinatra-contrib.gemspec +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a615aeb430fc3798adc052a32db556b4cc14995
|
4
|
+
data.tar.gz: dee1f8d52eb7fcdfb96b9af0f19077419da5a6a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8958af5cf23ef811fe72c7e59f19d667e6e0ac81f39f5efb76158b90f7ee92af7aa3f684e796e8e0f31532c5629fb7fc8278c7569ef806427b8f2d84eb01309
|
7
|
+
data.tar.gz: a42fcd0f2141282102e8ae872b47915781112b2c93c51e2505ad4777e6a64eb66ffc2a4d494bde422d49c603904c8e26168d30d1b14f7f20e962f27a3d229760
|
data/README.md
CHANGED
@@ -18,38 +18,38 @@ installed with this gem.
|
|
18
18
|
|
19
19
|
Currently included:
|
20
20
|
|
21
|
-
* `sinatra/capture
|
21
|
+
* [`sinatra/capture`][sinatra-capture]: Let's you capture the content of blocks in templates.
|
22
22
|
|
23
|
-
* `sinatra/config_file
|
23
|
+
* [`sinatra/config_file`][sinatra-config-file]: Allows loading configuration from yaml files.
|
24
24
|
|
25
|
-
* `sinatra/content_for
|
25
|
+
* [`sinatra/content_for`][sinatra-content-for]: Adds Rails-style `content_for` helpers to Haml, Erb,
|
26
26
|
Erubis and Slim.
|
27
27
|
|
28
|
-
* `sinatra/cookies
|
28
|
+
* [`sinatra/cookies`][sinatra-cookies]: A `cookies` helper for reading and writing cookies.
|
29
29
|
|
30
|
-
* `sinatra/engine_tracking
|
30
|
+
* [`sinatra/engine_tracking`][sinatra-engine-tracking]: Adds methods like `haml?` that allow helper
|
31
31
|
methods to check whether they are called from within a template.
|
32
32
|
|
33
|
-
* `sinatra/json
|
33
|
+
* [`sinatra/json`][sinatra-json]: Adds a `#json` helper method to return JSON documents.
|
34
34
|
|
35
|
-
* `sinatra/link_header
|
35
|
+
* [`sinatra/link_header`][sinatra-link-header]: Helpers for generating `link` HTML tags and
|
36
36
|
corresponding `Link` HTTP headers. Adds `link`, `stylesheet` and `prefetch`
|
37
37
|
helper methods.
|
38
38
|
|
39
|
-
* `sinatra/multi_route
|
39
|
+
* [`sinatra/multi_route`][sinatra-multi-route]: Adds ability to define one route block for multiple
|
40
40
|
routes and multiple or custom HTTP verbs.
|
41
41
|
|
42
|
-
* `sinatra/namespace
|
42
|
+
* [`sinatra/namespace`][sinatra-namespace]: Adds namespace support to Sinatra.
|
43
43
|
|
44
|
-
* `sinatra/respond_with
|
44
|
+
* [`sinatra/respond_with`][sinatra-respond-with]: Choose action and/or template automatically
|
45
45
|
depending on the incoming request. Adds helpers `respond_to` and
|
46
46
|
`respond_with`.
|
47
47
|
|
48
|
-
* `sinatra/custom_logger
|
48
|
+
* [`sinatra/custom_logger`][sinatra-custom-logger]: This extension allows you to define your own
|
49
49
|
logger instance using +logger+ setting. That logger then will
|
50
50
|
be available as #logger helper method in your routes and views.
|
51
51
|
|
52
|
-
* `sinatra/required_params
|
52
|
+
* [`sinatra/required_params`][sinatra-required-params]: Ensure if required query parameters exist
|
53
53
|
|
54
54
|
### Custom Extensions
|
55
55
|
|
@@ -58,13 +58,13 @@ existing APIs.
|
|
58
58
|
|
59
59
|
Currently included:
|
60
60
|
|
61
|
-
* `sinatra/reloader
|
61
|
+
* [`sinatra/reloader`][sinatra-reloader]: Automatically reloads Ruby files on code changes.
|
62
62
|
|
63
63
|
### Other Tools
|
64
64
|
|
65
|
-
* `sinatra/extension
|
65
|
+
* [`sinatra/extension`][sinatra-extension]: Mixin for writing your own Sinatra extensions.
|
66
66
|
|
67
|
-
* `sinatra/test_helpers
|
67
|
+
* [`sinatra/test_helpers`][sinatra-test-helpers]: Helper methods to ease testing your Sinatra
|
68
68
|
application. Partly extracted from Sinatra. Testing framework agnostic
|
69
69
|
|
70
70
|
## Installation
|
@@ -153,3 +153,23 @@ end
|
|
153
153
|
|
154
154
|
For more info check the [official docs](http://www.sinatrarb.com/contrib/) and
|
155
155
|
[api docs](http://www.rubydoc.info/gems/sinatra-contrib).
|
156
|
+
|
157
|
+
[sinatra-reloader]: /contrib/reloader
|
158
|
+
[sinatra-namespace]: /contrib/namespace
|
159
|
+
[sinatra-content-for]: /contrib/content_for
|
160
|
+
[sinatra-cookies]: /contrib/cookies
|
161
|
+
[sinatra-streaming]: /contrib/streaming
|
162
|
+
[sinatra-webdav]: /contrib/webdav
|
163
|
+
[sinatra-runner]: /contrib/runner
|
164
|
+
[sinatra-extension]: /contrib/extension
|
165
|
+
[sinatra-test-helpers]: /contrib/test_helpers
|
166
|
+
[sinatra-required-params]: /contrib/required_params
|
167
|
+
[sinatra-custom-logger]: /contrib/custom_logger
|
168
|
+
[sinatra-multi-route]: /contrib/multi_route
|
169
|
+
[sinatra-json]: /contrib/json
|
170
|
+
[sinatra-respond-with]: /contrib/respond_with
|
171
|
+
[sinatra-config-file]: /contrib/config_file
|
172
|
+
[sinatra-link-header]: /contrib/link_header
|
173
|
+
[sinatra-capture]: /contrib/capture
|
174
|
+
[sinatra-engine-tracking]: /contrib/engine_tracking
|
175
|
+
|
data/Rakefile
CHANGED
@@ -11,7 +11,8 @@ task(:default => :spec)
|
|
11
11
|
namespace :doc do
|
12
12
|
task :readmes do
|
13
13
|
Dir.glob 'lib/sinatra/*.rb' do |file|
|
14
|
-
|
14
|
+
puts "Trying file... #{file}"
|
15
|
+
excluded_files = %w[lib/sinatra/contrib.rb lib/sinatra/decompile.rb]
|
15
16
|
next if excluded_files.include?(file)
|
16
17
|
doc = File.read(file)[/^module Sinatra(\n)+( #[^\n]*\n)*/m].scan(/^ *#(?!#) ?(.*)\n/).join("\n")
|
17
18
|
file = "doc/#{file[4..-4].tr("/_", "-")}.rdoc"
|
@@ -21,7 +22,15 @@ namespace :doc do
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
task :
|
25
|
+
task :index do
|
26
|
+
doc = File.read("README.md")
|
27
|
+
file = "doc/sinatra-contrib-readme.md"
|
28
|
+
Dir.mkdir "doc" unless File.directory? "doc"
|
29
|
+
puts "writing #{file}"
|
30
|
+
File.open(file, "w") { |f| f << doc }
|
31
|
+
end
|
32
|
+
|
33
|
+
task :all => [:readmes, :index]
|
25
34
|
end
|
26
35
|
|
27
36
|
desc "generate documentation"
|
@@ -1,74 +1,96 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
|
3
3
|
module Sinatra
|
4
|
+
# Adds methods like `haml?` that allow helper methods to check whether they
|
5
|
+
# are called from within a template.
|
4
6
|
module EngineTracking
|
5
7
|
attr_reader :current_engine
|
6
8
|
|
9
|
+
# @return [Boolean] Returns true if current engine is `:erb`.
|
7
10
|
def erb?
|
8
11
|
@current_engine == :erb
|
9
12
|
end
|
10
13
|
|
14
|
+
# Returns true if the current engine is `:erubis`, or `Tilt[:erb]` is set
|
15
|
+
# to Tilt::ErubisTemplate.
|
16
|
+
#
|
17
|
+
# @return [Boolean] Returns true if current engine is `:erubis`.
|
11
18
|
def erubis?
|
12
19
|
@current_engine == :erubis or
|
13
20
|
erb? && Tilt[:erb] == Tilt::ErubisTemplate
|
14
21
|
end
|
15
22
|
|
23
|
+
# @return [Boolean] Returns true if current engine is `:haml`.
|
16
24
|
def haml?
|
17
25
|
@current_engine == :haml
|
18
26
|
end
|
19
27
|
|
28
|
+
# @return [Boolean] Returns true if current engine is `:sass`.
|
20
29
|
def sass?
|
21
30
|
@current_engine == :sass
|
22
31
|
end
|
23
32
|
|
33
|
+
# @return [Boolean] Returns true if current engine is `:scss`.
|
24
34
|
def scss?
|
25
35
|
@current_engine == :scss
|
26
36
|
end
|
27
37
|
|
38
|
+
# @return [Boolean] Returns true if current engine is `:less`.
|
28
39
|
def less?
|
29
40
|
@current_engine == :less
|
30
41
|
end
|
31
42
|
|
43
|
+
# @return [Boolean] Returns true if current engine is `:builder`.
|
32
44
|
def builder?
|
33
45
|
@current_engine == :builder
|
34
46
|
end
|
35
47
|
|
48
|
+
# @return [Boolean] Returns true if current engine is `:liquid`.
|
36
49
|
def liquid?
|
37
50
|
@current_engine == :liquid
|
38
51
|
end
|
39
52
|
|
53
|
+
# @return [Boolean] Returns true if current engine is `:markdown`.
|
40
54
|
def markdown?
|
41
55
|
@current_engine == :markdown
|
42
56
|
end
|
43
57
|
|
58
|
+
# @return [Boolean] Returns true if current engine is `:textile.
|
44
59
|
def textile?
|
45
60
|
@current_engine == :textile
|
46
61
|
end
|
47
62
|
|
63
|
+
# @return [Boolean] Returns true if current engine is `:rdoc`.
|
48
64
|
def rdoc?
|
49
65
|
@current_engine == :rdoc
|
50
66
|
end
|
51
67
|
|
68
|
+
# @return [Boolean] Returns true if current engine is `:radius.
|
52
69
|
def radius?
|
53
70
|
@current_engine == :radius
|
54
71
|
end
|
55
72
|
|
73
|
+
# @return [Boolean] Returns true if current engine is `:markaby`.
|
56
74
|
def markaby?
|
57
75
|
@current_engine == :markaby
|
58
76
|
end
|
59
77
|
|
78
|
+
# @return [Boolean] Returns true if current engine is `:coffee`.
|
60
79
|
def coffee?
|
61
80
|
@current_engine == :coffee
|
62
81
|
end
|
63
82
|
|
83
|
+
# @return [Boolean] Returns true if current engine is `:nokogiri`.
|
64
84
|
def nokogiri?
|
65
85
|
@current_engine == :nokogiri
|
66
86
|
end
|
67
87
|
|
88
|
+
# @return [Boolean] Returns true if current engine is `:slim`.
|
68
89
|
def slim?
|
69
90
|
@current_engine == :slim
|
70
91
|
end
|
71
92
|
|
93
|
+
# @return [Boolean] Returns true if current engine is `:creole`.
|
72
94
|
def creole?
|
73
95
|
@current_engine == :creole
|
74
96
|
end
|
@@ -78,6 +100,7 @@ module Sinatra
|
|
78
100
|
super
|
79
101
|
end
|
80
102
|
|
103
|
+
# @param engine [Symbol, String] Name of Engine to shift to.
|
81
104
|
def with_engine(engine)
|
82
105
|
@current_engine, engine_was = engine.to_sym, @current_engine
|
83
106
|
yield
|
data/lib/sinatra/namespace.rb
CHANGED
@@ -318,9 +318,7 @@ module Sinatra
|
|
318
318
|
pattern = nil
|
319
319
|
end
|
320
320
|
base_pattern, base_conditions = @pattern, @conditions
|
321
|
-
pattern
|
322
|
-
base_pattern ||= base.pattern if base.respond_to? :pattern
|
323
|
-
base_conditions ||= base.conditions if base.respond_to? :conditions
|
321
|
+
pattern ||= default_pattern
|
324
322
|
[ prefixed_path(base_pattern, pattern),
|
325
323
|
(base_conditions || {}).merge(conditions) ]
|
326
324
|
end
|
data/lib/sinatra/runner.rb
CHANGED
@@ -2,51 +2,51 @@ require 'open-uri'
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'timeout'
|
4
4
|
|
5
|
-
# NOTE: This feature is experimental, and missing tests!
|
6
|
-
#
|
7
|
-
# Helps you spinning up and shutting down your own sinatra app. This is especially helpful for running
|
8
|
-
# real network tests against a sinatra backend.
|
9
|
-
#
|
10
|
-
# The backend server could look like the following (in test/server.rb).
|
11
|
-
#
|
12
|
-
# require "sinatra"
|
13
|
-
#
|
14
|
-
# get "/" do
|
15
|
-
# "Cheers from test server"
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# get "/ping" do
|
19
|
-
# "1"
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# Note that you need to implement a ping action for internal use.
|
23
|
-
#
|
24
|
-
# Next, you need to write your runner.
|
25
|
-
#
|
26
|
-
# require 'sinatra/runner'
|
27
|
-
#
|
28
|
-
# class Runner < Sinatra::Runner
|
29
|
-
# def app_file
|
30
|
-
# File.expand_path("../server.rb", __FILE__)
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
#
|
34
|
-
# Override Runner#app_file, #command, #port, #protocol and #ping_path for customization.
|
35
|
-
#
|
36
|
-
# **Don't forget to override #app_file specific to your application!**
|
37
|
-
#
|
38
|
-
# Whereever you need this test backend, here's how you manage it. The following example assumes you
|
39
|
-
# have a test in your app that needs to be run against your test backend.
|
40
|
-
#
|
41
|
-
# runner = ServerRunner.new
|
42
|
-
# runner.run
|
43
|
-
#
|
44
|
-
# # ..tests against localhost:4567 here..
|
45
|
-
#
|
46
|
-
# runner.kill
|
47
|
-
#
|
48
|
-
# For an example, check https://github.com/apotonick/roar/blob/master/test/integration/runner.rb
|
49
5
|
module Sinatra
|
6
|
+
# NOTE: This feature is experimental, and missing tests!
|
7
|
+
#
|
8
|
+
# Helps you spinning up and shutting down your own sinatra app. This is especially helpful for running
|
9
|
+
# real network tests against a sinatra backend.
|
10
|
+
#
|
11
|
+
# The backend server could look like the following (in test/server.rb).
|
12
|
+
#
|
13
|
+
# require "sinatra"
|
14
|
+
#
|
15
|
+
# get "/" do
|
16
|
+
# "Cheers from test server"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# get "/ping" do
|
20
|
+
# "1"
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# Note that you need to implement a ping action for internal use.
|
24
|
+
#
|
25
|
+
# Next, you need to write your runner.
|
26
|
+
#
|
27
|
+
# require 'sinatra/runner'
|
28
|
+
#
|
29
|
+
# class Runner < Sinatra::Runner
|
30
|
+
# def app_file
|
31
|
+
# File.expand_path("../server.rb", __FILE__)
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# Override Runner#app_file, #command, #port, #protocol and #ping_path for customization.
|
36
|
+
#
|
37
|
+
# **Don't forget to override #app_file specific to your application!**
|
38
|
+
#
|
39
|
+
# Wherever you need this test backend, here's how you manage it. The following example assumes you
|
40
|
+
# have a test in your app that needs to be run against your test backend.
|
41
|
+
#
|
42
|
+
# runner = ServerRunner.new
|
43
|
+
# runner.run
|
44
|
+
#
|
45
|
+
# # ..tests against localhost:4567 here..
|
46
|
+
#
|
47
|
+
# runner.kill
|
48
|
+
#
|
49
|
+
# For an example, check https://github.com/apotonick/roar/blob/master/test/integration/runner.rb
|
50
50
|
class Runner
|
51
51
|
def app_file
|
52
52
|
File.expand_path("../server.rb", __FILE__)
|
data/lib/sinatra/test_helpers.rb
CHANGED
@@ -10,7 +10,10 @@ require 'forwardable'
|
|
10
10
|
module Sinatra
|
11
11
|
Base.set :environment, :test
|
12
12
|
|
13
|
+
# Helper methods to ease testing your Sinatra application. Partly extracted
|
14
|
+
# from Sinatra. Testing framework agnostic.
|
13
15
|
module TestHelpers
|
16
|
+
# Test variant of session, which exposes a `global_env`.
|
14
17
|
class Session < Rack::Test::Session
|
15
18
|
def global_env
|
16
19
|
@global_env ||= {}
|
@@ -27,11 +30,107 @@ module Sinatra
|
|
27
30
|
extend Forwardable
|
28
31
|
attr_accessor :settings
|
29
32
|
|
33
|
+
# @!group Instance Methods delegated to last_response
|
34
|
+
|
35
|
+
# @!method body
|
36
|
+
#
|
37
|
+
# Body of last_response
|
38
|
+
#
|
39
|
+
# @see http://www.rubydoc.info/github/rack/rack/master/Rack/Response#body-instance_method
|
40
|
+
# @return [String] body of the last response
|
41
|
+
|
42
|
+
# @!method headers
|
43
|
+
#
|
44
|
+
# Headers of last_response
|
45
|
+
#
|
46
|
+
# @return [Hash] hash of the last response
|
47
|
+
|
48
|
+
# @!method status
|
49
|
+
#
|
50
|
+
# HTTP status of last_response
|
51
|
+
#
|
52
|
+
# @return [Integer] HTTP status of the last response
|
53
|
+
|
54
|
+
# @!method errors
|
55
|
+
#
|
56
|
+
# Errors of last_response
|
57
|
+
#
|
58
|
+
# @return [Array] errors of the last response
|
30
59
|
def_delegators :last_response, :body, :headers, :status, :errors
|
60
|
+
# @!endgroup
|
61
|
+
|
62
|
+
# @!group Class Methods delegated to app
|
63
|
+
|
64
|
+
# @!method configure(*envs) {|_self| ... }
|
65
|
+
# @!scope class
|
66
|
+
# @yieldparam _self [Sinatra::Base] the object that the method was called on
|
67
|
+
#
|
68
|
+
# Set configuration options for Sinatra and/or the app. Allows scoping of
|
69
|
+
# settings for certain environments.
|
70
|
+
|
71
|
+
# @!method set(option, value = (not_set = true), ignore_setter = false, &block)
|
72
|
+
# @!scope class
|
73
|
+
# Sets an option to the given value. If the value is a proc, the proc will
|
74
|
+
# be called every time the option is accessed.
|
75
|
+
# @raise [ArgumentError]
|
76
|
+
|
77
|
+
# @!method enable(*opts)
|
78
|
+
# @!scope class
|
79
|
+
#
|
80
|
+
# Same as calling `set :option, true` for each of the given options.
|
81
|
+
|
82
|
+
# @!method disable(*opts)
|
83
|
+
# @!scope class
|
84
|
+
#
|
85
|
+
# Same as calling `set :option, false` for each of the given options.
|
86
|
+
|
87
|
+
# @!method use(middleware, *args, &block)
|
88
|
+
# @!scope class
|
89
|
+
# Use the specified Rack middleware
|
90
|
+
|
91
|
+
# @!method helpers(*extensions, &block)
|
92
|
+
# @!scope class
|
93
|
+
#
|
94
|
+
# Makes the methods defined in the block and in the Modules given in
|
95
|
+
# `extensions` available to the handlers and templates.
|
96
|
+
|
97
|
+
# @!method register(*extensions, &block)
|
98
|
+
# @!scope class
|
99
|
+
# Register an extension. Alternatively take a block from which an
|
100
|
+
# extension will be created and registered on the fly.
|
101
|
+
|
31
102
|
def_delegators :app, :configure, :set, :enable, :disable, :use, :helpers, :register
|
103
|
+
# @!endgroup
|
104
|
+
|
105
|
+
# @!group Instance Methods delegated to current_session
|
106
|
+
|
107
|
+
# @!method env_for(uri = "", opts = {})
|
108
|
+
#
|
109
|
+
# Return the Rack environment used for a request to `uri`.
|
110
|
+
#
|
111
|
+
# @return [Hash]
|
32
112
|
def_delegators :current_session, :env_for
|
113
|
+
# @!endgroup
|
114
|
+
|
115
|
+
# @!group Instance Methods delegated to rack_mock_session
|
116
|
+
# @!method cookie_jar
|
117
|
+
#
|
118
|
+
# Returns a {http://www.rubydoc.info/github/rack-test/rack-test/Rack/Test/CookieJar Rack::Test::CookieJar}.
|
119
|
+
#
|
120
|
+
# @return [Rack::Test::CookieJar]
|
33
121
|
def_delegators :rack_mock_session, :cookie_jar
|
34
122
|
|
123
|
+
# @!endgroup
|
124
|
+
|
125
|
+
# Instantiate and configure a mock Sinatra app.
|
126
|
+
#
|
127
|
+
# Takes a `base` app class, or defaults to Sinatra::Base, and instantiates
|
128
|
+
# an app instance. Any given code in `block` is `class_eval`'d on this new
|
129
|
+
# instance before the instance is returned.
|
130
|
+
#
|
131
|
+
# @param base [Sinatra::Base] App base class
|
132
|
+
#
|
133
|
+
# @return [Sinatra] Configured mocked app
|
35
134
|
def mock_app(base = Sinatra::Base, &block)
|
36
135
|
inner = nil
|
37
136
|
@app = Sinatra.new(base) do
|
@@ -42,18 +141,35 @@ module Sinatra
|
|
42
141
|
app
|
43
142
|
end
|
44
143
|
|
144
|
+
# Replaces the configured app.
|
145
|
+
#
|
146
|
+
# @param base [Sinatra::Base] a configured app
|
45
147
|
def app=(base)
|
46
148
|
@app = base
|
47
149
|
end
|
48
150
|
|
49
151
|
alias set_app app=
|
50
152
|
|
153
|
+
# Returns a Rack::Lint-wrapped Sinatra app.
|
154
|
+
#
|
155
|
+
# If no app has been configured, a new subclass of Sinatra::Base will be
|
156
|
+
# used and stored.
|
157
|
+
#
|
158
|
+
# (Rack::Lint validates your application and the requests and
|
159
|
+
# responses according to the Rack spec.)
|
160
|
+
#
|
161
|
+
# @return [Sinatra::Base]
|
51
162
|
def app
|
52
163
|
@app ||= Class.new Sinatra::Base
|
53
164
|
Rack::Lint.new @app
|
54
165
|
end
|
55
166
|
|
56
167
|
unless method_defined? :options
|
168
|
+
# Processes an OPTIONS request in the context of the current session.
|
169
|
+
#
|
170
|
+
# @param uri [String]
|
171
|
+
# @param params [Hash]
|
172
|
+
# @param env [Hash]
|
57
173
|
def options(uri, params = {}, env = {}, &block)
|
58
174
|
env = env_for(uri, env.merge(:method => "OPTIONS", :params => params))
|
59
175
|
current_session.send(:process_request, uri, env, &block)
|
@@ -61,12 +177,18 @@ module Sinatra
|
|
61
177
|
end
|
62
178
|
|
63
179
|
unless method_defined? :patch
|
180
|
+
# Processes a PATCH request in the context of the current session.
|
181
|
+
#
|
182
|
+
# @param uri [String]
|
183
|
+
# @param params [Hash]
|
184
|
+
# @param env [Hash]
|
64
185
|
def patch(uri, params = {}, env = {}, &block)
|
65
186
|
env = env_for(uri, env.merge(:method => "PATCH", :params => params))
|
66
187
|
current_session.send(:process_request, uri, env, &block)
|
67
188
|
end
|
68
189
|
end
|
69
190
|
|
191
|
+
# @return [Boolean]
|
70
192
|
def last_request?
|
71
193
|
last_request
|
72
194
|
true
|
@@ -74,12 +196,15 @@ module Sinatra
|
|
74
196
|
false
|
75
197
|
end
|
76
198
|
|
199
|
+
# @raise [Rack::Test:Error] If sessions are not enabled for app
|
200
|
+
# @return [Hash] Session of last request, or the empty Hash
|
77
201
|
def session
|
78
202
|
return {} unless last_request?
|
79
203
|
raise Rack::Test::Error, "session not enabled for app" unless last_env["rack.session"] or app.session?
|
80
204
|
last_request.session
|
81
205
|
end
|
82
206
|
|
207
|
+
# @return The env of the last request
|
83
208
|
def last_env
|
84
209
|
last_request.env
|
85
210
|
end
|
data/sinatra-contrib.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "sinatra-contrib"
|
7
7
|
s.version = version
|
8
8
|
s.description = "Collection of useful Sinatra extensions"
|
9
|
-
s.homepage = "http://
|
9
|
+
s.homepage = "http://www.sinatrarb.com/contrib/"
|
10
10
|
s.license = "MIT"
|
11
11
|
s.summary = s.description
|
12
12
|
s.authors = ["https://github.com/sinatra/sinatra/graphs/contributors"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/sinatra/sinatra/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.
|
19
|
+
version: 2.0.1.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.
|
26
|
+
version: 2.0.1.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mustermann
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - '='
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 2.0.
|
81
|
+
version: 2.0.1.rc1
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - '='
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 2.0.
|
88
|
+
version: 2.0.1.rc1
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: multi_json
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -400,7 +400,7 @@ files:
|
|
400
400
|
- lib/sinatra/test_helpers.rb
|
401
401
|
- lib/sinatra/webdav.rb
|
402
402
|
- sinatra-contrib.gemspec
|
403
|
-
homepage: http://
|
403
|
+
homepage: http://www.sinatrarb.com/contrib/
|
404
404
|
licenses:
|
405
405
|
- MIT
|
406
406
|
metadata: {}
|
@@ -415,12 +415,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
415
415
|
version: 2.2.0
|
416
416
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
417
417
|
requirements:
|
418
|
-
- - "
|
418
|
+
- - ">"
|
419
419
|
- !ruby/object:Gem::Version
|
420
|
-
version:
|
420
|
+
version: 1.3.1
|
421
421
|
requirements: []
|
422
422
|
rubyforge_project:
|
423
|
-
rubygems_version: 2.6.
|
423
|
+
rubygems_version: 2.6.8
|
424
424
|
signing_key:
|
425
425
|
specification_version: 4
|
426
426
|
summary: Collection of useful Sinatra extensions
|