Merge pull request #2211 from jekyll/pgp-key-header-frontmatter

This commit is contained in:
Parker Moore 2014-04-14 12:59:59 -04:00
commit 4f66db6c38
4 changed files with 14 additions and 1 deletions

View File

@ -374,7 +374,7 @@ module Jekyll
end
def has_yaml_header?(file)
"---" == File.open(file) { |fd| fd.read(3) }
!!(File.open(file).read =~ /\A---\r?\n/)
end
def limit_posts!

2
test/source/pgp.key Normal file
View File

@ -0,0 +1,2 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)

View File

@ -48,6 +48,7 @@ class TestGeneratedSite < Test::Unit::TestCase
should "print a nice list of static files" do
expected_output = Regexp.new <<-OUTPUT
- /css/screen.css last edited at \\d+ with extname .css
- /pgp.key last edited at \\d+ with extname .key
- /products.yml last edited at \\d+ with extname .yml
- /symlink-test/symlinked-dir/screen.css last edited at \\d+ with extname .css
OUTPUT

View File

@ -187,6 +187,16 @@ class TestSite < Test::Unit::TestCase
assert_equal posts.size - @num_invalid_posts, @site.posts.size
end
should "read pages with yaml front matter" do
abs_path = File.expand_path("about.html", @site.source)
assert_equal true, @site.send(:has_yaml_header?, abs_path)
end
should "enforce a strict 3-dash limit on the start of the YAML front-matter" do
abs_path = File.expand_path("pgp.key", @site.source)
assert_equal false, @site.send(:has_yaml_header?, abs_path)
end
should "expose jekyll version to site payload" do
assert_equal Jekyll::VERSION, @site.site_payload['jekyll']['version']
end