Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Commit

Permalink
add microbiology society handler sckott/pubpatterns#5 and ropensci-ar…
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jun 1, 2018
1 parent c016641 commit 91c11e4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 4 additions & 0 deletions member_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,9 @@
"297" => {
"name" => "springer",
"path" => "/var/lib/pubpatterns/src/springer.json"
},
"345" => {
"name" => "microbiology",
"path" => "/var/lib/pubpatterns/src/microbiology.json"
}
}
35 changes: 33 additions & 2 deletions utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def fetch_prefixes

class String
def murl
"http://api.crossref.org/members/" + self
"https://api.crossref.org/members/" + self
end
end

class String
def iurl
"http://api.crossref.org/journals/" + self
"https://api.crossref.org/journals/" + self
end
end

Expand All @@ -63,6 +63,8 @@ def get_ctype(x)
ct = 'application/pdf'
when 'xml'
ct = 'application/xml'
when 'html'
ct = 'text/html'
end
return ct
end
Expand All @@ -73,6 +75,8 @@ def from_ctype(x)
ct = 'application/pdf'
when 'xml'
ct = 'application/xml'
when 'html'
ct = 'text/html'
end
return ct
end
Expand Down Expand Up @@ -427,6 +431,33 @@ def fetch_url
return { "doi" => doi, "member" => {"name" => memname, "url" => "297".murl},
"issn" => Array(issn).map(&:iurl), "links" => { "pdf" => url },
"cookies" => json['cookies'], "open_access" => json['open_access'] }
when "345"
# Microbiology Society
res = Serrano.works(ids: doi)
issn = res[0]['message']['ISSN']
bit = json['journals'].select { |x| Array(x['issn']).select{ |z| !!z.match(issn.join('|')) }.any? }[0]

out = []
pdfref = doi.match(bit['components']['pdf']['regex']).to_s
if ['mic', 'jgv', 'jmm'].include? bit['journal']
patt = [res[0]['message']['volume'], res[0]['message']['issue'], res[0]['message']['page'].split('-')[0], pdfref]
else
patt = [pdfref,pdfref]
end
out << {
'url' => bit['urls']['pdf'] % patt,
'content-type' => get_ctype('pdf')
}

htmlref = doi.match(bit['components']['html']['regex']).to_s
out << {
'url' => bit['urls']['html'] % htmlref,
'content-type' => get_ctype('html')
}
return { "doi" => doi, "title" => res[0]['message']['container-title'][0].strip,
"member" => {"name" => memname, "publisher" => res[0]['message']['publisher'], "url" => "345".murl},
"issn" => Array(issn).map(&:iurl), "links" => out,
"cookies" => json['cookies'], "open_access" => json['open_access'] }
else
return {"doi" => doi, "member" => nil, "issn" => nil, "links" => nil}
end
Expand Down

0 comments on commit 91c11e4

Please sign in to comment.