parent
25ad937597
commit
63b3739062
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
class Site
|
class Site
|
||||||
attr_reader :source, :dest, :config
|
attr_reader :source, :dest, :cache_dir, :config
|
||||||
attr_accessor :layouts, :pages, :static_files, :drafts,
|
attr_accessor :layouts, :pages, :static_files, :drafts,
|
||||||
:exclude, :include, :lsi, :highlighter, :permalink_style,
|
:exclude, :include, :lsi, :highlighter, :permalink_style,
|
||||||
:time, :future, :unpublished, :safe, :plugins, :limit_posts,
|
:time, :future, :unpublished, :safe, :plugins, :limit_posts,
|
||||||
|
|
@ -22,6 +22,8 @@ module Jekyll
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
@cache_dir = in_source_dir(config["cache_dir"])
|
||||||
|
|
||||||
@reader = Reader.new(self)
|
@reader = Reader.new(self)
|
||||||
@regenerator = Regenerator.new(self)
|
@regenerator = Regenerator.new(self)
|
||||||
@liquid_renderer = LiquidRenderer.new(self)
|
@liquid_renderer = LiquidRenderer.new(self)
|
||||||
|
|
@ -401,6 +403,18 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Prefix a given path with the cache directory.
|
||||||
|
#
|
||||||
|
# paths - (optional) path elements to a file or directory within the
|
||||||
|
# cache directory
|
||||||
|
#
|
||||||
|
# Returns a path which is prefixed with the cache directory.
|
||||||
|
def in_cache_dir(*paths)
|
||||||
|
paths.reduce(cache_dir) do |base, path|
|
||||||
|
Jekyll.sanitized_path(base, path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Public: The full path to the directory that houses all the collections registered
|
# Public: The full path to the directory that houses all the collections registered
|
||||||
# with the current site.
|
# with the current site.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,11 @@ class TestSite < JekyllUnitTest
|
||||||
assert File.directory?(source_dir(".jekyll-cache", "Jekyll", "Cache"))
|
assert File.directory?(source_dir(".jekyll-cache", "Jekyll", "Cache"))
|
||||||
assert File.directory?(source_dir(".jekyll-cache", "Jekyll", "Cache", "Jekyll--Cache"))
|
assert File.directory?(source_dir(".jekyll-cache", "Jekyll", "Cache", "Jekyll--Cache"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "use .jekyll-cache directory at source as cache_dir by default" do
|
||||||
|
site = Site.new(default_configuration)
|
||||||
|
assert_equal File.join(site.source, ".jekyll-cache"), site.cache_dir
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "creating sites" do
|
context "creating sites" do
|
||||||
|
|
@ -678,5 +683,23 @@ class TestSite < JekyllUnitTest
|
||||||
refute_equal mtime1, mtime2 # must be regenerated
|
refute_equal mtime1, mtime2 # must be regenerated
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "#in_cache_dir method" do
|
||||||
|
setup do
|
||||||
|
@site = Site.new(
|
||||||
|
site_configuration(
|
||||||
|
"cache_dir" => "../../custom-cache-dir"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create sanitized paths within the cache directory" do
|
||||||
|
assert_equal File.join(@site.source, "custom-cache-dir"), @site.cache_dir
|
||||||
|
assert_equal(
|
||||||
|
File.join(@site.source, "custom-cache-dir", "foo.md.metadata"),
|
||||||
|
@site.in_cache_dir("../../foo.md.metadata")
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue