roda 2.8.0 → 2.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49da3db12f5573c87c6be816d293503ff794ea2f
4
- data.tar.gz: 443753193002f7e346437cd50ed50eab168e8f25
3
+ metadata.gz: db1595b9c872a259412f3038f5a0fb2840eeb3cf
4
+ data.tar.gz: f2b1ccafbdbbe5555ba7267aaa51711be0ea0f4e
5
5
  SHA512:
6
- metadata.gz: c0be145864376662bc858c903c9d4a1865b184b782b2b3f0494c0e85f168de74f44fe8c58f7398e6c1236cbbf9f280a22c3658bdf8a83f0018c6a9af45a1dc62
7
- data.tar.gz: 79911454fded94aaf16e48ed958c0ebfaf7d0bb5e3be9e22e0740b71eb21f5acabf949eff65eba5314a0b67dfeca13b84e4037484efff44fbc7d6d382061115b
6
+ metadata.gz: 584b93e1c7fad7764b37835c5a902ae0fa6549eadd180792db2cdb8bcd6ddcccf6e1c0292e3962e0960e5f491dae6807308f76534a9e51f66698b62e3d794def
7
+ data.tar.gz: 47869cb66d33806d615dae3046dd0b372532811c00456c839e781d5e57912dcec6c09161f8802a66a37d401fa4dd685dc00327ce1389555ce20dee84419d406b
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ = 2.9.0 (2015-12-15)
2
+
3
+ * Support passing the content as a string argument instead of a block in the content_for plugin (badosu) (#52)
4
+
1
5
  = 2.8.0 (2015-11-16)
2
6
 
3
7
  * Add multi_view plugin for easily setting up routing for rendering multiple views (jeremyevans)
data/README.rdoc CHANGED
@@ -759,7 +759,7 @@ application level using using the +default_headers+ plugin:
759
759
 
760
760
  Content-Security-Policy/X-Content-Security-Policy :: Defines policy for how javascript and other
761
761
  types of content can be used on the page.
762
- Frame-Options/X-Frame-Options :: Provides click-jacking projection by not allowing usage inside
762
+ Frame-Options/X-Frame-Options :: Provides click-jacking protection by not allowing usage inside
763
763
  a frame.
764
764
  Strict-Transport-Security :: Enforces SSL/TLS Connections to the application.
765
765
  X-Content-Type-Options :: Forces some browsers to respect a declared Content-Type header.
@@ -0,0 +1,6 @@
1
+ = New Features
2
+
3
+ * The content_for plugin now supports passing the content as a
4
+ string argument instead of a block:
5
+
6
+ <% content_for :foo, "Some content" %>
@@ -14,6 +14,11 @@ class Roda
14
14
  # Some content here.
15
15
  # <% end %>
16
16
  #
17
+ # You can also set the raw content as the second argument,
18
+ # instead of passing a block:
19
+ #
20
+ # <% content_for :foo, "Some content" %>
21
+ #
17
22
  # In the template in which you want to retrieve content,
18
23
  # call content_for without the block:
19
24
  #
@@ -30,7 +35,7 @@ class Roda
30
35
  # under the given key. If called without a block, retrieve
31
36
  # stored content with the given key, or return nil if there
32
37
  # is no content stored with that key.
33
- def content_for(key, &block)
38
+ def content_for(key, value=nil, &block)
34
39
  if block
35
40
  outvar = render_opts[:template_opts][:outvar]
36
41
  buf_was = instance_variable_get(outvar)
@@ -41,6 +46,9 @@ class Roda
41
46
  @_content_for[key] = Tilt[render_opts[:engine]].new(&block).render
42
47
 
43
48
  instance_variable_set(outvar, buf_was)
49
+ elsif value
50
+ @_content_for ||= {}
51
+ @_content_for[key] = value
44
52
  elsif @_content_for
45
53
  @_content_for[key]
46
54
  end
@@ -60,9 +60,7 @@ class Roda
60
60
  # In all cases where it uses a 405 response, it also sets the +Allow+
61
61
  # header in the response to contain the request methods supported.
62
62
  #
63
- # This plugin depends on the all_verbs plugin. It works by overriding
64
- # the verb methods, so it wouldn't work if loaded after the all_verbs
65
- # plugin.
63
+ # This plugin depends on the all_verbs plugin.
66
64
  module NotAllowed
67
65
  # Depend on the all_verbs plugin, as this plugin overrides methods
68
66
  # defined by it and calls super.
data/lib/roda/version.rb CHANGED
@@ -4,7 +4,7 @@ class Roda
4
4
  RodaMajorVersion = 2
5
5
 
6
6
  # The minor version of Roda, updated for new feature releases of Roda.
7
- RodaMinorVersion = 8
7
+ RodaMinorVersion = 9
8
8
 
9
9
  # The patch version of Roda, updated only for bug fixes from the last
10
10
  # feature release.
@@ -19,6 +19,9 @@ describe "content_for plugin with erb" do
19
19
  r.get 'a' do
20
20
  view(:inline => "bar", :layout => { :inline => '<%= content_for(:foo) %> <%= yield %>' })
21
21
  end
22
+ r.get 'b' do
23
+ view(:inline => '<% content_for(:foo, "foo") %>bar', :layout => { :inline => '<%= yield %> <%= content_for(:foo) %>' })
24
+ end
22
25
  end
23
26
  end
24
27
  end
@@ -30,6 +33,10 @@ describe "content_for plugin with erb" do
30
33
  it "should work if content is not set by the template" do
31
34
  body('/a').strip.must_equal "bar"
32
35
  end
36
+
37
+ it "should work if a raw string is set" do
38
+ body('/b').strip.must_equal "bar foo"
39
+ end
33
40
  end
34
41
 
35
42
  describe "content_for plugin with haml" do
@@ -42,12 +49,16 @@ describe "content_for plugin with haml" do
42
49
  r.root do
43
50
  view(:inline => "- content_for :foo do\n - capture_haml do\n foo\nbar", :layout => { :inline => "= yield\n=content_for :foo" })
44
51
  end
52
+ r.get 'a' do
53
+ view(:inline => "- content_for :foo, 'foo'\nbar", :layout => { :inline => "= yield\n=content_for :foo" })
54
+ end
45
55
  end
46
56
  end
47
57
  end
48
58
 
49
59
  it "should work with alternate rendering engines" do
50
60
  body.strip.must_equal "bar\nfoo"
61
+ body('/a').strip.must_equal "bar\nfoo"
51
62
  end
52
63
  end
53
64
 
@@ -61,12 +72,16 @@ describe "content_for plugin with mixed template engines" do
61
72
  r.root do
62
73
  view(:inline => "<% content_for :foo do %>foo<% end %>bar")
63
74
  end
75
+ r.get 'a' do
76
+ view(:inline => "<% content_for :foo, 'foo' %>bar")
77
+ end
64
78
  end
65
79
  end
66
80
  end
67
81
 
68
82
  it "should work with alternate rendering engines" do
69
83
  body.strip.must_equal "bar\nfoo"
84
+ body('/a').strip.must_equal "bar\nfoo"
70
85
  end
71
86
  end
72
87
 
@@ -80,12 +95,16 @@ describe "content_for plugin when overriding :engine" do
80
95
  r.root do
81
96
  view(:inline => "<% content_for :foo do %>foo<% end %>bar", :engine=>:erb)
82
97
  end
98
+ r.get 'a' do
99
+ view(:inline => "<% content_for :foo, 'foo' %>bar", :engine=>:erb)
100
+ end
83
101
  end
84
102
  end
85
103
  end
86
104
 
87
105
  it "should work with alternate rendering engines" do
88
106
  body.strip.must_equal "bar\nfoo"
107
+ body('/a').strip.must_equal "bar\nfoo"
89
108
  end
90
109
  end
91
110
  end
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.8.0
4
+ version: 2.9.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: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -174,6 +174,7 @@ extra_rdoc_files:
174
174
  - doc/release_notes/2.6.0.txt
175
175
  - doc/release_notes/2.7.0.txt
176
176
  - doc/release_notes/2.8.0.txt
177
+ - doc/release_notes/2.9.0.txt
177
178
  files:
178
179
  - CHANGELOG
179
180
  - MIT-LICENSE
@@ -194,6 +195,7 @@ files:
194
195
  - doc/release_notes/2.6.0.txt
195
196
  - doc/release_notes/2.7.0.txt
196
197
  - doc/release_notes/2.8.0.txt
198
+ - doc/release_notes/2.9.0.txt
197
199
  - lib/roda.rb
198
200
  - lib/roda/plugins/_erubis_escaping.rb
199
201
  - lib/roda/plugins/all_verbs.rb