Sha256: 2661d140ca4ab4e2d27ddc558bb4682667ea764dab9f5e20ffcd23290a104f59

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'nokogiri'
require 'open-uri'


class JournalTocs < Service
  include MetadataHelper
  
  def service_types_generated
    return [ServiceTypeValue['table_of_contents']]
  end
  
  def initialize
    @base_url = 'http://www.journaltocs.ac.uk/api'
    super
  end
  
  def handle(request)
    issn = get_issn(request.referent)
    
    # Can only work with an ISSN
    unless issn
      return request.dispatched(self, true)
    end
    
    xml = Nokogiri::XML( open(request_url(url))  )
    
    items = xml.search("//rss:item")
    
    unless items.length > 0
      # found nothing, no match, or no contents.
      return request.dispatched(self, true)
    end
    
    
    
    
  end
  
  def request_url(issn)
    return "#{@base_url.chomp('/')}/#{issn}?output=articles"
  end
  
  
  def xml_ns
    { "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
      "rss" => "http://purl.org/rss/1.0/",
      "prism"="http://prismstandard.org/namespaces/1.2/basic/", 
      "dc"="http://purl.org/dc/elements/1.1/",
      "mn"="http://usefulinc.com/rss/manifest/",
      "content"="http://purl.org/rss/1.0/modules/content/" 
    }
  end
  
  # Given a Nokogiri list of rss:items, returns a list of OpenURL::ContextObjects
  def extract_items(items)
    items.collect do |item|
      
    end
      
  end
  
  class Item
    attr_accessor :title, 
  end
  
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
umlaut-3.0.5 lib/service_adaptors/journal_tocs.progress
umlaut-3.0.4 lib/service_adaptors/journal_tocs.progress
umlaut-3.0.3 lib/service_adaptors/journal_tocs.progress
umlaut-3.0.2 lib/service_adaptors/journal_tocs.progress
umlaut-3.0.1 lib/service_adaptors/journal_tocs.progress