tzispa_rig 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/tzispa/rig/engine.rb +17 -17
- data/lib/tzispa/rig/parsernext.rb +4 -0
- data/lib/tzispa/rig/template.rb +4 -0
- data/lib/tzispa/rig/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: 34c29a6d0cb71518ba08bf0c7c3274ac6a1cad35
|
4
|
+
data.tar.gz: 23a5a9a18a5d22e871a51b5085d730b47f4676ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2780edabd2cbf6d049860a10eb04363c094a9b851a5ec95fd3b394cb34389b483cb4613418f7430bc791f942c9b3d55143d73853cd985402207be25e5deceb59
|
7
|
+
data.tar.gz: 8bbffe98a3a17c8a33d646980bc95f1ce3e7828f8779d323230c95b51d1897b335b3b5c2b67c5fc18b525085f94770ea0778b8c6def762b34028df2e88d71914
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@ Tzispa Rig
|
|
2
2
|
|
3
3
|
Rig templates implementation
|
4
4
|
|
5
|
+
## 0.3.4
|
6
|
+
- fix template cache returning empty template sometimes
|
7
|
+
|
5
8
|
## 0.3.3
|
6
9
|
- Raise a custom exception when a binder tag does not exists in the template
|
7
10
|
- Raise custom exception when there are duplicated loops in binder
|
data/lib/tzispa/rig/engine.rb
CHANGED
@@ -13,8 +13,7 @@ module Tzispa
|
|
13
13
|
|
14
14
|
def initialize(app, cache_enabled, cache_size)
|
15
15
|
@app = app
|
16
|
-
@cache = LruRedux::
|
17
|
-
@mutex = Mutex.new
|
16
|
+
@cache = LruRedux::ThreadSafeCache.new(cache_size) if cache_enabled
|
18
17
|
end
|
19
18
|
|
20
19
|
def layout(name:, format:nil, params:nil)
|
@@ -31,13 +30,7 @@ module Tzispa
|
|
31
30
|
|
32
31
|
def rig_template(name, type, tpl_format, params, parent)
|
33
32
|
if @cache
|
34
|
-
|
35
|
-
cache_template(name, type, tpl_format, params, parent)
|
36
|
-
else
|
37
|
-
@mutex.synchronize {
|
38
|
-
cache_template(name, type, tpl_format, params, parent)
|
39
|
-
}
|
40
|
-
end
|
33
|
+
cache_template(name, type, tpl_format, params, parent)
|
41
34
|
else
|
42
35
|
Template.new(name: name, type: type, format: tpl_format, domain: @app.domain, params: params, parent: parent, engine: self).load!.parse!
|
43
36
|
end
|
@@ -46,18 +39,25 @@ module Tzispa
|
|
46
39
|
private
|
47
40
|
|
48
41
|
def cache_template(name, type, tpl_format, params, parent)
|
49
|
-
|
50
|
-
|
51
|
-
Template.new(name: name, type: type, format: tpl_format, domain: @app.domain, parent: parent, engine: self).load!.parse!
|
52
|
-
}
|
53
|
-
if tpl.modified?
|
54
|
-
tpl = @cache[ktpl] = Template.new(name: name, type: type, format: tpl_format, domain: @app.domain, parent: parent, engine: self).load!.parse!
|
55
|
-
end
|
56
|
-
tpl.dup.tap { |ctpl|
|
42
|
+
key = "#{type}__#{name}".to_sym
|
43
|
+
(get_template(key, name, type, tpl_format, parent) || set_template(key, name, type, tpl_format, parent)).dup.tap { |ctpl|
|
57
44
|
ctpl.params = params if params
|
58
45
|
}
|
59
46
|
end
|
60
47
|
|
48
|
+
def get_template(key, name, type, tpl_format, parent)
|
49
|
+
if @cache.key?(key) && (@cache[key].modified? || !@cache[key].valid?)
|
50
|
+
set_template(key, name, type, tpl_format, parent)
|
51
|
+
else
|
52
|
+
@cache[key]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def set_template(key, name, type, tpl_format, parent)
|
58
|
+
@cache[key] = Template.new(name: name, type: type, format: tpl_format, domain: @app.domain, parent: parent, engine: self).load!.parse!
|
59
|
+
end
|
60
|
+
|
61
61
|
end
|
62
62
|
|
63
63
|
end
|
data/lib/tzispa/rig/template.rb
CHANGED
data/lib/tzispa/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzispa_helpers
|