Sha256: 3ad22e8a03cbb53b30d477856b04128cbbe721d1b2e0af15ca31bbad1c09746d

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 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 'uri'

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

require 'addressable/uri'
require 'addressable/template'
require 'json'
require 'hashie'


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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
djatoka-0.2.0 lib/djatoka.rb