slimmer 10.1.2 → 10.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/slimmer/component_resolver.rb +0 -6
- data/lib/slimmer/govuk_components.rb +25 -1
- data/lib/slimmer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c68306884f599c1b2c0ec09ab343531783a40465
|
4
|
+
data.tar.gz: 3c6e6dfed7ca6d702b47f36a93f933d4a842fbc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25903ce0805883946d9485de6db6526f583f3e93673dfae7b36c30808ae054d9a2248658f3971a7d75480457995810fe78cb1cf36c4a1461c3e230d16ba29579
|
7
|
+
data.tar.gz: f2de6e5c472d76b9f5ce879591efe8479e8ae53711182c076805a18ad7c2b83d227942c8f0a2acfc0cf38479d153eca24e77ee432eb5e22fc0b8d1be9bcd2625
|
data/CHANGELOG.md
CHANGED
@@ -5,12 +5,6 @@ module Slimmer
|
|
5
5
|
class ComponentResolver < ::ActionView::Resolver
|
6
6
|
TEST_TAG_NAME = 'test-govuk-component'
|
7
7
|
|
8
|
-
def self.caching
|
9
|
-
# this turns off the default ActionView::Resolver caching which caches
|
10
|
-
# all templates for the duration of the current process in production
|
11
|
-
false
|
12
|
-
end
|
13
|
-
|
14
8
|
def find_templates(name, prefix, partial, details, outside_app_allowed = false)
|
15
9
|
return [] unless prefix == 'govuk_component'
|
16
10
|
|
@@ -17,17 +17,41 @@ module Slimmer
|
|
17
17
|
|
18
18
|
# @private
|
19
19
|
def add_govuk_components
|
20
|
-
append_view_path
|
20
|
+
append_view_path GovukComponents.expiring_resolver_cache.resolver
|
21
21
|
|
22
22
|
return if slimmer_backend_included?
|
23
23
|
I18n.backend = I18n::Backend::Chain.new(I18n.backend, Slimmer::I18nBackend.new)
|
24
24
|
end
|
25
25
|
|
26
|
+
# @private
|
27
|
+
def self.expiring_resolver_cache
|
28
|
+
@expiring_resolver_cache ||= TimedExpirationResolverCache.new
|
29
|
+
end
|
30
|
+
|
26
31
|
private
|
27
32
|
|
28
33
|
def slimmer_backend_included?
|
29
34
|
I18n.backend.is_a?(I18n::Backend::Chain) &&
|
30
35
|
I18n.backend.backends.any? { |b| b.is_a? Slimmer::I18nBackend }
|
31
36
|
end
|
37
|
+
|
38
|
+
# Slimmer::ComponentResolver instantiates a lot of large objects and leaks
|
39
|
+
# memory. This class will cache the resolver so that it doesn't have to
|
40
|
+
# create new ActionView::Template objects for each request. The cache is
|
41
|
+
# timed to allow frontends to pick up changes made to components in `static`.
|
42
|
+
class TimedExpirationResolverCache
|
43
|
+
def initialize
|
44
|
+
@cache_last_reset = Time.now
|
45
|
+
end
|
46
|
+
|
47
|
+
def resolver
|
48
|
+
if (@cache_last_reset + Slimmer::CACHE_TTL) < Time.now
|
49
|
+
@resolver = nil
|
50
|
+
@cache_last_reset = Time.now
|
51
|
+
end
|
52
|
+
|
53
|
+
@resolver ||= Slimmer::ComponentResolver.new
|
54
|
+
end
|
55
|
+
end
|
32
56
|
end
|
33
57
|
end
|
data/lib/slimmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.1.
|
4
|
+
version: 10.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|