jekyll-include-cache 0.2.0 → 0.2.1

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: 3e6037c7adef63e056b1e55aea33af25cf9ac078fce0cf85862384ba21c63ca3
4
- data.tar.gz: 75b0fa20d4e03178622426c22251a6f19662ad3892d99886ab884e674e772ad6
3
+ metadata.gz: 51b1596177a007df8290d24e47e6c3d24e1edadc6f077fed3ea76f263bc7a143
4
+ data.tar.gz: a2bd9f0d0c20f85e99dc85cd4b91ac374a9d31f4c07dfa54d41e73cefa531e84
5
5
  SHA512:
6
- metadata.gz: a9764c74d5e856dcb20221b0140029c52f70a179b6778619a81e7e80e9d6c639230252ab272128409efad98768794e4e274a3784cd0e47d23f6f03f69b5c7a28
7
- data.tar.gz: facde92105c74ea1f97620df3bb3441946ab6df071e8675d3b1bf3135a1507abe609f4ca70a74bfc4238119f651874a384ca87d965d6707a1f57683148371519
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
- Digest::MD5.hexdigest(path.to_s + params.to_s)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllIncludeCache
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  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.0
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: 2019-03-21 00:00:00.000000000 Z
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.0.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: []