class BibSync::Actions::CheckArXivVersions
Constants
- SliceSize
Public Class Methods
new(options)
click to toggle source
# File lib/bibsync/actions/check_arxiv_versions.rb, line 9 def initialize(options) raise 'Option --bib is required' unless @bib = options[:bib] raise 'Option --dir is required' unless @dir = options[:dir] @update = options[:update] end
Public Instance Methods
run()
click to toggle source
# File lib/bibsync/actions/check_arxiv_versions.rb, line 15 def run notice 'Check for newer version on arXiv' @bib.select {|e| e[:arxiv] }.each_slice(SliceSize) do |entry| begin xml = fetch_xml('http://export.arxiv.org/api/query', id_list: entry.map{|e| arxiv_id(e, version: false, prefix: true) }.join(','), max_results: SliceSize) xml.get_elements('//entry').each_with_index do |e, i| id = e.elements['id'].text.gsub('http://arxiv.org/abs/', '') if id != entry[i][:arxiv] info("#{entry[i][:arxiv]} replaced by http://arxiv.org/pdf/#{id}", key: entry[i]) arxiv_download(@dir, id) if @update end end rescue => ex error('arXiv query failed', ex: ex) end end end