Sha256: 5eb5ca538be3bace2cd4dbec7733f29fc999ba1fde8a513e7470857de6ca9727

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module ActiveFedora
  module Noid
    class SeedGenerator < Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)
      argument :namespace, :type => :string, :default => ActiveFedora::Noid.config.namespace
      argument :template, :type => :string, :default => ActiveFedora::Noid.config.template

      desc <<-END_OF_DESC
Seeds DB from ActiveFedora::Noid.config (or command-line overrides)
      END_OF_DESC

      def banner
        say_status('info', "Initializing database table for namespace:template of '#{namespace}:#{template}'", :blue)
      end

      def checks
        say_status('warn', "Be sure to use an initializer to do 'ActiveFedora::Noid.config.namespace = #{namespace}'", :red) if namespace != ActiveFedora::Noid.config.namespace
        say_status('warn', "Be sure to use an initializer to do 'ActiveFedora::Noid.config.template = #{template}'", :red) if template != ActiveFedora::Noid.config.template
      end

      def seed_row
        MinterState.create!(
          namespace: namespace,
          template: template
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_fedora-noid-2.0.0.beta1 lib/generators/active_fedora/noid/seed_generator.rb