cache_with_locale 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +31 -1
- 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 +37 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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,4 +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
|
+
[![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)
|
2
4
|
|
3
5
|
# Rails cache with locale
|
4
6
|
Automatically adding current application locale (I18n.locale) as a part of caching key in Rails views.
|
@@ -26,6 +28,12 @@ This gem is a simple solution which allows you to DRY your code. So now you can
|
|
26
28
|
|
27
29
|
And let gem handle all work. You don't need to specify locale as a cache sufix/prefix.
|
28
30
|
|
31
|
+
This gem also works for collection caching like this:
|
32
|
+
|
33
|
+
```
|
34
|
+
= render partial: :post, collection: @posts, cached: true
|
35
|
+
```
|
36
|
+
|
29
37
|
## Usage
|
30
38
|
Just add this gem to your Gemfile.
|
31
39
|
|
@@ -42,7 +50,29 @@ $ bundle
|
|
42
50
|
```
|
43
51
|
|
44
52
|
## Contributing
|
45
|
-
|
53
|
+
|
54
|
+
Contributors:
|
55
|
+
|
56
|
+
|
57
|
+
- https://github.com/pfeiffer
|
58
|
+
- https://github.com/dlackty
|
59
|
+
|
60
|
+
## Change Log
|
61
|
+
|
62
|
+
0.0.3
|
63
|
+
|
64
|
+
- https://github.com/igorkasyanchuk/cache_with_locale/pull/3
|
65
|
+
|
66
|
+
0.0.2
|
67
|
+
|
68
|
+
- https://github.com/igorkasyanchuk/cache_with_locale/pull/2
|
69
|
+
|
70
|
+
0.0.1
|
71
|
+
|
72
|
+
- initial version, ready for production
|
46
73
|
|
47
74
|
## License
|
48
75
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
76
|
+
|
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,17 +1,45 @@
|
|
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
|
-
name:
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: actionview
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
45
|
- - ">="
|
@@ -50,6 +78,8 @@ files:
|
|
50
78
|
- README.md
|
51
79
|
- Rakefile
|
52
80
|
- lib/cache_with_locale.rb
|
81
|
+
- lib/cache_with_locale/collection_caching.rb
|
82
|
+
- lib/cache_with_locale/helpers.rb
|
53
83
|
- lib/cache_with_locale/railtie.rb
|
54
84
|
- lib/cache_with_locale/version.rb
|
55
85
|
- lib/tasks/cache_with_locale_tasks.rake
|
@@ -57,7 +87,7 @@ homepage: https://github.com/igorkasyanchuk
|
|
57
87
|
licenses:
|
58
88
|
- MIT
|
59
89
|
metadata: {}
|
60
|
-
post_install_message:
|
90
|
+
post_install_message:
|
61
91
|
rdoc_options: []
|
62
92
|
require_paths:
|
63
93
|
- lib
|
@@ -72,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
102
|
- !ruby/object:Gem::Version
|
73
103
|
version: '0'
|
74
104
|
requirements: []
|
75
|
-
|
76
|
-
|
77
|
-
signing_key:
|
105
|
+
rubygems_version: 3.3.26
|
106
|
+
signing_key:
|
78
107
|
specification_version: 4
|
79
108
|
summary: Automatic fragment caching in Rails with locales
|
80
109
|
test_files: []
|