quintype-liquid 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: ac1ddb27ce800219d1d39260cd06a92629442dc1
4
- data.tar.gz: 8fe24b80efbfa962c19508a054a470ca429672ab
3
+ metadata.gz: f9dc51862140d4bdffaf91ce3851e588b000eab3
4
+ data.tar.gz: 87592a5280a1fbebb546999710c8f6b9a25b6980
5
5
  SHA512:
6
- metadata.gz: 02e2676ae099f80c61a934366fe07e42974e031fd38f84be0492bb472221b1c49aa98dc11374edf954b9bb2f19fbe775f5e54d30c470de9bb90e36fe6437fde8
7
- data.tar.gz: dcfeda8a97a130f77f3841ddd86c293148e88933184311c42ab975d0bf527118ddddf85dfb3d5f700effd5508ef5ea5692ebad44479b8d3837b692671a40c6d4
6
+ metadata.gz: 7dbeccf50c78d2b7af979696e755904d0f7eb49fe672eff1898f8e18ffcfa3a71f7e9685c655c2d29c76a67ae09eb70e5dfa84af3717a584e390b7fcfe8e6552
7
+ data.tar.gz: 6e12889b0da66f4ea18bb2ea61821f657dde095c4fd774208debeed5001af1235dee37c3b100f52e85be867d6c7edf2b5f3812aa00d485c284b4f90ef45b4caf
@@ -1,6 +1,8 @@
1
- require "liquid-rails"
2
1
  require "quintype/liquid/version"
3
2
 
3
+ require "liquid-rails"
4
+ require "concurrent"
5
+
4
6
  module Quintype
5
7
  module Liquid
6
8
  autoload :Templates, "quintype/liquid/templates"
@@ -1,14 +1,18 @@
1
1
  module Quintype::Liquid
2
2
  class FileSystem < ::Liquid::LocalFileSystem
3
- def caching_enabled?
4
- Rails.env.production?
5
- end
6
-
7
3
  def read_file(path)
8
4
  full_path = full_path(path)
9
5
  File.read(full_path) if File.exists?(full_path)
10
6
  end
11
7
 
8
+ def read_file_with_caching(path)
9
+ @cached_templates ||= Concurrent::Map.new do |m, path|
10
+ m[path] = read_file_without_caching(path)
11
+ end
12
+ @cached_templates[path]
13
+ end
14
+ alias_method_chain :read_file, :caching if defined?(Rails) && Rails.env.production?
15
+
12
16
  def read_template_file(template_path, context)
13
17
  controller = context.registers[:controller]
14
18
  controller_path = controller.controller_path
@@ -20,7 +24,7 @@ module Quintype::Liquid
20
24
  path = template_path.include?('/') ? template_path : "#{controller_path}/#{template_path}"
21
25
  path = path + format
22
26
 
23
- file = caching_enabled? ? Rails.cache.fetch(cache_path(path)) { read_file(path) } : read_file(path)
27
+ file = read_file(path)
24
28
 
25
29
  break if file
26
30
  end
@@ -43,9 +47,5 @@ module Quintype::Liquid
43
47
 
44
48
  full_path
45
49
  end
46
-
47
- def cache_path(path)
48
- "liquid:#{path}"
49
- end
50
50
  end
51
51
  end
@@ -6,12 +6,12 @@ module Quintype::Liquid
6
6
  end
7
7
 
8
8
  initializer "quintype-liquid.liquid-file-system" do |app|
9
- template_path = ::Rails.root.join('app/views')
9
+ template_path = Rails.root.join('app/views')
10
10
  ::Liquid::Template.file_system = Quintype::Liquid::FileSystem.new(template_path)
11
11
  end
12
12
 
13
13
  initializer "quintype-liquid.fix-caching" do |app|
14
- ::Liquid::Rails::TemplateHandler.send(:prepend, Quintype::Liquid::LiquidTemplateCachingModule)
14
+ ::Liquid::Rails::TemplateHandler.send(:prepend, Quintype::Liquid::LiquidTemplateCachingModule) unless Rails.env.development?
15
15
  end
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  module Quintype
2
2
  module Liquid
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quintype-liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tejas Dinkar