scorched 0.11 → 0.11.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/Milestones.md +4 -0
- data/docs/02_fundamentals/03_routing.md +8 -6
- data/lib/scorched/controller.rb +3 -2
- data/lib/scorched/version.rb +1 -1
- data/scorched.gemspec +1 -1
- data/spec/controller_spec.rb +5 -1
- data/spec/views/composer.erb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 215f4c437938c37e309b465ec6fd685887e41fd5
|
4
|
+
data.tar.gz: 38795c31fe7f0395a78ebddc403e2fef586dcd9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4117536f2e361a2c432b49386f2def80528340d4d28055a50e5713e316fecdeffd93b2daa843af8dfdb8df447eb38b5379fa7fa7fc4253518ba7ad3129213829
|
7
|
+
data.tar.gz: 70dab536b62e324347442e19ca08fc7a13c02e7102d5fcdb051a41e32aa3c3286d008bf3fdea73b0f508360ce5cbc9cb1989d9401e1928b63c3705c2351cd725
|
data/Milestones.md
CHANGED
@@ -3,6 +3,10 @@ Milestones
|
|
3
3
|
|
4
4
|
Changelog
|
5
5
|
---------
|
6
|
+
### v0.11.1
|
7
|
+
* Fixed issue where multiple nested render calls would incorrectly render the layout (issue #9).
|
8
|
+
* Bumped Tilt dependancy to v1.4 and removed work-around for Tilt encoding issue.
|
9
|
+
|
6
10
|
### v0.11
|
7
11
|
* Route wildcards '*' and '**' (and their named equivalents) now match zero or more characters, instead of one or more. This means `/*` will now match both `/` and `/about` for example.
|
8
12
|
* Conditions can now be inverted by appending an exclamation mark to the condition, e.g. `method!: 'GET'` matches all HTTP methods, excluding GET.
|
@@ -19,7 +19,7 @@ Route Helpers
|
|
19
19
|
-------------
|
20
20
|
Adding mappings manually can be a little verbose and painful, which is why Scorched includes a bunch of route helpers which are used in most code examples.
|
21
21
|
|
22
|
-
The main route helper which all others delegate to, is the `route` class method. Here's what it looks like in both it's simple and advance
|
22
|
+
The main route helper which all others delegate to, is the `route` class method. Here's what it looks like in both it's simple and advance forms:
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
route '/' do
|
@@ -53,10 +53,10 @@ Patterns can be defined as either a String or Regexp.
|
|
53
53
|
###String Patterns
|
54
54
|
String patterns are compiled into Regexp patterns corresponding to the following rules:
|
55
55
|
|
56
|
-
* `*` - Matches
|
57
|
-
* `**` - Matches
|
58
|
-
* `:param` - Same as `*` except the capture is named to whatever the string following the single-colon
|
59
|
-
* `::param` - Same as `**` except the capture is named to whatever the string following the double-colon
|
56
|
+
* `*` - Matches zero or more characters, excluding the forward slash.
|
57
|
+
* `**` - Matches zero or more characters, including the forward slash.
|
58
|
+
* `:param` - Same as `*` except the capture is named to whatever the string following the single-colon.
|
59
|
+
* `::param` - Same as `**` except the capture is named to whatever the string following the double-colon.
|
60
60
|
* `$` - If placed at the end of a pattern, the pattern only matches if it matches the entire path. For patterns defined using the route helpers, e.g. `Controller.route`, `Controller.get`, this is implied.
|
61
61
|
|
62
62
|
###Regex Patterns
|
@@ -65,7 +65,7 @@ Regex patterns offer more power and flexibility than string patterns (naturally)
|
|
65
65
|
|
66
66
|
Conditions
|
67
67
|
----------
|
68
|
-
Conditions are essentially just pre-requisites that must be met before a mapping is invoked to handle the current request. They're implemented as `Proc` objects which take a single argument, and return true if the condition is satisfied, or false otherwise. Scorched comes with a number of pre-defined conditions included,
|
68
|
+
Conditions are essentially just pre-requisites that must be met before a mapping is invoked to handle the current request. They're implemented as `Proc` objects which take a single argument, and return true if the condition is satisfied, or false otherwise. Scorched comes with a number of pre-defined conditions included, some of which use functionality provided by _rack-accept_ - one of the few dependancies of Scorched.
|
69
69
|
|
70
70
|
* `:charset` - Character sets accepted by the client.
|
71
71
|
* `:config` - Takes a hash, each element of which must match the value of the corresponding config option.
|
@@ -80,6 +80,8 @@ Conditions are essentially just pre-requisites that must be met before a mapping
|
|
80
80
|
* `:user_agent` - The user agent string provided with the request. Takes a Regexp or String.
|
81
81
|
* `:status` - The response status of the request. Intended for use by _after_ filters.
|
82
82
|
|
83
|
+
As of v0.11, Scorched also supports inverted/negated conditions by adding a trailing exclamation mark. For example, a route with the condition `method!: 'GET'` will match any HTTP request except for `GET` requests.
|
84
|
+
|
83
85
|
Like configuration options, conditions are implemented using the `Scorched::Options` class, so they're inherited and can be overridden by child classes. You may easily add your own conditions as the example below demonstrates.
|
84
86
|
|
85
87
|
```ruby
|
data/lib/scorched/controller.rb
CHANGED
@@ -400,7 +400,7 @@ module Scorched
|
|
400
400
|
file = File.join(dir, file) if dir
|
401
401
|
# Tilt still has unresolved file encoding issues. Until that's fixed, we read the file manually.
|
402
402
|
template_cache.fetch(:file, tilt_engine, file, tilt_options) do
|
403
|
-
tilt_engine.new(
|
403
|
+
tilt_engine.new(file, nil, tilt_options)
|
404
404
|
end
|
405
405
|
else
|
406
406
|
template_cache.fetch(:string, tilt_engine, string_or_file, tilt_options) do
|
@@ -410,10 +410,11 @@ module Scorched
|
|
410
410
|
|
411
411
|
# The following chunk of code is responsible for preventing the rendering of layouts within views.
|
412
412
|
begin
|
413
|
+
original_no_default_layout = @_no_default_layout
|
413
414
|
@_no_default_layout = true
|
414
415
|
output = template.render(self, locals, &block)
|
415
416
|
ensure
|
416
|
-
@_no_default_layout =
|
417
|
+
@_no_default_layout = original_no_default_layout
|
417
418
|
end
|
418
419
|
|
419
420
|
if layout
|
data/lib/scorched/version.rb
CHANGED
data/scorched.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new 'scorched', Scorched::VERSION do |s|
|
|
15
15
|
|
16
16
|
s.add_dependency 'rack', '~> 1.4'
|
17
17
|
s.add_dependency 'rack-accept', '~> 0.4'
|
18
|
-
s.add_dependency 'tilt', '~> 1.
|
18
|
+
s.add_dependency 'tilt', '~> 1.4'
|
19
19
|
s.add_development_dependency 'rack-test', '~> 0.6'
|
20
20
|
s.add_development_dependency 'rspec', '~> 2.9'
|
21
21
|
end
|
data/spec/controller_spec.rb
CHANGED
@@ -715,6 +715,10 @@ module Scorched
|
|
715
715
|
File.open('views/temp.str', 'w') { |f| f.write 'hello world' }
|
716
716
|
end
|
717
717
|
|
718
|
+
after(:all) {
|
719
|
+
File.unlink 'views/temp.str'
|
720
|
+
}
|
721
|
+
|
718
722
|
it "can cache templates" do
|
719
723
|
app.config[:cache_templates] = true
|
720
724
|
app.get('/') { render :'temp.str' }
|
@@ -890,7 +894,7 @@ module Scorched
|
|
890
894
|
app.get('/') do
|
891
895
|
render :composer
|
892
896
|
end
|
893
|
-
rt.get('/').body.should == '({1 for none})'
|
897
|
+
rt.get('/').body.should == '({1 for none}{1 for none})'
|
894
898
|
end
|
895
899
|
|
896
900
|
it "can pass local variables through to view" do
|
data/spec/views/composer.erb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{<%= render :partial %>}
|
1
|
+
{<%= render :partial %>}{<%= render :partial %>}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scorched
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Wardrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack-test
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.0.
|
157
|
+
rubygems_version: 2.0.3
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Light-weight, DRY as a desert, web framework for Ruby
|