module Jekyll::Scholar::Utilities
Utility methods used by several Scholar
plugins. The methods in this module may depend on the presence of config
, bibtex_files
, and site
readers
Attributes
config[R]
context[R]
max[R]
offset[R]
prefix[R]
site[R]
text[R]
Public Instance Methods
allow_locale_overrides?()
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 128 def allow_locale_overrides? !!config['allow_locale_overrides'] end
bibliography_list_tag()
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 120 def bibliography_list_tag if @bibliography_list_tag.nil? config['bibliography_list_tag'] else @bibliography_list_tag end end
bibtex_files()
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 145 def bibtex_files if config['bibliography'].include? '*' @bibtex_files ||= Dir.glob(File.join(config["source"], config['bibliography'])).collect do |f| Pathname(f).relative_path_from(Pathname(config['source'])).to_s end end @bibtex_files ||= [config['bibliography']] end
labels()
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 141 def labels @labels ||= [] end
locators()
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 137 def locators @locators ||= [] end
match_fields()
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 133 def match_fields @match_fields ||= [] end
optparse(arguments)
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 31 def optparse(arguments) return if arguments.nil? || arguments.empty? parser = OptionParser.new do |opts| opts.on('-c', '--cited') do |cited| @cited = true end opts.on('-C', '--cited_in_order') do |cited| @cited, @skip_sort = true, true end opts.on('--clear') do |cited| @clear = true end opts.on('-r', '--remove_duplicates [MATCH_FIELDS]') do |match_field| @remove_duplicates = true @match_fields = match_field.split(/,\s+/) if not match_field.nil? end opts.on('-A', '--suppress_author') do |cited| @suppress_author = true end opts.on('-f', '--file FILE') do |file| @bibtex_files ||= [] @bibtex_files << file end opts.on('-q', '--query QUERY') do |query| @query = query end opts.on('-h', '--bibliography_list_tag TAG') do |tag| @bibliography_list_tag = tag end opts.on('-p', '--prefix PREFIX') do |prefix| @prefix = prefix end opts.on('-t', '--text TEXT') do |text| @text = text end opts.on('-l', '--locator LOCATOR') do |locator| locators << locator end opts.on('-L', '--label LABEL') do |label| labels << label end opts.on('-o', '--offset OFFSET') do |offset| @offset = offset.to_i end opts.on('-m', '--max MAX') do |max| @max = max.to_i end opts.on('-s', '--style STYLE') do |style| @style = style end opts.on('-g', '--group_by GROUP') do |group_by| @group_by = group_by end opts.on('-G', '--group_order ORDER') do |group_order| self.group_order = group_order end opts.on('-O', '--type_order ORDER') do |type_order| @group_by = type_order end opts.on('-T', '--template TEMPLATE') do |template| @bibliography_template = template end end argv = arguments.split(/(\B-[cCfhqptTsgGOlLomAr]|\B--(?:cited(_in_order)?|clear|bibliography_list_tag|file|query|prefix|text|style|group_(?:by|order)|type_order|template|locator|label|offset|max|suppress_author|remove_duplicates|))/) parser.parse argv.map(&:strip).reject(&:empty?) end
split_arguments(arguments)
click to toggle source
# File lib/jekyll/scholar/utilities.rb, line 21 def split_arguments(arguments) tokens = arguments.strip.split(/\s+/) args = tokens.take_while { |a| !a.start_with?('-') } opts = (tokens - args).join(' ') [args, opts] end