Merge pull request #1556 from maul-esel/dest-match

Fix up matching against source and destination when the two locations are similar.
This commit is contained in:
Matt Rogers 2013-09-16 18:34:22 -07:00
commit de49342324
3 changed files with 42 additions and 10 deletions

View File

@ -18,6 +18,27 @@ Feature: Site configuration
Then the _mysite directory should exist
And I should see "Changing destination directory" in "_mysite/index.html"
Scenario Outline: Similarly named source and destination
Given I have a blank site in "<source>"
And I have an "<source>/index.md" page that contains "markdown"
And I have a configuration file with:
| key | value |
| source | <source> |
| destination | <dest> |
When I run jekyll
Then the <source> directory should exist
And the "<dest>/index.html" file should <file_exist> exist
And I should see "markdown" in "<source>/index.md"
Examples:
| source | dest | file_exist |
| mysite_source | mysite | |
| mysite | mysite_dest | |
| mysite/ | mysite | not |
| mysite | ./mysite | not |
| mysite/source | mysite | not |
| mysite | mysite/dest | |
Scenario: Exclude files inline
Given I have an "Rakefile" file that contains "I want to be excluded"
And I have an "README" file that contains "I want to be excluded"

View File

@ -7,7 +7,7 @@ end
World(Test::Unit::Assertions)
Given /^I have a blank site in "(.*)"$/ do |path|
FileUtils.mkdir(path)
FileUtils.mkdir_p(path)
end
Given /^I do not have a "(.*)" directory$/ do |path|
@ -137,10 +137,14 @@ When /^I delete the file "(.*)"$/ do |file|
File.delete(file)
end
Then /^the (.*) directory should exist$/ do |dir|
Then /^the (.*) directory should +exist$/ do |dir|
assert File.directory?(dir), "The directory \"#{dir}\" does not exist"
end
Then /^the (.*) directory should not exist$/ do |dir|
assert !File.directory?(dir), "The directory \"#{dir}\" exists"
end
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
assert Regexp.new(text).match(File.open(file).readlines.join)
end
@ -157,12 +161,12 @@ Then /^I should see escaped "(.*)" in "(.*)"$/ do |text, file|
assert Regexp.new(Regexp.escape(text)).match(File.open(file).readlines.join)
end
Then /^the "(.*)" file should exist$/ do |file|
assert File.file?(file)
Then /^the "(.*)" file should +exist$/ do |file|
assert File.file?(file), "The file \"#{file}\" does not exist"
end
Then /^the "(.*)" file should not exist$/ do |file|
assert !File.exists?(file)
assert !File.exists?(file), "The file \"#{file}\" exists"
end
Then /^I should see today's time in "(.*)"$/ do |file|

View File

@ -63,11 +63,7 @@ module Jekyll
#
# Returns nothing.
def setup
# Check that the destination dir isn't the source dir or a directory
# parent to the source dir.
if self.source =~ /^#{self.dest}/
raise FatalException.new "Destination directory cannot be or contain the Source directory."
end
ensure_not_in_dest
# If safe mode is off, load in any Ruby files under the plugins
# directory.
@ -83,6 +79,17 @@ module Jekyll
self.generators = instantiate_subclasses(Jekyll::Generator)
end
# Check that the destination dir isn't the source dir or a directory
# parent to the source dir.
def ensure_not_in_dest
dest = Pathname.new(self.dest)
Pathname.new(self.source).ascend do |path|
if path == dest
raise FatalException.new "Destination directory cannot be or contain the Source directory."
end
end
end
# Internal: Setup the plugin search path
#
# Returns an Array of plugin search paths