rabl 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGZiYTEyMDU5MmE3YjVjODlkNzg5MzcwZDRkZTA2YzRmMDVlMjMzZA==
4
+ ZDMwMmY3ZDU1N2QwN2Y3OGNjZmRlOTljMGRiZGE1NDU3ZjQwYmViNQ==
5
5
  data.tar.gz: !binary |-
6
- ZDY1ZGI4OTY4MGRjODk3ODJhZDZhMjA1ZDViOTI0NWJjMjFhNzc4YQ==
6
+ NzliNzM2YThjMmUxNzg3OTdhYzc5M2FiMmVhNmEwOTljYjBjYWI5Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MTQ5YTlmM2Y2M2RlYTYzNzY4YmVkYjVmZTEzZGE2ODgwODY0NzdlYmEyNmI0
10
- ODQwZjQ2MzgwYmY3ZjI5NGExZTRjODY5YWQwY2JlOGE5OWU0NWYxZTVjNzM4
11
- MjI1YWE4ZGViMTUyMzA4ODM1YTE1MmU0OThhNTc4MDExMjhjN2U=
9
+ OTQ5YWQ4ZjYwNmRiMzc4YmRlYzIyYWZhZTA4Nzk3NzAyMWQxMDNlMzU5ZDdl
10
+ M2JiOTBhYTQxNDUwZjIwZjhhYmQ0ZWMyMDFiYTkyODhkMmU0MWNhMDNjY2Y5
11
+ MGQ3NTAzZDM0YmM0NzUwNmU1YjZjZTRhOTdhNjZmYzI5NjE4ZDA=
12
12
  data.tar.gz: !binary |-
13
- YmQ0NDM2ODQwNzQzZDI4OTQ1N2NkYWNlZDdhMGIzMmMwZmRiYjU1MGM5YTll
14
- ZjQwNWFmMmEwMDU2ZTczZGRkYWRlZDk1Y2MxY2Y3YjEyZTA1OWQwZTc2MmU4
15
- ZmJiMWVmYjVkODFjMWE3NTYxZTFhNmFjOWFkZTliMTkwYjAzMjQ=
13
+ MmRiZjE3ZGYyZjU3M2FlZWViYjkzYjgzZjU4MTU3YjA4Y2JkZjFmNjE0NjA1
14
+ MDcyMTc2M2E2MjgyMGE2ZTI3NWZkN2IyN2MyZWE5MGJiMWM3ZWI4OGQyZDI1
15
+ NmZmMjRmMGE5YWQ3MjE5ODI0N2JkY2IwNDEzZGMwMjUzMWRlOGM=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.10.1 (May 28th)
4
+
5
+ * Fix nasty formatting bug that broke XML (@bhicks)
6
+
3
7
  ## 0.10.0 (May 24th)
4
8
 
5
9
  * Fix typo in readme about new options (@PikachuEXE)
@@ -221,19 +221,18 @@ context "PostsController" do
221
221
  end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash'])[:title] } }
222
222
  end # index action, caching, json
223
223
 
224
- # TODO make this work again
225
- # context "for index action with caching in xml" do
226
- # setup do
227
- # get "/posts", format: :xml
228
- # end
229
-
230
- # asserts("contains post titles") do
231
- # doc = REXML::Document.new topic.body
232
- # doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
233
- # end.equals { @posts.map(&:title) }
234
-
235
- # asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml'] }
236
- # end # index action, caching, xml
224
+ context "for index action with caching in xml" do
225
+ setup do
226
+ get "/posts", format: :xml
227
+ end
228
+
229
+ asserts("contains post titles") do
230
+ doc = REXML::Document.new topic.body
231
+ doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
232
+ end.equals { @posts.map(&:title) }
233
+
234
+ asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml'] }
235
+ end # index action, caching, xml
237
236
 
238
237
  context "for show action with caching" do
239
238
  setup do
@@ -206,19 +206,18 @@ context "PostsController" do
206
206
  end.equals { @posts.map { |p| cache_hit([p, nil, 'hash', 'e373525f49a3b3b044af05255e84839d'])[:title] } }
207
207
  end # index action, caching, json
208
208
 
209
- # TODO make this work again
210
- # context "for index action with caching in xml" do
211
- # setup do
212
- # get "/posts", format: :xml
213
- # end
214
-
215
- # asserts("contains post titles") do
216
- # doc = REXML::Document.new topic.body
217
- # doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
218
- # end.equals { @posts.map(&:title) }
219
-
220
- # asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml', 'e83f65eee5ffb454c418a59105f222c4'] }
221
- # end # index action, caching, xml
209
+ context "for index action with caching in xml" do
210
+ setup do
211
+ get "/posts", format: :xml
212
+ end
213
+
214
+ asserts("contains post titles") do
215
+ doc = REXML::Document.new topic.body
216
+ doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
217
+ end.equals { @posts.map(&:title) }
218
+
219
+ asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml', 'e83f65eee5ffb454c418a59105f222c4'] }
220
+ end # index action, caching, xml
222
221
 
223
222
  context "for show action with caching" do
224
223
  setup do
data/lib/rabl/engine.rb CHANGED
@@ -269,7 +269,6 @@ module Rabl
269
269
  @_options[:extends] = []
270
270
  @_options[:root_name] = nil
271
271
  @_options[:scope] = scope
272
- @_options[:format] ||= self.request_format
273
272
  end
274
273
 
275
274
  # Caches the results of the block based on object cache_key
@@ -315,6 +314,7 @@ module Rabl
315
314
  def set_instance_variables!(scope, locals, &block)
316
315
  @_locals, @_scope = locals, scope
317
316
  self.copy_instance_variables_from(@_scope, [:@assigns, :@helpers])
317
+ @_options[:format] ||= self.request_format
318
318
  set_locals(locals)
319
319
  set_source(locals, &block)
320
320
  end
data/lib/rabl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.10.0"
2
+ VERSION = "0.10.1"
3
3
  end
data/test/engine_test.rb CHANGED
@@ -23,6 +23,30 @@ context "Rabl::Engine" do
23
23
  asserts_topic.assigns :_view_path
24
24
  end
25
25
 
26
+ context "#request_format" do
27
+ context "is json by default" do
28
+ setup do
29
+ template = RablTemplate.new("code") { "" }
30
+ template.render(Object.new)
31
+ engine = template.instance_eval('@engine')
32
+ engine.instance_eval('@_options')[:format]
33
+ end
34
+
35
+ asserts_topic.equals('json')
36
+ end
37
+
38
+ context "with a specified format" do
39
+ setup do
40
+ template = RablTemplate.new("code", format: 'xml') { "" }
41
+ template.render(Object.new)
42
+ engine = template.instance_eval('@engine')
43
+ engine.instance_eval('@_options')[:format]
44
+ end
45
+
46
+ asserts_topic.equals('xml')
47
+ end
48
+ end
49
+
26
50
  context "#cache" do
27
51
  context "with cache" do
28
52
  setup do
@@ -221,19 +221,18 @@ context "PostsController" do
221
221
  end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash'])[:title] } }
222
222
  end # index action, caching, json
223
223
 
224
- # TODO make this work again
225
- # context "for index action with caching in xml" do
226
- # setup do
227
- # get "/posts", format: :xml
228
- # end
229
-
230
- # asserts("contains post titles") do
231
- # doc = REXML::Document.new topic.body
232
- # doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
233
- # end.equals { @posts.map(&:title) }
234
-
235
- # asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml'] }
236
- # end # index action, caching, xml
224
+ context "for index action with caching in xml" do
225
+ setup do
226
+ get "/posts", format: :xml
227
+ end
228
+
229
+ asserts("contains post titles") do
230
+ doc = REXML::Document.new topic.body
231
+ doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
232
+ end.equals { @posts.map(&:title) }
233
+
234
+ asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml'] }
235
+ end # index action, caching, xml
237
236
 
238
237
  context "for show action with caching" do
239
238
  setup do
@@ -206,19 +206,18 @@ context "PostsController" do
206
206
  end.equals { @posts.map { |p| cache_hit([p, nil, 'hash', 'e373525f49a3b3b044af05255e84839d'])[:title] } }
207
207
  end # index action, caching, json
208
208
 
209
- # TODO make this work again
210
- # context "for index action with caching in xml" do
211
- # setup do
212
- # get "/posts", format: :xml
213
- # end
214
-
215
- # asserts("contains post titles") do
216
- # doc = REXML::Document.new topic.body
217
- # doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
218
- # end.equals { @posts.map(&:title) }
219
-
220
- # asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml', 'e83f65eee5ffb454c418a59105f222c4'] }
221
- # end # index action, caching, xml
209
+ context "for index action with caching in xml" do
210
+ setup do
211
+ get "/posts", format: :xml
212
+ end
213
+
214
+ asserts("contains post titles") do
215
+ doc = REXML::Document.new topic.body
216
+ doc.elements.inject('articles/article/title', []) {|arr, ele| arr << ele.text}
217
+ end.equals { @posts.map(&:title) }
218
+
219
+ asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'xml', 'e83f65eee5ffb454c418a59105f222c4'] }
220
+ end # index action, caching, xml
222
221
 
223
222
  context "for show action with caching" do
224
223
  setup do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-24 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -152,7 +152,6 @@ files:
152
152
  - MIT-LICENSE
153
153
  - README.md
154
154
  - Rakefile
155
- - TODO
156
155
  - examples/base.json.rabl
157
156
  - examples/demo.json.rabl
158
157
  - examples/inherited.json.rabl
data/TODO DELETED
@@ -1 +0,0 @@
1
- = TODO