Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors due to missing keys; update Gemfile #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,4 +35,4 @@ DEPENDENCIES
rubyscholar!

BUNDLED WITH
1.11.2
1.16.2
13 changes: 11 additions & 2 deletions bin/rubyscholar
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -39,7 +48,7 @@ command :scrape do |c|
html.gsub!( term , '<em>' + term + '</em>')
end

STDERR << "Outputting to #{options.output}\n."
STDERR << "Outputting to #{options.output}.\n"
File.open(options.output,'w') { |f| f.write html }
end
end
Expand Down
14 changes: 8 additions & 6 deletions lib/rubyscholar-main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down