curlybars 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ed9940570c86fee9f74999c8c87d78e39e8f276496d9dde4a235aa4fa09e60b
4
- data.tar.gz: cb01e427034963764cfac30318f3f637ba26e80bde93b70e30e0843643d61e20
3
+ metadata.gz: 52c29c45b57f92100b013838beeedfbf90786f38c53b16a80b5e8ce9c9375370
4
+ data.tar.gz: f3cb2ae061d3e34108f744ae194bbb2a73e87f189f99c672f76c29f91d330452
5
5
  SHA512:
6
- metadata.gz: c8e8af79c0b43dd99478dd3b8ab3e77efaf9abe423844850adb1ea50decb7a7084644e7f6d987bdc9142706317a77d7ff50b756be69e0c5fd4ed63d4b6559c28
7
- data.tar.gz: 42e0b53b95a8398a4c6dc53c64a0e9753a9844f342d2a1ee8e1abb47c9ab2847e5a7f83cc4e6b70cb487a5047ff5ddd44565d6fb6511c651ce70733f23ba1360
6
+ metadata.gz: 6506b677a75fcb692fdb89d65f959978287572a8149c77b2eb1035312a4dbd951e88cf4293a98a19da7beca6557f48c61ce5ac733d6cb37cf56c8ba17118a6bc
7
+ data.tar.gz: a3b173d94eebaac12907d143b01e8a28a07169ba23dc4c93502f452a76d95dac931c91ddb95cdd90951d8042cab73ff4c71e6181c11b5cce93598ea5216faac1
@@ -1,3 +1,5 @@
1
+ require 'digest'
2
+ require 'active_support/cache'
1
3
  require 'curlybars/version'
2
4
 
3
5
  # Curlybars is a view system based on Curly that uses Handlebars syntax.
@@ -23,12 +25,16 @@ module Curlybars
23
25
  #
24
26
  # Returns a String containing the Ruby code.
25
27
  def compile(source, identifier = nil)
26
- transformers = Curlybars.configuration.compiler_transformers
27
- transformed_source = transformers.inject(source) do |memo, transformer|
28
- transformer.transform(memo, identifier)
29
- end
28
+ cache_key = ["Curlybars.compile", identifier, Digest::SHA256.hexdigest(source)]
29
+
30
+ cache.fetch(cache_key) do
31
+ transformers = Curlybars.configuration.compiler_transformers
32
+ transformed_source = transformers.inject(source) do |memo, transformer|
33
+ transformer.transform(memo, identifier)
34
+ end
30
35
 
31
- ast(transformed_source, identifier, run_processors: true).compile
36
+ ast(transformed_source, identifier, run_processors: true).compile
37
+ end
32
38
  end
33
39
 
34
40
  # Validates the source against a presenter.
@@ -66,6 +72,12 @@ module Curlybars
66
72
  errors.empty?
67
73
  end
68
74
 
75
+ def cache
76
+ @cache ||= ActiveSupport::Cache::MemoryStore.new
77
+ end
78
+
79
+ attr_writer :cache
80
+
69
81
  private
70
82
 
71
83
  def ast(source, identifier, run_processors:)
@@ -7,6 +7,10 @@ module Curlybars
7
7
  ActionView::Template.register_template_handler(:hbs, Curlybars::TemplateHandler)
8
8
  end
9
9
 
10
+ initializer 'curlybars.set_cache' do
11
+ Curlybars.cache = Rails.cache
12
+ end
13
+
10
14
  if defined?(CacheDigests::DependencyTracker)
11
15
  CacheDigests::DependencyTracker.register_tracker :hbs, Curlybars::DependencyTracker
12
16
  end
@@ -1,3 +1,3 @@
1
1
  module Curlybars
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '1.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curlybars
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Libo Cannici
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2018-08-29 00:00:00.000000000 Z
16
+ date: 2018-10-02 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionpack
@@ -35,6 +35,26 @@ dependencies:
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
37
  version: '6.0'
38
+ - !ruby/object:Gem::Dependency
39
+ name: activesupport
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '4.2'
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '4.2'
55
+ - - "<"
56
+ - !ruby/object:Gem::Version
57
+ version: '6.0'
38
58
  - !ruby/object:Gem::Dependency
39
59
  name: ffi
40
60
  requirement: !ruby/object:Gem::Requirement