Skip to content

Commit

Permalink
Making sure excludes can work with a YAML array
Browse files Browse the repository at this point in the history
  • Loading branch information
qrush committed May 1, 2009
1 parent 252ca94 commit 53368cc
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
15 changes: 14 additions & 1 deletion features/site_configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Site configuration
Then the _mysite directory should exist
And I should see "Changing destination directory" in "_mysite/index.html"

Scenario: Exclude files
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"
And I have an "index.html" file that contains "I want to be included"
Expand All @@ -28,6 +28,19 @@ Feature: Site configuration
And the "_site/Rakefile" file should not exist
And the "_site/README" file should not exist

Scenario: Exclude files with YAML array
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"
And I have an "index.html" file that contains "I want to be included"
And I have a configuration file with "exclude" set to:
| Value |
| README |
| Rakefile |
When I run jekyll
Then I should see "I want to be included" in "_site/index.html"
And the "_site/Rakefile" file should not exist
And the "_site/README" file should not exist

Scenario: Use RDiscount for markup
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
And I have a configuration file with "markdown" set to "rdiscount"
Expand Down
15 changes: 15 additions & 0 deletions features/step_definitions/jekyll_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,25 @@
end
end

Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
File.open('_config.yml', 'w') do |f|
f.write("#{key}:\n")
table.hashes.each do |row|
f.write("- #{row["Value"]}\n")
end
f.close
end
end


When /^I run jekyll$/ do
run_jekyll
end

When /^I debug jekyll$/ do
run_jekyll(:debug => true)
end

When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
File.open(file, 'a') do |f|
f.write(text)
Expand Down
8 changes: 3 additions & 5 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
JEKYLL_PATH = File.join(ENV['PWD'], 'bin', 'jekyll')

def run_jekyll(opts = {})
if opts[:bg]
bg = '&'
end

system "#{JEKYLL_PATH} >> /dev/null"
command = JEKYLL_PATH
command << " >> /dev/null" if opts[:debug].nil?
system command
end
5 changes: 1 addition & 4 deletions lib/jekyll/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def initialize(config)
self.lsi = config['lsi']
self.pygments = config['pygments']
self.permalink_style = config['permalink'].to_sym

self.exclude = config['exclude'] || []

self.reset
Expand Down Expand Up @@ -230,11 +229,9 @@ def site_payload
def filter_entries(entries)
entries = entries.reject do |e|
unless ['_posts', '.htaccess'].include?(e)
# Reject backup/hidden
['.', '_', '#'].include?(e[0..0]) or e[-1..-1] == '~' or self.exclude.include?(e)
['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.include?(e)
end
end
end

end
end
8 changes: 8 additions & 0 deletions test/test_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,13 @@ class TestSite < Test::Unit::TestCase
assert_equal %w[foo.markdown bar.markdown baz.markdown], @site.filter_entries(ent1)
assert_equal ent2, @site.filter_entries(ent2)
end

should "filter entries with exclude" do
excludes = %w[README TODO]
includes = %w[index.html site.css]

@site.exclude = excludes
assert_equal includes, @site.filter_entries(excludes + includes)
end
end
end

0 comments on commit 53368cc

Please sign in to comment.