Class: BibTeX::Bibliography
- Inherits:
-
Object
- Object
- BibTeX::Bibliography
- Defined in:
- lib/bibtex_munge/bcf.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
Returns the value of attribute filepath.
Class Method Summary collapse
Instance Attribute Details
#filepath ⇒ Object
Returns the value of attribute filepath.
5 6 7 |
# File 'lib/bibtex_munge/bcf.rb', line 5 def filepath @filepath end |
Class Method Details
.from_bcf(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bibtex_munge/bcf.rb', line 16 def from_bcf(path) File.open(path, "r") do |f| @bcf = Nokogiri::XML(f).remove_namespaces! end filepath = File.dirname(path) + "/" + @bcf.at_xpath("//datasource").content citekeys = @bcf.xpath("//citekey", 'bcf'=>'URI').map(&:content) bib = open(filepath, :filter => 'latex') bib.filepath = filepath trim_unnecessary_entries!(bib, citekeys) bib.sort! { |a,b| a. <=> b. } bib.extend(BibtexMunge) bib.fix_everything! return bib end |
.trim_unnecessary_entries!(bib, citekeys) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/bibtex_munge/bcf.rb', line 8 def trim_unnecessary_entries!(bib, citekeys) bib.entries.each do |k,v| if !citekeys.include? k bib.delete(k) end end end |