diff --git a/Gemfile.lock b/Gemfile.lock index 48907e5..0996246 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,25 +9,23 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (4.2.0) + activesupport (4.2.10) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - commander (4.4.0) + commander (4.4.5) highline (~> 1.7.2) - highline (1.7.8) - i18n (0.7.0) - json (1.8.3) - mini_portile2 (2.1.0) - minitest (5.9.0) - nokogiri (1.6.8) - mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) - pkg-config (1.1.7) - thread_safe (0.3.5) - tzinfo (1.2.2) + concurrent-ruby (1.0.5) + highline (1.7.10) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) + thread_safe (0.3.6) + tzinfo (1.2.5) thread_safe (~> 0.1) PLATFORMS @@ -37,4 +35,4 @@ DEPENDENCIES rubyscholar! BUNDLED WITH - 1.11.2 + 1.16.2 diff --git a/bin/rubyscholar b/bin/rubyscholar index 9d4b9d8..d237014 100755 --- a/bin/rubyscholar +++ b/bin/rubyscholar @@ -25,7 +25,16 @@ command :scrape do |c| #rest stays in this block bc we need to access options raise IOError, "You must specify config file via --config\n" if options.config.nil? - config = YAML.load_file(options.config) + config = { + "url" => nil, + "email" => nil, + "pdfs" => {}, + "highlight" => [], + "altmetricDOIs" => [], + "minCitations" => nil, + "italicize" => [] + } + config = config.merge(YAML.load_file(options.config)) parsed = Rubyscholar::Parser.new(config["url"], config["email"]) html = Rubyscholar::Formatter.new(parsed, @@ -39,7 +48,7 @@ command :scrape do |c| html.gsub!( term , '' + term + '') end - STDERR << "Outputting to #{options.output}\n." + STDERR << "Outputting to #{options.output}.\n" File.open(options.output,'w') { |f| f.write html } end end diff --git a/lib/rubyscholar-main.rb b/lib/rubyscholar-main.rb index 80c6139..99ff481 100644 --- a/lib/rubyscholar-main.rb +++ b/lib/rubyscholar-main.rb @@ -118,16 +118,19 @@ def to_html doc.text '. ' doc.em paper[:journalName] + ' ' doc.text paper[:journalDetails] + unless doi.empty? doc.text(' ') doc.a(href: URI.join("http://dx.doi.org/", doi)) do doc.text "[DOI]" end end - if @pdfLinks.keys.include?(paper[:title]) + + if @pdfLinks.keys.include?(paper[:title]) doc.text(' ') doc.a(href: @pdfLinks[paper[:title]]) { doc.text "[PDF]" } - end + end + if paper[:citationCount].to_i > @minCitations doc.text(' ') doc.a(href: paper[:citingPapers], title: "Citations") do @@ -136,11 +139,10 @@ def to_html end end end - if altmetricDOIs.include?( doi) + + if altmetricDOIs.include?(doi) doc.text(' ') - doc.span(class: 'altmetric-embed', - 'data-badge-popover':'bottom', - 'data-doi': doi) + doc.span(class: 'altmetric-embed', 'data-badge-popover':'bottom', 'data-doi': doi) end end end