sitepress-core 2.0.0.beta7 → 2.0.0.beta8

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: 86ae1730830f940024cf418c59320540a22c1108017b6b8a54d9c75e53879b5b
4
- data.tar.gz: 9282851713b69e6456cc589761f741609b9f9c17a5ab47ec0c42eaa509bbb2c3
3
+ metadata.gz: 83c9ae67ef108b15908409feb2d555c718019e667c187713969372910e688580
4
+ data.tar.gz: 077afc29c48638240747ba35f3be4dda71f038645d1de08411d5337698d45b6a
5
5
  SHA512:
6
- metadata.gz: 78bbcf237ac225d6e90615e710163f65bb09bbc30fe017bb225ace3d4bf59a3186928bf02d75a8a9946812d04bdba7067c3d1eab35d6409f504f57bbd2df957f
7
- data.tar.gz: a6c5ee1a44dbfdf3516b6c51391f951dd863484018770651cd4d2dde3cf12133ac17c668eb54024210ceb2ddde80dfc0d18354e3f6dc9e4cd1cea2453a6c6c57
6
+ metadata.gz: 68622942e6fb27b292154b2ab5b344b6ba6a34008d151aef31d0b69989c732ad9c5eefdc69f335f31650d8c8652fdad9fe935e0c02c63910648194b0123f45dc
7
+ data.tar.gz: aa63c9d8b7fdb3c9dda60503192799d00cdd4ca8219047b04d632d21dc8ada33a61305ec9059ef0753a8dbbebd7e04a3aadf1a5f1e27cec71407cd2361edcbc2
@@ -17,7 +17,4 @@ module Sitepress
17
17
  autoload :ResourcesPipeline, "sitepress/resources_pipeline"
18
18
  autoload :Site, "sitepress/site"
19
19
  autoload :SourceNodeMapper, "sitepress/source_node_mapper"
20
- module Middleware
21
- autoload :RequestCache, "sitepress/middleware/request_cache"
22
- end
23
20
  end
@@ -14,26 +14,18 @@ module Sitepress
14
14
  attr_reader :root_path
15
15
  attr_writer :resources_pipeline
16
16
 
17
- # Cache resources for production runs of Sitepress. Development
18
- # modes don't cache to optimize for files reloading.
19
- attr_accessor :cache_resources
20
- alias :cache_resources? :cache_resources
21
-
22
17
  # TODO: Get rid of these so that folks have ot call site.resources.get ...
23
18
  extend Forwardable
24
19
  def_delegators :resources, :get, :glob
25
20
 
26
21
  def initialize(root_path: DEFAULT_ROOT_PATH)
27
22
  self.root_path = root_path
28
- # When Site#resources is called, the results should be cached in production
29
- # environments for performance reasons, but not in development environments.
30
- self.cache_resources = false
31
23
  end
32
24
 
33
25
  # A tree representation of the resourecs wthin the site. The root is a node that's
34
26
  # processed by the `resources_pipeline`.
35
27
  def root
36
- Node.new.tap do |node|
28
+ @root ||= Node.new.tap do |node|
37
29
  source_node_mapper.mount node
38
30
  resources_pipeline.process node
39
31
  end
@@ -41,13 +33,12 @@ module Sitepress
41
33
 
42
34
  # Returns a list of all the resources within #root.
43
35
  def resources
44
- with_resources_cache do
45
- ResourceCollection.new(node: root, root_path: pages_path)
46
- end
36
+ @resources ||= ResourceCollection.new(node: root, root_path: pages_path)
47
37
  end
48
38
 
49
- def clear_resources_cache
50
- @resources = nil
39
+ def reload!
40
+ @resources = @root = nil
41
+ self
51
42
  end
52
43
 
53
44
  # Root path to website project. Contains helpers, pages, and more.
@@ -108,10 +99,6 @@ module Sitepress
108
99
  end
109
100
 
110
101
  private
111
- def with_resources_cache
112
- clear_resources_cache unless cache_resources
113
- @resources ||= yield
114
- end
115
102
 
116
103
  def source_node_mapper
117
104
  @source_node_mapper ||= SourceNodeMapper.new(path: pages_path)
@@ -1,3 +1,3 @@
1
1
  module Sitepress
2
- VERSION = "2.0.0.beta7".freeze
2
+ VERSION = "2.0.0.beta8".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta7
4
+ version: 2.0.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,7 +79,6 @@ files:
79
79
  - lib/sitepress/extensions/proc_manipulator.rb
80
80
  - lib/sitepress/formats.rb
81
81
  - lib/sitepress/frontmatter.rb
82
- - lib/sitepress/middleware/request_cache.rb
83
82
  - lib/sitepress/node.rb
84
83
  - lib/sitepress/path.rb
85
84
  - lib/sitepress/resource.rb
@@ -1,26 +0,0 @@
1
- module Sitepress
2
- module Middleware
3
- # Reloads the Sitepress cache between requests if cache resources is enabled.
4
- # This ensures that the Sitepress resources are loaded only once per request
5
- # for development environments so that the site isn're reloaded per call. Used
6
- # from the Rails app and from the stand-alone Sitepress server.
7
- class RequestCache
8
- def initialize(app, site:)
9
- @app, @site = app, site
10
- end
11
-
12
- # Cache resources for the duration of the request, even if
13
- # caching is disabled.
14
- def call(env)
15
- cache_resources = @site.cache_resources
16
- begin
17
- @site.cache_resources = true
18
- @app.call env
19
- ensure
20
- @site.cache_resources = cache_resources
21
- @site.clear_resources_cache unless @site.cache_resources
22
- end
23
- end
24
- end
25
- end
26
- end