rabl 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.6.7
4
+
5
+ * Fix format to default to json in the event that it is a 'hash' (Thanks @databyte)
6
+ * Support using cache keys within extended templates (Thanks @databyte)
7
+
3
8
  ## 0.6.6
4
9
 
5
10
  * Even more improvements to Rails template resolution (Thanks @databyte)
@@ -1,4 +1,4 @@
1
- +#!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
3
 
4
4
  APP_PATH = File.expand_path('../../config/application', __FILE__)
@@ -144,6 +144,10 @@ context "PostsController" do
144
144
  end.equals { @posts.map(&:title) }
145
145
 
146
146
  asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'json'] }
147
+
148
+ asserts("contains cache hits per object (posts by title)") do
149
+ json_output['articles'].map { |o| o['article']['title'] }
150
+ end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash'])[:title] } }
147
151
  end # index action, caching, json
148
152
 
149
153
  context "for index action with caching in xml" do
data/lib/rabl/builder.rb CHANGED
@@ -127,7 +127,8 @@ module Rabl
127
127
  # Returns a guess at the format in this scope
128
128
  # request_format => "xml"
129
129
  def request_format
130
- @options[:format] if @options[:format] != "hash"
130
+ format = @options[:format]
131
+ format && format != "hash" ? format : 'json'
131
132
  end
132
133
 
133
134
  # Caches the results of the block based on object cache_key
data/lib/rabl/engine.rb CHANGED
@@ -121,6 +121,7 @@ module Rabl
121
121
  # cache 'user', expires_in: 1.hour
122
122
  # options is passed through to the cache store
123
123
  def cache(key, options = nil)
124
+ key ||= @_data # if called but missing, use object
124
125
  @_cache = [key, options]
125
126
  end
126
127
 
data/lib/rabl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
@@ -144,6 +144,10 @@ context "PostsController" do
144
144
  end.equals { @posts.map(&:title) }
145
145
 
146
146
  asserts(:body).equals { cache_hit ['kittens!', @posts, nil, 'json'] }
147
+
148
+ asserts("contains cache hits per object (posts by title)") do
149
+ json_output['articles'].map { |o| o['article']['title'] }
150
+ end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash'])[:title] } }
147
151
  end # index action, caching, json
148
152
 
149
153
  context "for index action with caching in xml" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.6
5
+ version: 0.6.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nathan Esquenazi
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-03-31 00:00:00 Z
13
+ date: 2012-04-04 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport