jekyll-cache 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 999222f8c1428d0a0e7323f68095209d3831da59
4
+ data.tar.gz: 417b41339b40d0e6ddb522db4bf74002f90e21ed
5
+ SHA512:
6
+ metadata.gz: 5c8eadfed318f0bd0d15bbe0b92dd05082c014b701104890501e4daa95f3abf3bd018b90e95f9dd7df91dca783ac720378e060ee13a5017a2b96b25c38a124fa
7
+ data.tar.gz: bceb3e98be5fdb5312231ab93d579a6ebcf9339954b92ff77251ab82fd1c79afcc04ccd9157426496047af1bb2dd508dd920af6d4f217c0582416c45a6a1ca6e
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ gem "rake"
5
+ gem "pry"
6
+
7
+ if ENV["JEKYLL_VERSION"]
8
+ # So we can test across all our supported.
9
+ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
10
+ end
@@ -0,0 +1,5 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require "jekyll/cache"
@@ -0,0 +1,46 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require "jekyll/sanity"
6
+ require "jekyll/log_wrapper"
7
+ require "jekyll"
8
+
9
+
10
+ module Jekyll
11
+ module Cache
12
+ autoload :FileStore, "jekyll/cache/file_store"
13
+ autoload :MemoryStore, \
14
+ "jekyll/cache/memory_store"
15
+
16
+ # --
17
+ # Clear the entire cache.
18
+ # @note Doesn't matter if it exists.
19
+ # @return [true,false]
20
+ # --
21
+ def self.clear
22
+ if Jekyll.cache_dir && Jekyll.cache_dir.directory?
23
+ return Jekyll.cache_dir.rm_rf
24
+ end
25
+ end
26
+
27
+ # --
28
+ # @return [Jekyll::LogWrapper]
29
+ # Creates a log wrapper for ActiveSupport
30
+ # @see Jekyll::LogWrapper
31
+ # --
32
+ def self.logger
33
+ @logger ||= LogWrapper.new(Jekyll.logger)
34
+ end
35
+ end
36
+
37
+ # --
38
+ # @note this should always use FileStore.
39
+ # A global cache that uses the FileStore. This is meant
40
+ # for quick caching (or) one off caching.
41
+ # @return [FileStore] the new cache.
42
+ # --
43
+ def self.cache
44
+ @cache ||= Cache::FileStore.new("global")
45
+ end
46
+ end
@@ -0,0 +1,65 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require_relative "../cache"
6
+ require "active_support/cache"
7
+ require "forwardable/extended"
8
+ require "jekyll/sanity"
9
+
10
+ module Jekyll
11
+ module Cache
12
+ class FileStore < ActiveSupport::Cache::FileStore
13
+ def self.clear
14
+ Cache.method(:clear).call
15
+ end
16
+
17
+ # --
18
+ # @return [<EnvyGeeks::Cache>] the cache
19
+ # Overrides the default method so that we can simply
20
+ # pass in the name of the directory we want to store
21
+ # cache files inside of
22
+ # @see https://goo.gl/3G35gw
23
+ # --
24
+ def initialize(dir)
25
+ super(Jekyll.cache_dir.join(dir))
26
+ self.logger = Cache.logger
27
+ end
28
+
29
+ # --
30
+ # So that users don't freak out.
31
+ # @return nil
32
+ # --
33
+ def middleware
34
+ nil
35
+ end
36
+
37
+ # --
38
+ # @param key [String,Symbol] the cache key.
39
+ # Overrides `fetch` so that we can automatically
40
+ # (immediately) expire if we are in development, without
41
+ # the need for any one class to carry expirey data.
42
+ # @return [<Any>] the cached value.
43
+ # --
44
+ def fetch(key, **opts)
45
+ opts[:expires_in] = expires_in unless opts.key?(:expires_in)
46
+ return yield if opts[:expires_in] == 0.minutes
47
+ super(key, **opts) do
48
+ yield
49
+ end
50
+ end
51
+
52
+ # --
53
+ # @return [ActiveSupport::Duration] the time.
54
+ # Tells you how long until we plan to expire something
55
+ # In production this is always set to 0 minutes, in dev
56
+ # it's set to around 6 minutes, this way your sites
57
+ # don't build slow when you are working.
58
+ # --
59
+ private
60
+ def expires_in
61
+ (Jekyll.env == "development" ? 24 : 0).minutes
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,36 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require "active_support/cache"
6
+ require_relative "../cache"
7
+
8
+ module Jekyll
9
+ module Cache
10
+ class MemoryStore < ActiveSupport::Cache::MemoryStore
11
+ def self.clear
12
+ Cache.method(:clear).call
13
+ end
14
+
15
+ # --
16
+ # @return [<EnvyGeeks::Cache>] the cache
17
+ # Overrides the default method so that we can simply
18
+ # pass in the name of the directory we want to store
19
+ # cache files inside of
20
+ # @see https://goo.gl/3G35gw
21
+ # --
22
+ def initialize(*args)
23
+ self.logger = Cache.logger
24
+ super(*args)
25
+ end
26
+
27
+ # --
28
+ # So that users don't freak out.
29
+ # @return nil
30
+ # --
31
+ def middleware
32
+ nil
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Cache
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-cache
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jordon Bedwell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4'
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.0'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: luna-rspec-formatters
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.7'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.7'
67
+ - !ruby/object:Gem::Dependency
68
+ name: jekyll-log-wrapper
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.0'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.0'
81
+ - !ruby/object:Gem::Dependency
82
+ name: jekyll-sanity
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: jekyll
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '3.1'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '3.1'
109
+ description: Caching for Jekyll
110
+ email:
111
+ - jordon@envygeeks.io
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files: []
115
+ files:
116
+ - Gemfile
117
+ - lib/jekyll-cache.rb
118
+ - lib/jekyll/cache.rb
119
+ - lib/jekyll/cache/file_store.rb
120
+ - lib/jekyll/cache/memory_store.rb
121
+ - lib/jekyll/cache/version.rb
122
+ homepage: http://github.com/envygeeks/jekyll-cache
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 2.1.0
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.6.11
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: A cache library that wraps around ActiveSupport
146
+ test_files: []