cache_with_locale 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -2
- data/lib/cache_with_locale/collection_caching.rb +7 -0
- data/lib/cache_with_locale/helpers.rb +14 -0
- data/lib/cache_with_locale/railtie.rb +5 -1
- data/lib/cache_with_locale/version.rb +1 -1
- data/lib/cache_with_locale.rb +1 -16
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2c5361798afa4b6c5355bba50ee927108dda840f016d6ef58c6e707e7083f13
|
4
|
+
data.tar.gz: 573e168de3cbe79f0a92edd20067f1718d29e46182e975bd0b4a9e8b7f43bd3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824b3c3d7a4cf9890d69e6ab38bd0c047d119d15de9a5a847f422797c4735f6183882f04a46c3dea82baa5548c98bbdeddc6ae949c48d0a2675ecaa08b15793a
|
7
|
+
data.tar.gz: bcece37e507eb22ec112782be05dd60b4edc6d2b467e7ce287fb5236c27d13888696e38199e49434f63e986fe19768d2d775bc2479091188fe734221a0640d8d
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/igorkasyanchuk/cache_with_locale.svg?branch=master)](https://travis-ci.org/igorkasyanchuk/cache_with_locale)
|
2
2
|
[![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
|
3
|
+
[![https://www.patreon.com/igorkasyanchuk](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/patron.svg?raw=true)](https://www.patreon.com/igorkasyanchuk)
|
3
4
|
|
4
5
|
# Rails cache with locale
|
5
6
|
Automatically adding current application locale (I18n.locale) as a part of caching key in Rails views.
|
@@ -27,6 +28,12 @@ This gem is a simple solution which allows you to DRY your code. So now you can
|
|
27
28
|
|
28
29
|
And let gem handle all work. You don't need to specify locale as a cache sufix/prefix.
|
29
30
|
|
31
|
+
This gem also works for collection caching like this:
|
32
|
+
|
33
|
+
```
|
34
|
+
= render partial: :post, collection: @posts, cached: true
|
35
|
+
```
|
36
|
+
|
30
37
|
## Usage
|
31
38
|
Just add this gem to your Gemfile.
|
32
39
|
|
@@ -44,12 +51,18 @@ $ bundle
|
|
44
51
|
|
45
52
|
## Contributing
|
46
53
|
|
47
|
-
Contributors
|
54
|
+
Contributors:
|
55
|
+
|
48
56
|
|
49
57
|
- https://github.com/pfeiffer
|
58
|
+
- https://github.com/dlackty
|
50
59
|
|
51
60
|
## Change Log
|
52
61
|
|
62
|
+
0.0.3
|
63
|
+
|
64
|
+
- https://github.com/igorkasyanchuk/cache_with_locale/pull/3
|
65
|
+
|
53
66
|
0.0.2
|
54
67
|
|
55
68
|
- https://github.com/igorkasyanchuk/cache_with_locale/pull/2
|
@@ -61,4 +74,5 @@ Contributors
|
|
61
74
|
## License
|
62
75
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
63
76
|
|
64
|
-
|
77
|
+
[<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
|
78
|
+
/>](https://www.railsjazz.com/?utm_source=github&utm_medium=bottom&utm_campaign=cache_with_locale)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CacheWithLocale
|
2
|
+
module Helpers
|
3
|
+
def cache(key, options = {}, &block)
|
4
|
+
super(cache_with_locale_compose_key(key), options) do
|
5
|
+
yield(block)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def cache_with_locale_compose_key(key)
|
11
|
+
Array.wrap(key) + [I18n.locale.to_s]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,8 +1,12 @@
|
|
1
|
+
require "cache_with_locale/collection_caching"
|
2
|
+
require "cache_with_locale/helpers"
|
3
|
+
|
1
4
|
module CacheWithLocale
|
2
5
|
class Railtie < ::Rails::Railtie
|
3
|
-
initializer '
|
6
|
+
initializer 'cache_with_locale.helpers' do
|
4
7
|
ActiveSupport.on_load :action_view do
|
5
8
|
ActionView::Base.send :include, CacheWithLocale::Helpers
|
9
|
+
ActionView::PartialRenderer.prepend CacheWithLocale::CollectionCaching
|
6
10
|
end
|
7
11
|
end
|
8
12
|
end
|
data/lib/cache_with_locale.rb
CHANGED
@@ -1,16 +1 @@
|
|
1
|
-
require "cache_with_locale/railtie"
|
2
|
-
|
3
|
-
module CacheWithLocale
|
4
|
-
module Helpers
|
5
|
-
def cache(key, options = {}, &block)
|
6
|
-
super(cache_with_locale_compose_key(key), options) do
|
7
|
-
yield(block)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
def cache_with_locale_compose_key(key)
|
13
|
-
Array.wrap(key) + [I18n.locale.to_s]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require "cache_with_locale/railtie"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_with_locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -78,6 +78,8 @@ files:
|
|
78
78
|
- README.md
|
79
79
|
- Rakefile
|
80
80
|
- lib/cache_with_locale.rb
|
81
|
+
- lib/cache_with_locale/collection_caching.rb
|
82
|
+
- lib/cache_with_locale/helpers.rb
|
81
83
|
- lib/cache_with_locale/railtie.rb
|
82
84
|
- lib/cache_with_locale/version.rb
|
83
85
|
- lib/tasks/cache_with_locale_tasks.rake
|
@@ -85,7 +87,7 @@ homepage: https://github.com/igorkasyanchuk
|
|
85
87
|
licenses:
|
86
88
|
- MIT
|
87
89
|
metadata: {}
|
88
|
-
post_install_message:
|
90
|
+
post_install_message:
|
89
91
|
rdoc_options: []
|
90
92
|
require_paths:
|
91
93
|
- lib
|
@@ -100,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
- !ruby/object:Gem::Version
|
101
103
|
version: '0'
|
102
104
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
104
|
-
signing_key:
|
105
|
+
rubygems_version: 3.3.26
|
106
|
+
signing_key:
|
105
107
|
specification_version: 4
|
106
108
|
summary: Automatic fragment caching in Rails with locales
|
107
109
|
test_files: []
|