jbuilder 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/jbuilder-0.4.0.gem +0 -0
- data/jbuilder.gemspec +1 -1
- data/lib/jbuilder.rb +0 -1
- data/lib/jbuilder_template.rb +12 -2
- data/test/jbuilder_template_test.rb +16 -12
- metadata +11 -7
- data/jbuilder-0.6.0.gem +0 -0
- data/jbuilder-0.7.0.gem +0 -0
data/jbuilder-0.4.0.gem
ADDED
Binary file
|
data/jbuilder.gemspec
CHANGED
data/lib/jbuilder.rb
CHANGED
data/lib/jbuilder_template.rb
CHANGED
@@ -24,12 +24,22 @@ class JbuilderTemplate < Jbuilder
|
|
24
24
|
# json.extract! @person, :name, :age
|
25
25
|
# end
|
26
26
|
def cache!(key=nil, options={}, &block)
|
27
|
-
|
28
|
-
value = ::Rails.cache.fetch(
|
27
|
+
options[:force] = true unless @context.controller.perform_caching
|
28
|
+
value = ::Rails.cache.fetch(_cache_key(key), options) do
|
29
29
|
_scope { yield self }
|
30
30
|
end
|
31
|
+
|
31
32
|
_merge(value)
|
32
33
|
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
def _cache_key(key)
|
37
|
+
if @context.respond_to?(:fragment_name_with_digest)
|
38
|
+
@context.fragment_name_with_digest(key)
|
39
|
+
else
|
40
|
+
::ActiveSupport::Cache.expand_cache_key(key.is_a?(::Hash) ? url_for(key).split("://").last : key, :jbuilder)
|
41
|
+
end
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
class JbuilderHandler
|
@@ -8,9 +8,11 @@ require 'jbuilder'
|
|
8
8
|
module Rails
|
9
9
|
class Cache
|
10
10
|
def initialize
|
11
|
-
|
11
|
+
clear
|
12
12
|
end
|
13
13
|
|
14
|
+
def clear; @cache = {}; end
|
15
|
+
|
14
16
|
def write(k, v, opt={})
|
15
17
|
@cache[k] = v
|
16
18
|
end
|
@@ -78,32 +80,34 @@ class JbuilderTemplateTest < ActionView::TestCase
|
|
78
80
|
end
|
79
81
|
|
80
82
|
test "fragment caching a JSON object" do
|
81
|
-
|
83
|
+
self.controller.perform_caching = true
|
84
|
+
Rails.cache.clear
|
85
|
+
render_jbuilder <<-JBUILDER
|
82
86
|
json.cache!("cachekey") do
|
83
87
|
json.name "Cache"
|
84
88
|
end
|
85
89
|
JBUILDER
|
86
90
|
|
87
|
-
Rails.cache.read("jbuilder/cachekey").tap do |parsed|
|
88
|
-
assert_equal "Cache", parsed['name']
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
test "fragment caching deserializes a JSON object" do
|
93
|
-
Rails.cache.write("jbuilder/cachekey", {'name' => "Something"})
|
94
91
|
json = render_jbuilder <<-JBUILDER
|
95
92
|
json.cache!("cachekey") do
|
96
|
-
json.name "
|
93
|
+
json.name "Miss"
|
97
94
|
end
|
98
95
|
JBUILDER
|
99
96
|
|
100
97
|
MultiJson.load(json).tap do |parsed|
|
101
|
-
assert_equal "
|
98
|
+
assert_equal "Cache", parsed['name']
|
102
99
|
end
|
103
100
|
end
|
104
101
|
|
105
102
|
test "fragment caching deserializes an array" do
|
106
|
-
Rails.cache.
|
103
|
+
Rails.cache.clear
|
104
|
+
self.controller.perform_caching = true
|
105
|
+
render_jbuilder <<-JBUILDER
|
106
|
+
json.cache!("cachekey") do
|
107
|
+
json.array! ['a', 'b', 'c']
|
108
|
+
end
|
109
|
+
JBUILDER
|
110
|
+
|
107
111
|
json = render_jbuilder <<-JBUILDER
|
108
112
|
json.cache!("cachekey") do
|
109
113
|
json.array! ['1', '2', '3']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
25
30
|
description:
|
26
31
|
email: david@37signals.com
|
27
32
|
executables: []
|
@@ -30,8 +35,7 @@ extra_rdoc_files: []
|
|
30
35
|
files:
|
31
36
|
- ./Gemfile
|
32
37
|
- ./Gemfile.lock
|
33
|
-
- ./jbuilder-0.
|
34
|
-
- ./jbuilder-0.7.0.gem
|
38
|
+
- ./jbuilder-0.4.0.gem
|
35
39
|
- ./jbuilder.gemspec
|
36
40
|
- ./lib/jbuilder.rb
|
37
41
|
- ./lib/jbuilder_template.rb
|
@@ -60,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
64
|
version: '0'
|
61
65
|
requirements: []
|
62
66
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.23
|
64
68
|
signing_key:
|
65
69
|
specification_version: 3
|
66
70
|
summary: Create JSON structures via a Builder-style DSL
|
data/jbuilder-0.6.0.gem
DELETED
Binary file
|
data/jbuilder-0.7.0.gem
DELETED
Binary file
|