Sha256: e42a75e153ccb79b9920240ef96e4c7aad87a2514d3fa007e1f21c1fc1483e20

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

#
# filehandlers.rb
# Contains top-level file utility methods
#

module AsciidoctorBibliography

  module FileHandlers
    # Locate a bibliography file to read in given dir
    def FileHandlers.find_bibliography dir
      begin
        candidates = Dir.glob("#{dir}/*.bib")
        if candidates.empty?
          return ""
        else
          return candidates.first
        end
      rescue # catch all errors, and return empty string
        return ""
      end
    end

    # Add '-ref' before the extension of a filename
    def FileHandlers.add_ref filename
      file_dir = File.dirname(File.expand_path(filename))
      file_base = File.basename(filename, ".*")
      file_ext = File.extname(filename)
      return "#{file_dir}#{File::SEPARATOR}#{file_base}-ref#{file_ext}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asciidoctor-bibliography-0.1 deprecated/asciidoctor-bibliography/filehandlers.rb
asciidoctor-bibliography-0.0.1.dev deprecated/asciidoctor-bibliography/filehandlers.rb