Sha256: ae1a3eae35c57776940e2d6c9eaad686f483e2cedd8fd227f4687bb188feb470

Contents?: true

Size: 1.76 KB

Versions: 50

Compression:

Stored size: 1.76 KB

Contents

#--
# BibTeX-Ruby
# Copyright (C) 2011  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 <http://www.gnu.org/licenses/>.
#++

module BibTeX

  class << self
    
    # 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.
    def open(file, options = {}, &block)
      Bibliography.open(file, options, &block)
    end
  
    # Parses the given string and returns a corresponding +Bibliography+ object.
    # Delegates to BibTeX.open if the string is a filename or URI.
    def parse(string, options = {}, &block)
      if File.exists?(string) || string =~ /^[a-z]+:\/\//i
        Bibliography.open(string, options, &block)
      else
        Bibliography.parse(string, options)
      end
    end
  
    # Returns true if the given file is a valid BibTeX bibliography.
    def valid?(file)
      Bibliography.open(file).valid?
    end
    
    # Parses the given string as a BibTeX name value and returns a Names object.
    def names(string)
      Names.parse(string)
    end
    
    alias :name :names
    alias :parse_name :names
    alias :parse_names :names
    
  end

end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
bibtex-ruby-4.0.8 lib/bibtex/utilities.rb
bibtex-ruby-4.0.7 lib/bibtex/utilities.rb
bibtex-ruby-4.0.6 lib/bibtex/utilities.rb
bibtex-ruby-4.0.5 lib/bibtex/utilities.rb
bibtex-ruby-4.0.4 lib/bibtex/utilities.rb
bibtex-ruby-4.0.3 lib/bibtex/utilities.rb
bibtex-ruby-4.0.2 lib/bibtex/utilities.rb
bibtex-ruby-4.0.1 lib/bibtex/utilities.rb
bibtex-ruby-4.0.0 lib/bibtex/utilities.rb
bibtex-ruby-3.1.6 lib/bibtex/utilities.rb
bibtex-ruby-3.1.5 lib/bibtex/utilities.rb
bibtex-ruby-3.1.4 lib/bibtex/utilities.rb
bibtex-ruby-3.1.3 lib/bibtex/utilities.rb
bibtex-ruby-3.1.2 lib/bibtex/utilities.rb
bibtex-ruby-3.1.1 lib/bibtex/utilities.rb
bibtex-ruby-3.1.0 lib/bibtex/utilities.rb
bibtex-ruby-3.0.1 lib/bibtex/utilities.rb
bibtex-ruby-3.0.0 lib/bibtex/utilities.rb
bibtex-ruby-2.3.4 lib/bibtex/utilities.rb
bibtex-ruby-2.3.3 lib/bibtex/utilities.rb