jbuilder_cache_multi 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +11 -23
  3. data/README.md +27 -9
  4. data/gemfiles/{rails_3_0.gemfile → rails_3.0.0_jbuilder_1.5.0.gemfile} +1 -0
  5. data/gemfiles/rails_3.0.0_jbuilder_1.5.0.gemfile.lock +69 -0
  6. data/gemfiles/rails_3.0.0_jbuilder_2.0.0.gemfile +12 -0
  7. data/gemfiles/{rails_3_0.gemfile.lock → rails_3.0.0_jbuilder_2.0.0.gemfile.lock} +4 -3
  8. data/gemfiles/{rails_3_1.gemfile → rails_3.1.0_jbuilder_1.5.0.gemfile} +1 -0
  9. data/gemfiles/rails_3.1.0_jbuilder_1.5.0.gemfile.lock +79 -0
  10. data/gemfiles/rails_3.1.0_jbuilder_2.0.0.gemfile +12 -0
  11. data/gemfiles/{rails_3_1.gemfile.lock → rails_3.1.0_jbuilder_2.0.0.gemfile.lock} +4 -3
  12. data/gemfiles/{rails_3_2.gemfile → rails_3.2.0_jbuilder_1.5.0.gemfile} +1 -0
  13. data/gemfiles/rails_3.2.0_jbuilder_1.5.0.gemfile.lock +78 -0
  14. data/gemfiles/rails_3.2.0_jbuilder_2.0.0.gemfile +12 -0
  15. data/gemfiles/{rails_3_2.gemfile.lock → rails_3.2.0_jbuilder_2.0.0.gemfile.lock} +4 -3
  16. data/gemfiles/{rails_4_0.gemfile → rails_4.0.0_jbuilder_1.5.0.gemfile} +1 -0
  17. data/gemfiles/rails_4.0.0_jbuilder_1.5.0.gemfile.lock +60 -0
  18. data/gemfiles/rails_4.0.0_jbuilder_2.0.0.gemfile +12 -0
  19. data/gemfiles/{rails_4_0.gemfile.lock → rails_4.0.0_jbuilder_2.0.0.gemfile.lock} +11 -10
  20. data/gemfiles/{rails_4_1.gemfile → rails_4.1.0_jbuilder_1.5.0.gemfile} +1 -2
  21. data/gemfiles/rails_4.1.0_jbuilder_1.5.0.gemfile.lock +65 -0
  22. data/gemfiles/rails_4.1.0_jbuilder_2.0.0.gemfile +12 -0
  23. data/gemfiles/{rails_4_1.gemfile.lock → rails_4.1.0_jbuilder_2.0.0.gemfile.lock} +7 -10
  24. data/jbuilder_cache_multi.gemspec +2 -2
  25. data/lib/jbuilder_cache_multi/jbuilder_ext.rb +24 -8
  26. data/lib/jbuilder_cache_multi/version.rb +1 -1
  27. data/test/jbuilder_template_test.rb +2 -1
  28. metadata +33 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 54a2a84bed25c236f2516f7d502551044d62a9a7
4
- data.tar.gz: 30aa6ccb09a966117c4b5f94a666227006612211
3
+ metadata.gz: 61de803bda6b5bd09b58daa83d4ac4647a7df8a3
4
+ data.tar.gz: e692f65aafdd50578ae7a3a19f0f2c011c7c7cf9
5
5
  SHA512:
6
- metadata.gz: a048fd0ee8ab5a57c5c8526f6401dde121dd91ae2b90543602df90c204ebac1797623596da544cb8fe2120efd05cb13e39854c59d7a2442445a128d3e1b241d9
7
- data.tar.gz: 3f1c15b833a01c38323404d7dd48ea2e2a724c86c38e746ad1ebfcb2b9e2441ae0c79f94f5a5741bc7d9c9bc4f6b54d1787128fde9d013126ab39e7fa8c96b76
6
+ metadata.gz: fe52ae7c7cf3d61afb6da0802463431a26b91799686735405a5bf045c12a8789f2f0c507d6f2cd4ec75c57b8679f14e685bf6c7ccba42fcc4028d1c59c374548
7
+ data.tar.gz: ce3d31e05e8bcc50c0975169bdaa38348354c65aaf80e7b4f92a677f8ff2f712b290003cff7a5f9a7e41f85074f059a706bf8e1d8f341a90d7a83eed2996e776
data/Appraisals CHANGED
@@ -1,24 +1,12 @@
1
- appraise "rails-3-0" do
2
- gem "railties", "~> 3.0.0"
3
- gem "actionpack", "~> 3.0.0"
4
- end
5
-
6
- appraise "rails-3-1" do
7
- gem "railties", "~> 3.1.0"
8
- gem "actionpack", "~> 3.1.0"
9
- end
10
-
11
- appraise "rails-3-2" do
12
- gem "railties", "~> 3.2.0"
13
- gem "actionpack", "~> 3.2.0"
14
- end
15
-
16
- appraise "rails-4-0" do
17
- gem "railties", "~> 4.0.0"
18
- gem "actionpack", "~> 4.0.0"
19
- end
20
-
21
- appraise "rails-4-1" do
22
- gem "railties", "~> 4.1.0"
23
- gem "actionpack", "~> 4.1.0"
1
+ rails_versions = ["~> 3.0.0", "~> 3.1.0", "~> 3.2.0", "~> 4.0.0", "~> 4.1.0"]
2
+ jbuilder_versions = ["~> 1.5.0", "~> 2.0.0"]
3
+
4
+ rails_versions.each do |r|
5
+ jbuilder_versions.each do |j|
6
+ appraise "rails_#{r.match(/\d.*/)} jbuilder_#{j.match(/\d.*/)}" do
7
+ gem "railties", r
8
+ gem "actionpack", r
9
+ gem "jbuilder", j
10
+ end
11
+ end
24
12
  end
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # JbuilderCacheMulti
2
2
 
3
- Adds cache_collection! method, useful when iterating over a collection. The main advantage is that it will try to use fetch_multi from rails (if available in rails and supported by the cache) to query the cache.
3
+ Useful when you need to retrieve fragments for a collection of objects from the cache. This plugin gives you method called 'cache_collection!' which uses fetch_multi (new in Rails 4.1) to retrieve multiple keys in a single go.
4
4
 
5
- fetch_muti uses read_multi (supported by memcache) to retreive multiple items in one go. This means less queries to the cache == faster responses. If items are not found, they are writen to the cache (individualy, at the moment).
5
+ This means less queries to the cache == faster responses. If items are not found, they are writen to the cache (individualy. memcache doesn't support writing items in batch...yet).
6
+
7
+ Tested with Rails 4.1 + Memcached + Dalli
6
8
 
7
9
  ## Installation
8
10
 
@@ -20,10 +22,9 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- Caches a collection of objects using fetch_multi, if supported (otherwise iterates over the collection using fetch)
24
- Requires a block for each item in the array. Accepts optional 'key' attribute in options (e.g. key: 'v1').
25
+ Renders the given block for each item in the collection. Accepts optional 'key' attribute in options (e.g. key: 'v1').
25
26
 
26
- Note: At the moment, does not accept the partial name as an argument #todo
27
+ Note: At the moment, does not accept the partial name as an argument (#todo)
27
28
 
28
29
  Examples:
29
30
 
@@ -31,13 +32,30 @@ Examples:
31
32
  json.partial! 'person', :person => person
32
33
  end
33
34
 
34
- Or with optional key
35
+ # Or with optional key
35
36
 
36
37
  json.cache_collection! @people, expires_in: 10.minutes, key: 'v1' do |person|
37
38
  json.partial! 'person', :person => person
38
39
  end
39
40
 
40
-
41
+ NOTE: If the items in your collection don't change frequently, it might be better to cache the entire collection like this:
42
+ (in which case you don't need this gem)
43
+
44
+ json.cache! @people do
45
+ json.partial! 'person', collection: @people, as: :person
46
+ end
47
+
48
+ Or you can use a combination of both!
49
+ This will cache the entire collection. If a single item changes it will use read_multi to get all unchanged items and regenerate only the changed item(s).
50
+
51
+ json.cache! @people do
52
+ json.cache_collection! @people do |person|
53
+ json.partial! 'person', :person => person
54
+ end
55
+ end
56
+
57
+ Last thing: If you are using a collection for the cache key, may I recommend the 'scope_cache_key' gem? (check out my fork for a Rails 4 version: https://github.com/joshblour/scope_cache_key). It very quickly calculates a hash for all items in the collection (MD5 hash of updated_at + IDs).
58
+
41
59
  ## Todo
42
60
 
43
61
  - Add support for passing a partial name as an argument (e.g. json.cache_collection! @people, partial: 'person') or maybe even just "json.cache_collection! @people" and infer the partial name from the collection...
@@ -53,5 +71,5 @@ Or with optional key
53
71
  5. Create a new Pull Request
54
72
 
55
73
  ## Credit
56
- Loads borrowed from https://github.com/n8/multi_fetch_fragments. Thank you!
57
- And of course https://github.com/rails/jbuilder
74
+ Inspired by https://github.com/n8/multi_fetch_fragments. Thank you!
75
+ And of course https://github.com/rails/jbuilder
@@ -7,5 +7,6 @@ gem "mocha", :require => false
7
7
  gem "appraisal"
8
8
  gem "railties", "~> 3.0.0"
9
9
  gem "actionpack", "~> 3.0.0"
10
+ gem "jbuilder", "~> 1.5.0"
10
11
 
11
12
  gemspec :path => "../"
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ jbuilder_cache_multi (0.0.1)
5
+ jbuilder (>= 1.5.0, < 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionpack (3.0.20)
12
+ activemodel (= 3.0.20)
13
+ activesupport (= 3.0.20)
14
+ builder (~> 2.1.2)
15
+ erubis (~> 2.6.6)
16
+ i18n (~> 0.5.0)
17
+ rack (~> 1.2.5)
18
+ rack-mount (~> 0.6.14)
19
+ rack-test (~> 0.5.7)
20
+ tzinfo (~> 0.3.23)
21
+ activemodel (3.0.20)
22
+ activesupport (= 3.0.20)
23
+ builder (~> 2.1.2)
24
+ i18n (~> 0.5.0)
25
+ activesupport (3.0.20)
26
+ appraisal (1.0.0)
27
+ bundler
28
+ rake
29
+ thor (>= 0.14.0)
30
+ builder (2.1.2)
31
+ erubis (2.6.6)
32
+ abstract (>= 1.0.0)
33
+ i18n (0.5.3)
34
+ jbuilder (1.5.3)
35
+ activesupport (>= 3.0.0)
36
+ multi_json (>= 1.2.0)
37
+ json (1.8.1)
38
+ metaclass (0.0.4)
39
+ mocha (1.0.0)
40
+ metaclass (~> 0.0.1)
41
+ multi_json (1.10.1)
42
+ rack (1.2.8)
43
+ rack-mount (0.6.14)
44
+ rack (>= 1.0.0)
45
+ rack-test (0.5.7)
46
+ rack (>= 1.0)
47
+ railties (3.0.20)
48
+ actionpack (= 3.0.20)
49
+ activesupport (= 3.0.20)
50
+ rake (>= 0.8.7)
51
+ rdoc (~> 3.4)
52
+ thor (~> 0.14.4)
53
+ rake (10.3.2)
54
+ rdoc (3.12.2)
55
+ json (~> 1.4)
56
+ thor (0.14.6)
57
+ tzinfo (0.3.39)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ actionpack (~> 3.0.0)
64
+ appraisal
65
+ jbuilder (~> 1.5.0)
66
+ jbuilder_cache_multi!
67
+ mocha
68
+ railties (~> 3.0.0)
69
+ rake
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha", :require => false
7
+ gem "appraisal"
8
+ gem "railties", "~> 3.0.0"
9
+ gem "actionpack", "~> 3.0.0"
10
+ gem "jbuilder", "~> 2.0.0"
11
+
12
+ gemspec :path => "../"
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ../
3
3
  specs:
4
4
  jbuilder_cache_multi (0.0.1)
5
- jbuilder (~> 2.0)
5
+ jbuilder (>= 1.5.0, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -38,7 +38,7 @@ GEM
38
38
  metaclass (0.0.4)
39
39
  mocha (1.0.0)
40
40
  metaclass (~> 0.0.1)
41
- multi_json (1.10.0)
41
+ multi_json (1.10.1)
42
42
  rack (1.2.8)
43
43
  rack-mount (0.6.14)
44
44
  rack (>= 1.0.0)
@@ -50,7 +50,7 @@ GEM
50
50
  rake (>= 0.8.7)
51
51
  rdoc (~> 3.4)
52
52
  thor (~> 0.14.4)
53
- rake (10.3.1)
53
+ rake (10.3.2)
54
54
  rdoc (3.12.2)
55
55
  json (~> 1.4)
56
56
  thor (0.14.6)
@@ -62,6 +62,7 @@ PLATFORMS
62
62
  DEPENDENCIES
63
63
  actionpack (~> 3.0.0)
64
64
  appraisal
65
+ jbuilder (~> 2.0.0)
65
66
  jbuilder_cache_multi!
66
67
  mocha
67
68
  railties (~> 3.0.0)
@@ -7,5 +7,6 @@ gem "mocha", :require => false
7
7
  gem "appraisal"
8
8
  gem "railties", "~> 3.1.0"
9
9
  gem "actionpack", "~> 3.1.0"
10
+ gem "jbuilder", "~> 1.5.0"
10
11
 
11
12
  gemspec :path => "../"
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ jbuilder_cache_multi (0.0.1)
5
+ jbuilder (>= 1.5.0, < 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (3.1.12)
11
+ activemodel (= 3.1.12)
12
+ activesupport (= 3.1.12)
13
+ builder (~> 3.0.0)
14
+ erubis (~> 2.7.0)
15
+ i18n (~> 0.6)
16
+ rack (~> 1.3.6)
17
+ rack-cache (~> 1.2)
18
+ rack-mount (~> 0.8.2)
19
+ rack-test (~> 0.6.1)
20
+ sprockets (~> 2.0.4)
21
+ activemodel (3.1.12)
22
+ activesupport (= 3.1.12)
23
+ builder (~> 3.0.0)
24
+ i18n (~> 0.6)
25
+ activesupport (3.1.12)
26
+ multi_json (~> 1.0)
27
+ appraisal (1.0.0)
28
+ bundler
29
+ rake
30
+ thor (>= 0.14.0)
31
+ builder (3.0.4)
32
+ erubis (2.7.0)
33
+ hike (1.2.3)
34
+ i18n (0.6.9)
35
+ jbuilder (1.5.3)
36
+ activesupport (>= 3.0.0)
37
+ multi_json (>= 1.2.0)
38
+ json (1.8.1)
39
+ metaclass (0.0.4)
40
+ mocha (1.0.0)
41
+ metaclass (~> 0.0.1)
42
+ multi_json (1.10.1)
43
+ rack (1.3.10)
44
+ rack-cache (1.2)
45
+ rack (>= 0.4)
46
+ rack-mount (0.8.3)
47
+ rack (>= 1.0.0)
48
+ rack-ssl (1.3.4)
49
+ rack
50
+ rack-test (0.6.2)
51
+ rack (>= 1.0)
52
+ railties (3.1.12)
53
+ actionpack (= 3.1.12)
54
+ activesupport (= 3.1.12)
55
+ rack-ssl (~> 1.3.2)
56
+ rake (>= 0.8.7)
57
+ rdoc (~> 3.4)
58
+ thor (~> 0.14.6)
59
+ rake (10.3.2)
60
+ rdoc (3.12.2)
61
+ json (~> 1.4)
62
+ sprockets (2.0.4)
63
+ hike (~> 1.2)
64
+ rack (~> 1.0)
65
+ tilt (~> 1.1, != 1.3.0)
66
+ thor (0.14.6)
67
+ tilt (1.4.1)
68
+
69
+ PLATFORMS
70
+ ruby
71
+
72
+ DEPENDENCIES
73
+ actionpack (~> 3.1.0)
74
+ appraisal
75
+ jbuilder (~> 1.5.0)
76
+ jbuilder_cache_multi!
77
+ mocha
78
+ railties (~> 3.1.0)
79
+ rake
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha", :require => false
7
+ gem "appraisal"
8
+ gem "railties", "~> 3.1.0"
9
+ gem "actionpack", "~> 3.1.0"
10
+ gem "jbuilder", "~> 2.0.0"
11
+
12
+ gemspec :path => "../"
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ../
3
3
  specs:
4
4
  jbuilder_cache_multi (0.0.1)
5
- jbuilder (~> 2.0)
5
+ jbuilder (>= 1.5.0, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -39,7 +39,7 @@ GEM
39
39
  metaclass (0.0.4)
40
40
  mocha (1.0.0)
41
41
  metaclass (~> 0.0.1)
42
- multi_json (1.10.0)
42
+ multi_json (1.10.1)
43
43
  rack (1.3.10)
44
44
  rack-cache (1.2)
45
45
  rack (>= 0.4)
@@ -56,7 +56,7 @@ GEM
56
56
  rake (>= 0.8.7)
57
57
  rdoc (~> 3.4)
58
58
  thor (~> 0.14.6)
59
- rake (10.3.1)
59
+ rake (10.3.2)
60
60
  rdoc (3.12.2)
61
61
  json (~> 1.4)
62
62
  sprockets (2.0.4)
@@ -72,6 +72,7 @@ PLATFORMS
72
72
  DEPENDENCIES
73
73
  actionpack (~> 3.1.0)
74
74
  appraisal
75
+ jbuilder (~> 2.0.0)
75
76
  jbuilder_cache_multi!
76
77
  mocha
77
78
  railties (~> 3.1.0)
@@ -7,5 +7,6 @@ gem "mocha", :require => false
7
7
  gem "appraisal"
8
8
  gem "railties", "~> 3.2.0"
9
9
  gem "actionpack", "~> 3.2.0"
10
+ gem "jbuilder", "~> 1.5.0"
10
11
 
11
12
  gemspec :path => "../"
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ jbuilder_cache_multi (0.0.1)
5
+ jbuilder (>= 1.5.0, < 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (3.2.17)
11
+ activemodel (= 3.2.17)
12
+ activesupport (= 3.2.17)
13
+ builder (~> 3.0.0)
14
+ erubis (~> 2.7.0)
15
+ journey (~> 1.0.4)
16
+ rack (~> 1.4.5)
17
+ rack-cache (~> 1.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.2.1)
20
+ activemodel (3.2.17)
21
+ activesupport (= 3.2.17)
22
+ builder (~> 3.0.0)
23
+ activesupport (3.2.17)
24
+ i18n (~> 0.6, >= 0.6.4)
25
+ multi_json (~> 1.0)
26
+ appraisal (1.0.0)
27
+ bundler
28
+ rake
29
+ thor (>= 0.14.0)
30
+ builder (3.0.4)
31
+ erubis (2.7.0)
32
+ hike (1.2.3)
33
+ i18n (0.6.9)
34
+ jbuilder (1.5.3)
35
+ activesupport (>= 3.0.0)
36
+ multi_json (>= 1.2.0)
37
+ journey (1.0.4)
38
+ json (1.8.1)
39
+ metaclass (0.0.4)
40
+ mocha (1.0.0)
41
+ metaclass (~> 0.0.1)
42
+ multi_json (1.10.1)
43
+ rack (1.4.5)
44
+ rack-cache (1.2)
45
+ rack (>= 0.4)
46
+ rack-ssl (1.3.4)
47
+ rack
48
+ rack-test (0.6.2)
49
+ rack (>= 1.0)
50
+ railties (3.2.17)
51
+ actionpack (= 3.2.17)
52
+ activesupport (= 3.2.17)
53
+ rack-ssl (~> 1.3.2)
54
+ rake (>= 0.8.7)
55
+ rdoc (~> 3.4)
56
+ thor (>= 0.14.6, < 2.0)
57
+ rake (10.3.2)
58
+ rdoc (3.12.2)
59
+ json (~> 1.4)
60
+ sprockets (2.2.2)
61
+ hike (~> 1.2)
62
+ multi_json (~> 1.0)
63
+ rack (~> 1.0)
64
+ tilt (~> 1.1, != 1.3.0)
65
+ thor (0.19.1)
66
+ tilt (1.4.1)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ actionpack (~> 3.2.0)
73
+ appraisal
74
+ jbuilder (~> 1.5.0)
75
+ jbuilder_cache_multi!
76
+ mocha
77
+ railties (~> 3.2.0)
78
+ rake
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha", :require => false
7
+ gem "appraisal"
8
+ gem "railties", "~> 3.2.0"
9
+ gem "actionpack", "~> 3.2.0"
10
+ gem "jbuilder", "~> 2.0.0"
11
+
12
+ gemspec :path => "../"
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ../
3
3
  specs:
4
4
  jbuilder_cache_multi (0.0.1)
5
- jbuilder (~> 2.0)
5
+ jbuilder (>= 1.5.0, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -39,7 +39,7 @@ GEM
39
39
  metaclass (0.0.4)
40
40
  mocha (1.0.0)
41
41
  metaclass (~> 0.0.1)
42
- multi_json (1.10.0)
42
+ multi_json (1.10.1)
43
43
  rack (1.4.5)
44
44
  rack-cache (1.2)
45
45
  rack (>= 0.4)
@@ -54,7 +54,7 @@ GEM
54
54
  rake (>= 0.8.7)
55
55
  rdoc (~> 3.4)
56
56
  thor (>= 0.14.6, < 2.0)
57
- rake (10.3.1)
57
+ rake (10.3.2)
58
58
  rdoc (3.12.2)
59
59
  json (~> 1.4)
60
60
  sprockets (2.2.2)
@@ -71,6 +71,7 @@ PLATFORMS
71
71
  DEPENDENCIES
72
72
  actionpack (~> 3.2.0)
73
73
  appraisal
74
+ jbuilder (~> 2.0.0)
74
75
  jbuilder_cache_multi!
75
76
  mocha
76
77
  railties (~> 3.2.0)
@@ -7,5 +7,6 @@ gem "mocha", :require => false
7
7
  gem "appraisal"
8
8
  gem "railties", "~> 4.0.0"
9
9
  gem "actionpack", "~> 4.0.0"
10
+ gem "jbuilder", "~> 1.5.0"
10
11
 
11
12
  gemspec :path => "../"
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ jbuilder_cache_multi (0.0.1)
5
+ jbuilder (>= 1.5.0, < 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (4.0.5)
11
+ activesupport (= 4.0.5)
12
+ builder (~> 3.1.0)
13
+ erubis (~> 2.7.0)
14
+ rack (~> 1.5.2)
15
+ rack-test (~> 0.6.2)
16
+ activesupport (4.0.5)
17
+ i18n (~> 0.6, >= 0.6.9)
18
+ minitest (~> 4.2)
19
+ multi_json (~> 1.3)
20
+ thread_safe (~> 0.1)
21
+ tzinfo (~> 0.3.37)
22
+ appraisal (1.0.0)
23
+ bundler
24
+ rake
25
+ thor (>= 0.14.0)
26
+ builder (3.1.4)
27
+ erubis (2.7.0)
28
+ i18n (0.6.9)
29
+ jbuilder (1.5.3)
30
+ activesupport (>= 3.0.0)
31
+ multi_json (>= 1.2.0)
32
+ metaclass (0.0.4)
33
+ minitest (4.7.5)
34
+ mocha (1.0.0)
35
+ metaclass (~> 0.0.1)
36
+ multi_json (1.10.1)
37
+ rack (1.5.2)
38
+ rack-test (0.6.2)
39
+ rack (>= 1.0)
40
+ railties (4.0.5)
41
+ actionpack (= 4.0.5)
42
+ activesupport (= 4.0.5)
43
+ rake (>= 0.8.7)
44
+ thor (>= 0.18.1, < 2.0)
45
+ rake (10.3.2)
46
+ thor (0.19.1)
47
+ thread_safe (0.3.4)
48
+ tzinfo (0.3.39)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ actionpack (~> 4.0.0)
55
+ appraisal
56
+ jbuilder (~> 1.5.0)
57
+ jbuilder_cache_multi!
58
+ mocha
59
+ railties (~> 4.0.0)
60
+ rake
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha", :require => false
7
+ gem "appraisal"
8
+ gem "railties", "~> 4.0.0"
9
+ gem "actionpack", "~> 4.0.0"
10
+ gem "jbuilder", "~> 2.0.0"
11
+
12
+ gemspec :path => "../"
@@ -2,18 +2,18 @@ PATH
2
2
  remote: ../
3
3
  specs:
4
4
  jbuilder_cache_multi (0.0.1)
5
- jbuilder (~> 2.0)
5
+ jbuilder (>= 1.5.0, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (4.0.4)
11
- activesupport (= 4.0.4)
10
+ actionpack (4.0.5)
11
+ activesupport (= 4.0.5)
12
12
  builder (~> 3.1.0)
13
13
  erubis (~> 2.7.0)
14
14
  rack (~> 1.5.2)
15
15
  rack-test (~> 0.6.2)
16
- activesupport (4.0.4)
16
+ activesupport (4.0.5)
17
17
  i18n (~> 0.6, >= 0.6.9)
18
18
  minitest (~> 4.2)
19
19
  multi_json (~> 1.3)
@@ -33,18 +33,18 @@ GEM
33
33
  minitest (4.7.5)
34
34
  mocha (1.0.0)
35
35
  metaclass (~> 0.0.1)
36
- multi_json (1.10.0)
36
+ multi_json (1.10.1)
37
37
  rack (1.5.2)
38
38
  rack-test (0.6.2)
39
39
  rack (>= 1.0)
40
- railties (4.0.4)
41
- actionpack (= 4.0.4)
42
- activesupport (= 4.0.4)
40
+ railties (4.0.5)
41
+ actionpack (= 4.0.5)
42
+ activesupport (= 4.0.5)
43
43
  rake (>= 0.8.7)
44
44
  thor (>= 0.18.1, < 2.0)
45
- rake (10.3.1)
45
+ rake (10.3.2)
46
46
  thor (0.19.1)
47
- thread_safe (0.3.3)
47
+ thread_safe (0.3.4)
48
48
  tzinfo (0.3.39)
49
49
 
50
50
  PLATFORMS
@@ -53,6 +53,7 @@ PLATFORMS
53
53
  DEPENDENCIES
54
54
  actionpack (~> 4.0.0)
55
55
  appraisal
56
+ jbuilder (~> 2.0.0)
56
57
  jbuilder_cache_multi!
57
58
  mocha
58
59
  railties (~> 4.0.0)
@@ -7,7 +7,6 @@ gem "mocha", :require => false
7
7
  gem "appraisal"
8
8
  gem "railties", "~> 4.1.0"
9
9
  gem "actionpack", "~> 4.1.0"
10
- gem "rails-perftest"
11
- gem "ruby-prof"
10
+ gem "jbuilder", "~> 1.5.0"
12
11
 
13
12
  gemspec :path => "../"
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ jbuilder_cache_multi (0.0.1)
5
+ jbuilder (>= 1.5.0, < 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (4.1.0)
11
+ actionview (= 4.1.0)
12
+ activesupport (= 4.1.0)
13
+ rack (~> 1.5.2)
14
+ rack-test (~> 0.6.2)
15
+ actionview (4.1.0)
16
+ activesupport (= 4.1.0)
17
+ builder (~> 3.1)
18
+ erubis (~> 2.7.0)
19
+ activesupport (4.1.0)
20
+ i18n (~> 0.6, >= 0.6.9)
21
+ json (~> 1.7, >= 1.7.7)
22
+ minitest (~> 5.1)
23
+ thread_safe (~> 0.1)
24
+ tzinfo (~> 1.1)
25
+ appraisal (1.0.0)
26
+ bundler
27
+ rake
28
+ thor (>= 0.14.0)
29
+ builder (3.2.2)
30
+ erubis (2.7.0)
31
+ i18n (0.6.9)
32
+ jbuilder (1.5.3)
33
+ activesupport (>= 3.0.0)
34
+ multi_json (>= 1.2.0)
35
+ json (1.8.1)
36
+ metaclass (0.0.4)
37
+ minitest (5.3.4)
38
+ mocha (1.0.0)
39
+ metaclass (~> 0.0.1)
40
+ multi_json (1.10.1)
41
+ rack (1.5.2)
42
+ rack-test (0.6.2)
43
+ rack (>= 1.0)
44
+ railties (4.1.0)
45
+ actionpack (= 4.1.0)
46
+ activesupport (= 4.1.0)
47
+ rake (>= 0.8.7)
48
+ thor (>= 0.18.1, < 2.0)
49
+ rake (10.3.2)
50
+ thor (0.19.1)
51
+ thread_safe (0.3.4)
52
+ tzinfo (1.2.1)
53
+ thread_safe (~> 0.1)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ actionpack (~> 4.1.0)
60
+ appraisal
61
+ jbuilder (~> 1.5.0)
62
+ jbuilder_cache_multi!
63
+ mocha
64
+ railties (~> 4.1.0)
65
+ rake
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha", :require => false
7
+ gem "appraisal"
8
+ gem "railties", "~> 4.1.0"
9
+ gem "actionpack", "~> 4.1.0"
10
+ gem "jbuilder", "~> 2.0.0"
11
+
12
+ gemspec :path => "../"
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ../
3
3
  specs:
4
4
  jbuilder_cache_multi (0.0.1)
5
- jbuilder (~> 2.0)
5
+ jbuilder (>= 1.5.0, < 3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -34,24 +34,22 @@ GEM
34
34
  multi_json (~> 1.2)
35
35
  json (1.8.1)
36
36
  metaclass (0.0.4)
37
- minitest (5.3.3)
37
+ minitest (5.3.4)
38
38
  mocha (1.0.0)
39
39
  metaclass (~> 0.0.1)
40
- multi_json (1.10.0)
40
+ multi_json (1.10.1)
41
41
  rack (1.5.2)
42
42
  rack-test (0.6.2)
43
43
  rack (>= 1.0)
44
- rails-perftest (0.0.3)
45
44
  railties (4.1.0)
46
45
  actionpack (= 4.1.0)
47
46
  activesupport (= 4.1.0)
48
47
  rake (>= 0.8.7)
49
48
  thor (>= 0.18.1, < 2.0)
50
- rake (10.3.1)
51
- ruby-prof (0.15.1)
49
+ rake (10.3.2)
52
50
  thor (0.19.1)
53
- thread_safe (0.3.3)
54
- tzinfo (1.1.0)
51
+ thread_safe (0.3.4)
52
+ tzinfo (1.2.1)
55
53
  thread_safe (~> 0.1)
56
54
 
57
55
  PLATFORMS
@@ -60,9 +58,8 @@ PLATFORMS
60
58
  DEPENDENCIES
61
59
  actionpack (~> 4.1.0)
62
60
  appraisal
61
+ jbuilder (~> 2.0.0)
63
62
  jbuilder_cache_multi!
64
63
  mocha
65
- rails-perftest
66
64
  railties (~> 4.1.0)
67
65
  rake
68
- ruby-prof
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Yonah Forst"]
10
10
  spec.email = ["joshblour@hotmail.com"]
11
11
  spec.summary = %q{Adds cache_collection! to jbuilder. Uses memcache fetch_multi/read_multi}
12
- spec.homepage = ""
12
+ spec.homepage = "http://www.github.com/joshblour/jbuilder_cache_multi"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.required_ruby_version = '>= 1.9.3'
21
21
 
22
- spec.add_dependency 'jbuilder', '~> 2.0'
22
+ spec.add_dependency 'jbuilder', '>= 1.5.0', '< 3'
23
23
 
24
24
  end
@@ -1,5 +1,4 @@
1
1
  JbuilderTemplate.class_eval do
2
-
3
2
  # Caches a collection of objects using fetch_multi, if supported.
4
3
  # Requires a block for each item in the array. Accepts optional 'key' attribute in options (e.g. key: 'v1').
5
4
  #
@@ -29,26 +28,43 @@ JbuilderTemplate.class_eval do
29
28
  end
30
29
 
31
30
 
31
+
32
32
  protected
33
33
 
34
+ ## Implementing our own version of _cache_key because jbuilder's is protected
35
+ def _cache_key_fetch_multi(key, options)
36
+ if @context.respond_to?(:cache_fragment_name)
37
+ # Current compatibility, fragment_name_with_digest is private again and cache_fragment_name
38
+ # should be used instead.
39
+ @context.cache_fragment_name(key, options)
40
+ elsif @context.respond_to?(:fragment_name_with_digest)
41
+ # Backwards compatibility for period of time when fragment_name_with_digest was made public.
42
+ @context.fragment_name_with_digest(key)
43
+ else
44
+ ::ActiveSupport::Cache.expand_cache_key(key.is_a?(::Hash) ? url_for(key).split('://').last : key, :jbuilder)
45
+ end
46
+ end
47
+
34
48
  def _keys_to_collection_map(collection, options)
35
49
  key = options.delete(:key)
36
50
 
37
51
  collection.inject({}) do |result, item|
38
52
  cache_key = key ? [key, item] : item
39
- result[_cache_key(cache_key, options)] = item
53
+ result[_cache_key_fetch_multi(cache_key, options)] = item
40
54
  result
41
55
  end
42
56
  end
43
57
 
44
58
  def _process_collection_results(results)
45
- case results
46
- when ::Hash
47
- merge! results.values
59
+ _results = results.class == Hash ? results.values : results
60
+ #support pre 2.0 versions of jbuilder where merge! is still private
61
+ if Jbuilder.instance_methods.include? :merge!
62
+ merge! _results
63
+ elsif Jbuilder.private_instance_methods.include? :_merge
64
+ _merge _results
48
65
  else
49
- merge! results
50
- end
66
+ _results
67
+ end
51
68
  end
52
69
 
53
-
54
70
  end
@@ -1,3 +1,3 @@
1
1
  module JbuilderCacheMulti
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,6 +3,7 @@ require 'mocha/setup'
3
3
  require 'action_view'
4
4
  require 'action_view/testing/resolvers'
5
5
  require 'active_support/cache'
6
+ require 'jbuilder'
6
7
  require 'jbuilder/jbuilder_template'
7
8
  require 'jbuilder_cache_multi'
8
9
 
@@ -56,7 +57,7 @@ class JbuilderTemplateTest < ActionView::TestCase
56
57
  def assert_collection_rendered(json, context = nil)
57
58
  result = MultiJson.load(json)
58
59
  result = result.fetch(context) if context
59
-
60
+
60
61
  assert_equal 10, result.length
61
62
  assert_equal Array, result.class
62
63
  assert_equal 'post body 5', result[4]['body']
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder_cache_multi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yonah Forst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: 1.5.0
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.0
30
+ - - <
25
31
  - !ruby/object:Gem::Version
26
- version: '2.0'
32
+ version: '3'
27
33
  description:
28
34
  email:
29
35
  - joshblour@hotmail.com
@@ -37,23 +43,33 @@ files:
37
43
  - LICENSE.txt
38
44
  - README.md
39
45
  - Rakefile
40
- - gemfiles/rails_3_0.gemfile
41
- - gemfiles/rails_3_0.gemfile.lock
42
- - gemfiles/rails_3_1.gemfile
43
- - gemfiles/rails_3_1.gemfile.lock
44
- - gemfiles/rails_3_2.gemfile
45
- - gemfiles/rails_3_2.gemfile.lock
46
- - gemfiles/rails_4_0.gemfile
47
- - gemfiles/rails_4_0.gemfile.lock
48
- - gemfiles/rails_4_1.gemfile
49
- - gemfiles/rails_4_1.gemfile.lock
46
+ - gemfiles/rails_3.0.0_jbuilder_1.5.0.gemfile
47
+ - gemfiles/rails_3.0.0_jbuilder_1.5.0.gemfile.lock
48
+ - gemfiles/rails_3.0.0_jbuilder_2.0.0.gemfile
49
+ - gemfiles/rails_3.0.0_jbuilder_2.0.0.gemfile.lock
50
+ - gemfiles/rails_3.1.0_jbuilder_1.5.0.gemfile
51
+ - gemfiles/rails_3.1.0_jbuilder_1.5.0.gemfile.lock
52
+ - gemfiles/rails_3.1.0_jbuilder_2.0.0.gemfile
53
+ - gemfiles/rails_3.1.0_jbuilder_2.0.0.gemfile.lock
54
+ - gemfiles/rails_3.2.0_jbuilder_1.5.0.gemfile
55
+ - gemfiles/rails_3.2.0_jbuilder_1.5.0.gemfile.lock
56
+ - gemfiles/rails_3.2.0_jbuilder_2.0.0.gemfile
57
+ - gemfiles/rails_3.2.0_jbuilder_2.0.0.gemfile.lock
58
+ - gemfiles/rails_4.0.0_jbuilder_1.5.0.gemfile
59
+ - gemfiles/rails_4.0.0_jbuilder_1.5.0.gemfile.lock
60
+ - gemfiles/rails_4.0.0_jbuilder_2.0.0.gemfile
61
+ - gemfiles/rails_4.0.0_jbuilder_2.0.0.gemfile.lock
62
+ - gemfiles/rails_4.1.0_jbuilder_1.5.0.gemfile
63
+ - gemfiles/rails_4.1.0_jbuilder_1.5.0.gemfile.lock
64
+ - gemfiles/rails_4.1.0_jbuilder_2.0.0.gemfile
65
+ - gemfiles/rails_4.1.0_jbuilder_2.0.0.gemfile.lock
50
66
  - jbuilder_cache_multi.gemspec
51
67
  - lib/jbuilder_cache_multi.rb
52
68
  - lib/jbuilder_cache_multi/jbuilder_ext.rb
53
69
  - lib/jbuilder_cache_multi/version.rb
54
70
  - test/jbuilder_template_test.rb
55
71
  - test/test_helper.rb
56
- homepage: ''
72
+ homepage: http://www.github.com/joshblour/jbuilder_cache_multi
57
73
  licenses:
58
74
  - MIT
59
75
  metadata: {}