Sha256: 305b1b77ed9a92156522a6650b8c6acaa394d304462d6ceddd1cb6f06fc768e7

Contents?: true

Size: 781 Bytes

Versions: 3

Compression:

Stored size: 781 Bytes

Contents

module ActiveFedora
  module Noid
    class Config
      attr_writer :template, :translate_uri_to_id, :translate_id_to_uri, :statefile

      def template
        @template ||= '.reeddeeddk'
      end

      def statefile
        @statefile ||= '/tmp/minter-state'
      end

      def translate_uri_to_id
        lambda do |uri|
          uri.to_s.sub(baseurl, '').split('/', baseparts).last
        end
      end

      def translate_id_to_uri
        lambda do |id|
          "#{baseurl}/#{ActiveFedora::Noid.treeify(id)}"
        end
      end

      private

      def baseurl
        "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}"
      end

      def baseparts
        2 + [(template.gsub(/\.[rsz]/,'').length.to_f/2).ceil, 4].min
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_fedora-noid-1.1.3 lib/active_fedora/noid/config.rb
active_fedora-noid-1.1.2 lib/active_fedora/noid/config.rb
active_fedora-noid-1.1.1 lib/active_fedora/noid/config.rb