Sha256: 4fd870e2890501ee96f6a13678f9ce6d01b89104b6d2d62134e0c8521a3af500

Contents?: true

Size: 1.67 KB

Versions: 7

Compression:

Stored size: 1.67 KB

Contents

$:.unshift(File.dirname(__FILE__)) unless
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))

# In the context of Djatoka a <tt>uri</tt> is an Addressable::URI and a
# <tt>url</tt> is a String representation of that uri.
module Djatoka
  # for use with Rails to allow for configuration
  def self.resolver=(url)
    if url.is_a? Djatoka::Resolver
      @resolver = url
    elsif url.is_a? String
      @resolver = Djatoka::Resolver.new(url)
#      if resolver.valid?
#        @resolver = resolver
#      else
#        @resolver = nil
#      end
    end
  end
  def self.resolver
    @resolver
  end

  # Allows for using curb if available. Otherwise falls back on Net::HTTP. See Djatoka::Net
  def self.use_curb=(curb)
    @use_curb = curb
  end
  def self.use_curb?
    @use_curb
  end
  class << self
    # Calls enable_actionpack
    def enable
      enable_actionpack
    end
    # Requires the Djatoka Rails view helpers
    def enable_actionpack
      return if ActionView::Base.instance_methods.include? :djatoka_image_tag
      require 'djatoka/view_helpers'
      ActionView::Base.send :include, ViewHelpers
    end
  end
end

begin
  require 'curb'
  Djatoka.use_curb = true
rescue LoadError
  Djatoka.use_curb = false
end

require 'net/http'
require 'net/https'
require 'uri'
require 'set'

require 'djatoka/net'
require 'djatoka/resolver'
require 'djatoka/metadata'
require 'djatoka/common'
require 'djatoka/region'
require 'djatoka/iiif_request'

require 'addressable/uri'
require 'addressable/template'
require 'json'
require 'nokogiri'
require 'hashie'
require 'mime/types'


if defined? Rails
  Djatoka.enable_actionpack if defined? ActionController
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
djatoka-0.4.1 lib/djatoka.rb
djatoka-0.4.0 lib/djatoka.rb
djatoka-0.3.2 lib/djatoka.rb
djatoka-0.3.1 lib/djatoka.rb
djatoka-0.3.0 lib/djatoka.rb
djatoka-0.2.4 lib/djatoka.rb
djatoka-0.2.3 lib/djatoka.rb