Class: BibSync::Actions::JabRefFormat
- Inherits:
-
Object
- Object
- BibSync::Actions::JabRefFormat
- Defined in:
- lib/bibsync/actions/jabref_format.rb
Constant Summary
Constants included from Log
Log::Blue, Log::Level, Log::Red, Log::Reset, Log::Yellow
Instance Method Summary collapse
-
#initialize(options) ⇒ JabRefFormat
constructor
A new instance of JabRefFormat.
- #run ⇒ Object
Methods included from Log
Methods included from Utils
#arxiv_download, #arxiv_id, #fetch, #fetch_html, #fetch_xml, #name_without_ext
Constructor Details
#initialize(options) ⇒ JabRefFormat
Returns a new instance of JabRefFormat.
7 8 9 |
# File 'lib/bibsync/actions/jabref_format.rb', line 7 def initialize() raise 'Option --bib is required' unless @bib = [:bib] end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/bibsync/actions/jabref_format.rb', line 11 def run @bib.save if File.read(@bib.file, 80) !~ /JabRef/ notice 'Transforming file with JabRef' tmp_file = "#{@bib.file}.tmp.bib" `jabref --primp #{Shellwords.escape File.join(File.dirname(__FILE__), 'jabref.xml')} --nogui --import #{Shellwords.escape @bib.file} --output #{Shellwords.escape tmp_file} 2>&1 >/dev/null` File.rename(tmp_file, @bib.file) if File.exists?(tmp_file) end end |