class EzproxyProviders::Sage

Public Class Methods

parse(path, params) click to toggle source
# File lib/logstash/filters/ezproxy_providers/sage.rb, line 4
def self.parse (path, params)
  
  data = {
    "provider" => "sage"
  }

  if (match = /^\/(loi|toc)\/(([a-z]+)\/?([0-9]+)?\/?([0-9]+)?)$/i.match(path))
    data["rtype"] = "TOC"
    data["mime"] = "MISC"
    data["title_id"] = match[3]
    if (match[4])
      data["unit_id"] = match[2]
    end

  elsif (match = /^\/doi\/([a-z]+)\/(([0-9]{2})\.([0-9]{4})\/([0-9]+))$/i.match(path))
    data["rtype"] = "ARTICLE"
    data["mime"] = "HTML"
    data["doi"] = match[2]
    data["unit_id"] = match[5]

    case (match[1])
    when "pdf"
      data["mime"] = "PDF"
    when "figure"
      data["rtype"] = "FIGURE"
    end
  end

  return data

end