jekyll-include-cache 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: 9b6464521578087ce391414656f84402b6d5fee9
4
- data.tar.gz: 2b33a085424f180f657dc7affb007b39d73b7888
2
+ SHA256:
3
+ metadata.gz: 3e6037c7adef63e056b1e55aea33af25cf9ac078fce0cf85862384ba21c63ca3
4
+ data.tar.gz: 75b0fa20d4e03178622426c22251a6f19662ad3892d99886ab884e674e772ad6
5
5
  SHA512:
6
- metadata.gz: bc2767f09b4a18d2041e22eec11e70706b9233795bc1767f20160e90a1a23dcd90500220c70a53d650b06c85f0827d31ea30fdcf0e32ba1b317bcdba64695871
7
- data.tar.gz: 54b05b36a7ce0ada74213908e1bc09389b0c9b518ff62dd26a7ceb2a5138ef7b88a9ee51763ee1070954022db0f4bba425f9f9b9832cf8af8df4c5010ec6ae22
6
+ metadata.gz: a9764c74d5e856dcb20221b0140029c52f70a179b6778619a81e7e80e9d6c639230252ab272128409efad98768794e4e274a3784cd0e47d23f6f03f69b5c7a28
7
+ data.tar.gz: facde92105c74ea1f97620df3bb3441946ab6df071e8675d3b1bf3135a1507abe609f4ca70a74bfc4238119f651874a384ca87d965d6707a1f57683148371519
@@ -1,11 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "jekyll"
2
4
 
3
5
  module JekyllIncludeCache
4
- autoload :Tag, "jekyll-include-cache/tag"
6
+ autoload :Tag, "jekyll-include-cache/tag"
7
+ autoload :Cache, "jekyll-include-cache/cache"
8
+
9
+ class << self
10
+ def cache
11
+ @cache ||= if defined? Jekyll::Cache
12
+ Jekyll::Cache.new(self.class.name)
13
+ else
14
+ JekyllIncludeCache::Cache.new
15
+ end
16
+ end
5
17
 
6
- def self.cache
7
- @cache ||= {}
18
+ def reset
19
+ JekyllIncludeCache.cache.clear
20
+ end
8
21
  end
9
22
  end
10
23
 
11
24
  Liquid::Template.register_tag("include_cached", JekyllIncludeCache::Tag)
25
+ Jekyll::Hooks.register :site, :pre_render do |_site|
26
+ JekyllIncludeCache.reset
27
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Jekyll 4.x comptable caching class for pre-4.x compatability
4
+ module JekyllIncludeCache
5
+ class Cache
6
+ extend Forwardable
7
+
8
+ def_delegators :@cache, :[]=, :key?, :delete, :clear
9
+
10
+ def initialize(_name = nil)
11
+ @cache = {}
12
+ end
13
+
14
+ def getset(key)
15
+ if key?(key)
16
+ @cache[key]
17
+ else
18
+ value = yield
19
+ @cache[key] = value
20
+ value
21
+ end
22
+ end
23
+
24
+ def [](key)
25
+ if key?(key)
26
+ @cache[key]
27
+ else
28
+ raise
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "digest/md5"
2
4
 
3
5
  module JekyllIncludeCache
@@ -5,14 +7,12 @@ module JekyllIncludeCache
5
7
  def render(context)
6
8
  path = path(context)
7
9
  params = parse_params(context) if @params
10
+ key = key(path, params)
8
11
  return unless path
9
12
 
10
- key = key(path, params)
11
- cached = JekyllIncludeCache.cache[key]
12
-
13
- if cached
13
+ if JekyllIncludeCache.cache.key?(key)
14
14
  Jekyll.logger.debug "Include cache hit:", path
15
- cached
15
+ JekyllIncludeCache.cache[key]
16
16
  else
17
17
  Jekyll.logger.debug "Include cache miss:", path
18
18
  JekyllIncludeCache.cache[key] = super
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JekyllIncludeCache
2
- VERSION = "0.1.0".freeze
4
+ VERSION = "0.2.0"
3
5
  end
metadata CHANGED
@@ -1,57 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-include-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-19 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.7'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '3.3'
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.7'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
23
36
  requirements:
24
37
  - - "~>"
25
38
  - !ruby/object:Gem::Version
26
- version: '3.3'
39
+ version: '3.5'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.5'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: rubocop
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '0.43'
53
+ version: '0.51'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '0.43'
60
+ version: '0.51'
41
61
  - !ruby/object:Gem::Dependency
42
- name: rspec
62
+ name: rubocop-jekyll
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
45
65
  - - "~>"
46
66
  - !ruby/object:Gem::Version
47
- version: '3.5'
67
+ version: '0.3'
48
68
  type: :development
49
69
  prerelease: false
50
70
  version_requirements: !ruby/object:Gem::Requirement
51
71
  requirements:
52
72
  - - "~>"
53
73
  - !ruby/object:Gem::Version
54
- version: '3.5'
74
+ version: '0.3'
55
75
  description:
56
76
  email:
57
77
  - ben.balter@github.com
@@ -60,6 +80,7 @@ extensions: []
60
80
  extra_rdoc_files: []
61
81
  files:
62
82
  - lib/jekyll-include-cache.rb
83
+ - lib/jekyll-include-cache/cache.rb
63
84
  - lib/jekyll-include-cache/tag.rb
64
85
  - lib/jekyll-include-cache/version.rb
65
86
  homepage: https://github.com/benbalter/jekyll-include-cache
@@ -81,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
102
  - !ruby/object:Gem::Version
82
103
  version: '0'
83
104
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.5.2
105
+ rubygems_version: 3.0.3
86
106
  signing_key:
87
107
  specification_version: 4
88
108
  summary: A Jekyll plugin to cache the rendering of Liquid includes