scorched 1.1.0 → 1.1.1
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/CHANGES.md +2 -0
- data/docs/02_fundamentals/03_routing.md +1 -1
- data/docs/02_fundamentals/05_filters.md +19 -0
- data/lib/scorched/controller.rb +2 -1
- data/lib/scorched/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e9063c14895226f457fcb9255e206f5915a8aaefde84be0114dabbf4723a677
|
|
4
|
+
data.tar.gz: e773ac700d17abe3b3ce00f94be2665e4753bacffee9ce07fc4e86a00f35afec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2444d1752e6296881377c74c21a6219b19b9ef415165e89382d4b9f3d80b8e7030c5997cf8fcffeb6377c5f58cd96431019f170ee75577210564798b61514764
|
|
7
|
+
data.tar.gz: 61dae3a5d9f0d4d35d53be9db55c157d0e0cbdeee1bcf504a0d9069fa674ad993e95c865ddcf8165d78ed5c2dd1f567184baecc1be90f69017d329f79642e75c
|
data/CHANGES.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
### v1.1.1
|
|
5
|
+
* Fixed frozen string mutation in `absolute` method.
|
|
4
6
|
### v1.1.0
|
|
5
7
|
* Added `around` filters to allow wrapping application logic around a request. `around` filters wrap around `before/after` filters. Ideal for `begin...ensure...end` where you need to ensure something happens before the request processing ends. For example:
|
|
6
8
|
```
|
|
@@ -117,7 +117,7 @@ Conditions are essentially just pre-requisites that must be met before a mapping
|
|
|
117
117
|
* `:host` - The host name (i.e. domain name) used in the request.
|
|
118
118
|
* `:language` - Languages accepted by the client.
|
|
119
119
|
* `:media_type` - Media types (i.e. content types) accepted by the client.
|
|
120
|
-
* `:
|
|
120
|
+
* `:dispatched` - Whether a mapping in the controller instance was invoked as the target for the request. A mapping that _passes_ a request is not considered dispatched.
|
|
121
121
|
* `:method` - The request method used, e.g. GET, POST, PUT, ... .
|
|
122
122
|
* `:proc` - An on-the-fly condition to be evaluated in the context of the controller instance. Should return true if the condition was satisfied, or false otherwise.
|
|
123
123
|
* `:user_agent` - The user agent string provided with the request. Takes a Regexp or String.
|
|
@@ -42,6 +42,25 @@ end
|
|
|
42
42
|
How you use filters is up to your own imagination and creative problem solving.
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
Around Filters
|
|
46
|
+
--------------
|
|
47
|
+
Around filters wrap the entire before/dispatch/after cycle. The block is passed a single argument - a proc representing the rest of the filter chain - which it must call (e.g. `cont.call`) for request handling to proceed. If the block doesn't call it, the wrapped request chain never runs.
|
|
48
|
+
|
|
49
|
+
Around filters defined earlier (including those defined in superclasses) wrap those defined later. Around filters are ideal for `begin...ensure...end`-style wrapping, where you need to guarantee something happens once the request has finished processing.
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
around do |cont|
|
|
53
|
+
begin
|
|
54
|
+
cont.call
|
|
55
|
+
ensure
|
|
56
|
+
# Ensure something important happens here
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Like before and after filters, around filters can have conditions defined on them.
|
|
62
|
+
|
|
63
|
+
|
|
45
64
|
Error Filters
|
|
46
65
|
-------------
|
|
47
66
|
Error filters are processed like regular filters, except they're called whenever an exception occurs. If an error filter returns false, it's assumed to be unhandled, and the next error filter is called. This continues until one of the following is true, 1) an error filter returns true, in which case the exception is assumed to be handled, 2) an error filter raises an exception itself, or 3) there are no more error handlers defined on the current controller, in which case the exception is re-raised.
|
data/lib/scorched/controller.rb
CHANGED
|
@@ -573,9 +573,10 @@ module Scorched
|
|
|
573
573
|
else
|
|
574
574
|
env['scorched.root_path']
|
|
575
575
|
end
|
|
576
|
-
abs
|
|
576
|
+
abs = "/#{abs}" unless abs[0] == '/'
|
|
577
577
|
abs
|
|
578
578
|
end
|
|
579
|
+
|
|
579
580
|
|
|
580
581
|
# We always want this filter to run at the end-point controller, hence we include the conditions within the body of
|
|
581
582
|
# the filter.
|
data/lib/scorched/version.rb
CHANGED