Commit d8973cae authored by Sylvester Keil's avatar Sylvester Keil

Added cucumber environment

parent 56674158
source :rubygems
gemspec
gem 'unicode_utils'
group :development do
gem 'ruby-debug19', :platforms => [:ruby_19]
gem 'ruby-debug', :platforms => [:ruby_18]
end
\ No newline at end of file
Feature: BibTeX
As a scholar who likes to blog
I want to publish my BibTeX bibliography on my blog
In order to share my awesome references with my peers
Scenario: Simple Bibliography
Given I have a configuration file with "citation_style" set to "apa"
And I have a page "references.bib":
"""
---
---
@book{ruby,
title = {The Ruby Programming Language},
author = {Flanagan, David and Matsumoto, Yukihiro},
year = {2008},
publisher = {O'Reilly Media}
}
"""
When I run jekyll
Then the _site directory should exist
And the "_site/references.html" file should exist
And I should see "<i>The Ruby Programming Language</i>" in "_site/references.html"
Before do
FileUtils.rm_rf(TEST_DIR)
FileUtils.mkdir(TEST_DIR)
Dir.chdir(TEST_DIR)
end
After do
Dir.chdir(TEST_DIR)
FileUtils.rm_rf(TEST_DIR)
end
# Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
Given /^I have an? "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
File.open(file, 'w') do |f|
f.write <<EOF
---
#{key || 'layout'}: #{value || 'nil'}
---
#{text}
EOF
f.close
end
end
Given /^I have an? "(.*)" file that contains "(.*)"$/ do |file, text|
File.open(file, 'w') do |f|
f.write(text)
f.close
end
end
Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
File.open('_config.yml', 'w') do |f|
f.write("#{key}: #{value}\n")
f.close
end
end
Given /^I have a configuration file with:$/ do |table|
File.open('_config.yml', 'w') do |f|
table.hashes.each do |row|
f.write("#{row["key"]}: #{row["value"]}\n")
end
f.close
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
Then /^the (.*) directory should exist$/ do |dir|
assert File.directory?(dir)
end
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
assert_match Regexp.new(text), File.open(file).readlines.join
end
Then /^the "(.*)" file should exist$/ do |file|
assert File.file?(file)
end
Then /^the "(.*)" file should not exist$/ do |file|
assert !File.exists?(file)
end
Given /^I have a page "([^"]*)":$/ do |file, string|
File.open(file, 'w') do |f|
f.write(string)
end
end
require 'rr'
require 'test/unit'
require 'jekyll/scholar'
require 'ruby-debug'
Debugger.start
World do
include Test::Unit::Assertions
end
TEST_DIR = File.join('/', 'tmp', 'jekyll')
def run_jekyll(options = {})
options['source'] ||= TEST_DIR
options['destination'] ||= File.join(TEST_DIR, '_site')
options = Jekyll.configuration(options)
site = Jekyll::Site.new(options)
site.process
end
......@@ -18,14 +18,19 @@ Gem::Specification.new do |s|
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = s.name
s.add_dependency('jekyll', '~> 0.10')
s.add_runtime_dependency('jekyll', '~> 0.10')
s.add_runtime_dependency('citeproc-ruby', '>= 0.0.1')
s.add_runtime_dependency('bibtex-ruby', '>= 1.3.7')
s.add_development_dependency('bundler', '~> 1.0')
s.add_development_dependency('rdoc', '~> 2.5')
s.add_development_dependency('rake', '>= 0.8')
s.add_development_dependency('rspec', '~> 2.5')
s.add_development_dependency('cucumber', '~> 0.3')
s.add_development_dependency('redgreen', ">= 1.2.2")
s.add_development_dependency('shoulda', ">= 2.11.3")
s.add_development_dependency('rr', ">= 1.0.2")
s.add_development_dependency('cucumber', ">= 0.10.0")
s.add_development_dependency('RedCloth', ">= 4.2.1")
s.add_development_dependency('rdiscount', ">= 1.6.5")
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
......
require 'jekyll'
require 'jekyll/scholar/version'
require 'jekyll/scholar/converters/bibtex'
......@@ -13,14 +13,12 @@ module Jekyll
citation_locale en
}].freeze
PATTERN = (/^\.bib(tex)?$/i).freeze
PATTERN = (/bib(tex)?$/i).freeze
EXTENSION = '.html'.freeze
def initialize (config = {})
super
@config['scholar'] = DEFAULTS.merge(@config['scholar'] || {})
@citeproc = CiteProc::Processor.new :style => @config['citation_style'],
:locale => @config['citation_locale'], :format => 'html'
@markdown = MarkdownConverter.new config
end
......@@ -28,12 +26,13 @@ module Jekyll
def output_ext (extension); EXTENSION; end
def convert(content)
def convert (content)
content = BibTeX.parse(content, :include => [:meta_content]).map do |b|
if b.respond_to? :to_citeproc
@citeproc.bibliography(b.to_citeproc).data.join
if b.respond_to?(:to_citeproc)
CiteProc.process b.to_citeproc, :style => @config['citation_style'],
:locale => @config['citation_locale'], :format => 'html'
else
b.is_a? BibTeX::MetaContent ? b.to_s : ''
b.is_a?(BibTeX::MetaContent) ? b.to_s : ''
end
end
@markdown.convert(content.join("\n"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment