Sha256: 4e25ea57bbd93f482dba4fd2898338432b066cf88a5ab7788b0e7955aa69fe61

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 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 { |uri| URI(uri).path.split('/', baseparts).last }
      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
        treeparts = [(template.gsub(/\.[rsz]/,'').length.to_f/2).ceil, 4].min
        baseurl.count('/') + treeparts
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_fedora-noid-1.1.0 lib/active_fedora/noid/config.rb
active_fedora-noid-1.0.3 lib/active_fedora/noid/config.rb
active_fedora-noid-1.0.2 lib/active_fedora/noid/config.rb
active_fedora-noid-1.0.1 lib/active_fedora/noid/config.rb