rabl 0.9.0.pre3 → 0.9.0.pre4
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 +8 -8
- data/CHANGELOG.md +4 -0
- data/fixtures/ashared/views_rails_3/posts/renderer.rabl +4 -0
- data/fixtures/ashared/views_rails_3/posts/renderer_partial.rabl +4 -0
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +4 -0
- data/fixtures/rails4/test/functional/posts_controller_test.rb +5 -1
- data/lib/rabl/digestor.rb +1 -1
- data/lib/rabl/engine.rb +2 -2
- data/lib/rabl/partials.rb +2 -7
- data/lib/rabl/renderer.rb +2 -1
- data/lib/rabl/version.rb +1 -1
- data/test/engine_test.rb +1 -1
- data/test/integration/rails3_2/posts_controller_test.rb +4 -0
- data/test/integration/rails4/posts_controller_test.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjA4NTM5ZDI5ZjQ3YTg5MGVjNjRiODY2YTM2OTRmZmI5OGM2NmRjZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTM5MWM4MjRkOGExNTJkNDgzZWYyYzhmMjc5MTY3ODFjNDYxYTU1NA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmFlODc5NjdkYzEyZGJhZDhkODQ2NTczNTFkZTk0ZTk0OGRlZGQ3NmNiYmI1
|
10
|
+
OTNhNjBkOTQxMDM5ZTM0ODJiMTY5NmE5MzZmY2M0NTBmZDhmMzc5NjY3MDUy
|
11
|
+
NDY2NDRjMDFkZjA2ZGIxMDNlM2NkNWVlMjBkZmYyMGNjNGQwNTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGZhNjI0MjU5ZjU2OTljMjkxZGIyZTA5NzFjYTE3ODcyYWI5Yzk0YzIyZGZj
|
14
|
+
MTZkZjhkNjAyNmZmMWQ0ZWIzZGY5ZWVlM2U4MmUxMTM0M2FmYTJkNTQxYWUz
|
15
|
+
NTllOGZjZjZhZWI2Y2E1OGE4ZDliYzFiYWFiOTYzZTFjZGIyODk=
|
data/CHANGELOG.md
CHANGED
@@ -149,6 +149,10 @@ context "PostsController" do
|
|
149
149
|
# Attributes (regular)
|
150
150
|
asserts("contains post title") { topic['title'] }.equals { @post1.title }
|
151
151
|
asserts("contains post body") { topic['body'] }.equals { @post1.body }
|
152
|
+
|
153
|
+
# Attributes (partial)
|
154
|
+
asserts("contains post partial title") { topic['partial']['title'] }.equals { @post1.title }
|
155
|
+
asserts("contains post partial body") { topic['partial']['body'] }.equals { @post1.body }
|
152
156
|
end # renderer action, json
|
153
157
|
|
154
158
|
context "for index action rendering JSON within HTML" do
|
@@ -149,6 +149,10 @@ context "PostsController" do
|
|
149
149
|
# Attributes (regular)
|
150
150
|
asserts("contains post title") { topic['title'] }.equals { @post1.title }
|
151
151
|
asserts("contains post body") { topic['body'] }.equals { @post1.body }
|
152
|
+
|
153
|
+
# Attributes (partial)
|
154
|
+
asserts("contains post partial title") { topic['partial']['title'] }.equals { @post1.title }
|
155
|
+
asserts("contains post partial body") { topic['partial']['body'] }.equals { @post1.body }
|
152
156
|
end # renderer action, json
|
153
157
|
|
154
158
|
context "for index action rendering JSON within HTML" do
|
@@ -199,7 +203,7 @@ context "PostsController" do
|
|
199
203
|
|
200
204
|
asserts("contains cache hits per object (posts by title)") do
|
201
205
|
json_output['articles'].map { |o| o['article']['title'] }
|
202
|
-
end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash', '
|
206
|
+
end.equals { @posts.map { |p| cache_hit([p, nil, 'hash', 'e373525f49a3b3b044af05255e84839d'])[:title] } }
|
203
207
|
end # index action, caching, json
|
204
208
|
|
205
209
|
context "for index action with caching in xml" do
|
data/lib/rabl/digestor.rb
CHANGED
@@ -12,7 +12,7 @@ module Rabl
|
|
12
12
|
private
|
13
13
|
def dependency_digest
|
14
14
|
template_digests = dependencies.collect do |template_name|
|
15
|
-
Digestor.digest(template_name, format, finder
|
15
|
+
Digestor.digest(template_name, format, finder)
|
16
16
|
end
|
17
17
|
|
18
18
|
(template_digests + injected_dependencies).join("-")
|
data/lib/rabl/engine.rb
CHANGED
@@ -287,11 +287,11 @@ module Rabl
|
|
287
287
|
end
|
288
288
|
|
289
289
|
def cache_key_with_digest(cache_key)
|
290
|
-
|
290
|
+
template = @_options[:template] || @virtual_path
|
291
291
|
Array(cache_key) + [
|
292
292
|
@_options[:root_name],
|
293
293
|
@_options[:format],
|
294
|
-
Digestor.digest(
|
294
|
+
Digestor.digest(template, :rabl, lookup_context)
|
295
295
|
]
|
296
296
|
end
|
297
297
|
|
data/lib/rabl/partials.rb
CHANGED
@@ -10,7 +10,7 @@ module Rabl
|
|
10
10
|
raise ArgumentError, "Must provide an :object option to render a partial" unless options.has_key?(:object)
|
11
11
|
object, view_path = options.delete(:object), options[:view_path] || @_view_path
|
12
12
|
source, location = self.fetch_source(file, :view_path => view_path)
|
13
|
-
engine_options = options.merge(:source => source, :source_location => location)
|
13
|
+
engine_options = options.merge(:source => source, :source_location => location, :template => file)
|
14
14
|
self.object_to_hash(object, engine_options, &block)
|
15
15
|
end
|
16
16
|
|
@@ -43,16 +43,11 @@ module Rabl
|
|
43
43
|
fetch_manual_template(view_paths, file)
|
44
44
|
end
|
45
45
|
|
46
|
-
# being used by cache digestor
|
47
|
-
if defined?(Rails) && Rails.version =~ /^[4]/
|
48
|
-
@_virtual_path = file_path.gsub('app/views/', '').gsub('.rabl', '')
|
49
|
-
end
|
50
|
-
|
51
46
|
unless File.exist?(file_path.to_s)
|
52
47
|
raise "Cannot find rabl template '#{file}' within registered (#{view_paths.map(&:to_s).inspect}) view paths!"
|
53
48
|
end
|
54
49
|
|
55
|
-
[File.read(file_path.to_s), file_path.to_s]
|
50
|
+
[File.read(file_path.to_s), file_path.to_s]
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
data/lib/rabl/renderer.rb
CHANGED
data/lib/rabl/version.rb
CHANGED
data/test/engine_test.rb
CHANGED
@@ -379,7 +379,7 @@ context "Rabl::Engine" do
|
|
379
379
|
scope.instance_variable_set :@user, @user
|
380
380
|
any_instance_of(Rabl::Engine) do |b|
|
381
381
|
mock(b).fetch_source("foo/bar", :view_path => nil).once
|
382
|
-
mock(b).object_to_hash(@user, :locals => { :foo => "bar" }, :source => nil, :source_location => nil).returns({ :name => 'leo', :city => 'LA', :age => 12 })
|
382
|
+
mock(b).object_to_hash(@user, :locals => { :foo => "bar" }, :source => nil, :source_location => nil, :template => 'foo/bar').returns({ :name => 'leo', :city => 'LA', :age => 12 })
|
383
383
|
end
|
384
384
|
JSON.parse(template.render(scope))
|
385
385
|
end.equals JSON.parse("{ \"foo\" : {\"name\":\"leo\",\"city\":\"LA\",\"age\":12} }")
|
@@ -149,6 +149,10 @@ context "PostsController" do
|
|
149
149
|
# Attributes (regular)
|
150
150
|
asserts("contains post title") { topic['title'] }.equals { @post1.title }
|
151
151
|
asserts("contains post body") { topic['body'] }.equals { @post1.body }
|
152
|
+
|
153
|
+
# Attributes (partial)
|
154
|
+
asserts("contains post partial title") { topic['partial']['title'] }.equals { @post1.title }
|
155
|
+
asserts("contains post partial body") { topic['partial']['body'] }.equals { @post1.body }
|
152
156
|
end # renderer action, json
|
153
157
|
|
154
158
|
context "for index action rendering JSON within HTML" do
|
@@ -149,6 +149,10 @@ context "PostsController" do
|
|
149
149
|
# Attributes (regular)
|
150
150
|
asserts("contains post title") { topic['title'] }.equals { @post1.title }
|
151
151
|
asserts("contains post body") { topic['body'] }.equals { @post1.body }
|
152
|
+
|
153
|
+
# Attributes (partial)
|
154
|
+
asserts("contains post partial title") { topic['partial']['title'] }.equals { @post1.title }
|
155
|
+
asserts("contains post partial body") { topic['partial']['body'] }.equals { @post1.body }
|
152
156
|
end # renderer action, json
|
153
157
|
|
154
158
|
context "for index action rendering JSON within HTML" do
|
@@ -199,7 +203,7 @@ context "PostsController" do
|
|
199
203
|
|
200
204
|
asserts("contains cache hits per object (posts by title)") do
|
201
205
|
json_output['articles'].map { |o| o['article']['title'] }
|
202
|
-
end.equals { @posts.map{ |p| cache_hit([p, nil, 'hash', '
|
206
|
+
end.equals { @posts.map { |p| cache_hit([p, nil, 'hash', 'e373525f49a3b3b044af05255e84839d'])[:title] } }
|
203
207
|
end # index action, caching, json
|
204
208
|
|
205
209
|
context "for index action with caching in xml" 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.9.0.
|
4
|
+
version: 0.9.0.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- fixtures/ashared/views_rails_3/posts/index.html.erb
|
179
179
|
- fixtures/ashared/views_rails_3/posts/index.rabl
|
180
180
|
- fixtures/ashared/views_rails_3/posts/renderer.rabl
|
181
|
+
- fixtures/ashared/views_rails_3/posts/renderer_partial.rabl
|
181
182
|
- fixtures/ashared/views_rails_3/posts/show.html.erb
|
182
183
|
- fixtures/ashared/views_rails_3/posts/show.rabl
|
183
184
|
- fixtures/ashared/views_rails_3/posts/show.rabl_test_v1.rabl
|