diff --git a/features/support/env.rb b/features/support/env.rb index 0e0ad79a25197e098b96bf2977f5ac169e742799..eb71f74870cbac051036b0571474479a4db92cd2 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -17,10 +17,10 @@ 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) diff --git a/lib/jekyll/scholar/utilities.rb b/lib/jekyll/scholar/utilities.rb index feb8e5381c1d2c0758bc78ed10a2bb860e9f2e8b..7ac75d5f41f7f6cd32d26a960260968658eeaccf 100644 --- a/lib/jekyll/scholar/utilities.rb +++ b/lib/jekyll/scholar/utilities.rb @@ -2,11 +2,11 @@ module Jekyll class Scholar # Utility methods used by several Scholar plugins. The methods in this - # module may depend on the presence of #config, #bibtex_file, and + # module may depend on the presence of #config, #bibtex_files, and # #site readers module Utilities - attr_reader :bibtex_file, :config, :site, :query, + attr_reader :config, :site, :query, :context, :prefix, :key, :text def optparse(arguments) @@ -18,8 +18,8 @@ module Jekyll end opts.on('-f', '--file FILE') do |file| - @bibtex_file ||= [] - @bibtex_file << file + @bibtex_files ||= [] + @bibtex_files << file end opts.on('-q', '--query QUERY') do |query| @@ -48,6 +48,15 @@ module Jekyll parser.parse argv.map(&:strip).reject(&:empty?) end + def bibtex_files + @bibtex_files ||= [config['bibliography']] + end + + # :nodoc: backwards compatibility + def bibtex_file + bibtex_files[0] + end + def bibtex_options config['bibtex_options'] ||= {} end @@ -56,15 +65,23 @@ module Jekyll config['bibtex_filters'] ||= [] end + def bibtex_paths + @bibtex_paths ||= bibtex_files.map { |file| + extend_path file + } + end + + # :nodoc: backwards compatibility def bibtex_path - @bibtex_path ||= extend_path(bibtex_file) + bibtex_paths[0] end def bibliography unless @bibliography - tmp = "" - bibtex_path.each{|s| tmp << IO.read(s)} - @bibliography = BibTeX.parse(tmp, bibtex_options) + @bibliography = BibTeX.parse( + bibtex_paths.reduce('') { |s, p| s << IO.read(p) }, + bibtex_options + ) @bibliography.replace_strings if replace_strings? end @@ -112,22 +129,15 @@ module Jekyll def extend_path(name) if name.nil? || name.empty? - name = [config['bibliography']] + name = config['bibliography'] end - ret = [] + # return as is if it is an absolute path + return name if name.start_with?('/') && File.exists?(name) - name.each { |file| - # return as is if it is an absolute path - if file.start_with?('/') && File.exists?(file) - ret << file - else - p = File.join(config['source'], file) - p << '.bib' unless File.exists?(p) - ret << p - end - } - ret + p = File.join(config['source'], name) + p << '.bib' unless File.exists?(p) + p end def reference_tag(entry)