Class: BibtexImport

Inherits:
Object
  • Object
show all
Defined in:
lib/bibtex_import.rb

Overview

BibtexImport - a library to handle tasks related to importing a BibTeX bibliography. It depends on both the bibtex-ruby gem and Source::Bibtex

Instance Method Summary (collapse)

Instance Method Details

- (Array<Source::Bibtex>) bibtex_biblio_2_tw(input_bibliography)

Note:

Not yet implemented!

Move the BibTeX bibliography into TaxonWorks records

Parameters:

  • input_bibliography (BibTeX::Bibliography)

    the set of BibTeX records to be converted to TW records.

Returns:

  • (Array<Source::Bibtex>)

    a set of TW Source::Bibtex records (records may or may not exist in the database.)



22
23
24
25
# File 'lib/bibtex_import.rb', line 22

def bibtex_biblio_2_tw(input_bibliography)
  # input BibTeX-ruby bibliography (hash)
  # output TaxonWorks source records (hash?, array?)
end

- (BibTeX::Bibliography) bibtex_read(input_file)

Note:

Current version opens a fixed file (“spec/files/Taenionema.bib”) for testing purposes. eventually input_file name will be passed in.

Open a BibTeX file & read in a bibliography

Parameters:

  • input_file (String)

    the name of the file containing the BibTeX bibliography.

Returns:

  • (BibTeX::Bibliography)

    has the same return values as BibTeX.open()



10
11
12
13
14
15
16
# File 'lib/bibtex_import.rb', line 10

def bibtex_read (input_file)

#TODO get input filename from parameter input_file
  input_file = Rails.root + 'spec/files/Taenionema.bib' # will eventually get this from the user
  BibTeX.open(input_file)
# this returns BibTex-ruby bibliography hash
end

- (Source::Bibtex) create_tw_source_from_bibtex(bibtex_entry)

Note:

Note yet implemented

Create a Source::Bibtex object from a BibTeX::Entry object

Parameters:

  • bibtex_entry (BibTeX::Entry)

    bibtex object to be converted

Returns:

  • (Source::Bibtex)

    a TW bibtex source object (which may or may not be valid.)



40
41
42
# File 'lib/bibtex_import.rb', line 40

def create_tw_source_from_bibtex(bibtex_entry)
  #return Source::Bibtex
end

- (Boolean) save_bibtex_entry_as_tw(bibtex_entry, tw_entry)

Note:

Not yet implemented

Save a BibTeX::Entry object as a Source::Bibtex record

Parameters:

  • bibtex_entry (BibTeX::Entry)

    bibtex object to be converted and saved to the database

  • tw_entry (Source::Bibtex)

    will be overwritten with a new Source::Bibtex.

Returns:

  • (Boolean)

    True if successfully saved to the database; False if not saved.



32
33
34
# File 'lib/bibtex_import.rb', line 32

def save_bibtex_entry_as_tw(bibtex_entry, tw_entry)
  # Save a TaxonWorks record
end