Module: BibTeX

Defined in:
lib/bibtex.rb,
lib/bibtex/entry.rb,
lib/bibtex/error.rb,
lib/bibtex/lexer.rb,
lib/bibtex/names.rb,
lib/bibtex/value.rb,
lib/bibtex/parser.rb,
lib/bibtex/version.rb,
lib/bibtex/elements.rb,
lib/bibtex/utilities.rb,
lib/bibtex/extensions.rb,
lib/bibtex/name_parser.rb,
lib/bibtex/replaceable.rb,
lib/bibtex/bibliography.rb

Overview

– BibTeX-Ruby Copyright © 2010 Sylvester Keil <sylvester.keil.or.at>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>. ++

Defined Under Namespace

Modules: Extensions, Replaceable, Version Classes: Bibliography, Comment, Element, Entry, Error, Lexer, MetaContent, Name, NameParser, Names, ParseError, Parser, Preamble, String, Value

Constant Summary collapse

Log =

An instance of the Ruby core class Logger. Used for logging by BibTeX-Ruby.

Logger.new(STDERR)

Class Method Summary collapse

Class Method Details

.logObject



48
# File 'lib/bibtex.rb', line 48

def self.log; BibTeX::Log end

.names(string) ⇒ Object Also known as: name, parse_name, parse_names

Parses the given string as a BibTeX name value and returns a Names object.



46
47
48
# File 'lib/bibtex/utilities.rb', line 46

def names(string)
  Names.parse(string)
end

.open(file, options = {}, &block) ⇒ Object

Opens a BibTeX file or URI and returns a corresponding Bibliography object or, if a block is given, yields the Bibliography to the block, ensuring that the file is saved.



26
27
28
# File 'lib/bibtex/utilities.rb', line 26

def open(file, options = {}, &block)
  Bibliography.open(file, options, &block)
end

.parse(string, options = {}, &block) ⇒ Object

Parses the given string and returns a corresponding Bibliography object. Delegates to BibTeX.open if the string is a filename or URI.



32
33
34
35
36
37
38
# File 'lib/bibtex/utilities.rb', line 32

def parse(string, options = {}, &block)
  if File.exists?(string) || string =~ /^[a-z]+:\/\//i
    open(string, options, &block)
  else
    Bibliography.parse(string, options)
  end
end

.valid?(file) ⇒ Boolean

Returns true if the given file is a valid BibTeX bibliography.

Returns:

  • (Boolean)


41
42
43
# File 'lib/bibtex/utilities.rb', line 41

def valid?(file)
  Bibliography.open(file).valid?
end