jekyll-include-cache 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-include-cache/tag.rb +34 -1
- data/lib/jekyll-include-cache/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51b1596177a007df8290d24e47e6c3d24e1edadc6f077fed3ea76f263bc7a143
|
4
|
+
data.tar.gz: a2bd9f0d0c20f85e99dc85cd4b91ac374a9d31f4c07dfa54d41e73cefa531e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a91cb70e2ec36c19e56d40f21b888efb19d6ddba344d0d75c051700d38e50bc5507b14f2ad5adfe6cd9f973b33650bc618f0904cd9594b23d293f70bbc47631
|
7
|
+
data.tar.gz: d82200411f709c1f7b13fab467d632a14f49c22f603597ee71e3dbcb06a426f69745892cba8612388fc9a0d554e9439266d15aa996662c667e41bf040ee66353
|
@@ -4,6 +4,10 @@ require "digest/md5"
|
|
4
4
|
|
5
5
|
module JekyllIncludeCache
|
6
6
|
class Tag < Jekyll::Tags::IncludeTag
|
7
|
+
def self.digest_cache
|
8
|
+
@digest_cache ||= {}
|
9
|
+
end
|
10
|
+
|
7
11
|
def render(context)
|
8
12
|
path = path(context)
|
9
13
|
params = parse_params(context) if @params
|
@@ -28,7 +32,36 @@ module JekyllIncludeCache
|
|
28
32
|
end
|
29
33
|
|
30
34
|
def key(path, params)
|
31
|
-
|
35
|
+
path_hash = path.hash
|
36
|
+
params_hash = quick_hash(params)
|
37
|
+
self.class.digest_cache[path_hash] ||= {}
|
38
|
+
self.class.digest_cache[path_hash][params_hash] ||= digest(path_hash, params_hash)
|
39
|
+
end
|
40
|
+
|
41
|
+
def quick_hash(params)
|
42
|
+
return params.hash unless params
|
43
|
+
|
44
|
+
md5 = Digest::MD5.new
|
45
|
+
|
46
|
+
params.sort.each do |_, value|
|
47
|
+
# Using the fact that Jekyll documents don't change during a build.
|
48
|
+
# Instead of calculating the hash of an entire document (expensive!)
|
49
|
+
# we just use its object id.
|
50
|
+
if value.is_a? Jekyll::Drops::Drop
|
51
|
+
md5.update value.object_id.to_s
|
52
|
+
else
|
53
|
+
md5.update value.hash.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
md5.hexdigest
|
58
|
+
end
|
59
|
+
|
60
|
+
def digest(path_hash, params_hash)
|
61
|
+
md5 = Digest::MD5.new
|
62
|
+
md5.update path_hash.to_s
|
63
|
+
md5.update params_hash.to_s
|
64
|
+
md5.hexdigest
|
32
65
|
end
|
33
66
|
end
|
34
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-include-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0.3'
|
75
|
-
description:
|
75
|
+
description:
|
76
76
|
email:
|
77
77
|
- ben.balter@github.com
|
78
78
|
executables: []
|
@@ -87,7 +87,7 @@ homepage: https://github.com/benbalter/jekyll-include-cache
|
|
87
87
|
licenses:
|
88
88
|
- MIT
|
89
89
|
metadata: {}
|
90
|
-
post_install_message:
|
90
|
+
post_install_message:
|
91
91
|
rdoc_options: []
|
92
92
|
require_paths:
|
93
93
|
- lib
|
@@ -102,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
105
|
+
rubygems_version: 3.1.4
|
106
|
+
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: A Jekyll plugin to cache the rendering of Liquid includes
|
109
109
|
test_files: []
|