Sha256: 2f4dec146444705678e57fc1c1e92278643f0544d827de8cc40190456adfdcb3

Contents?: true

Size: 1.09 KB

Versions: 4

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

4 entries across 4 versions & 1 rubygems

Version Path
active_fedora-noid-2.0.0.beta5 lib/generators/active_fedora/noid/seed_generator.rb
active_fedora-noid-2.0.0.beta4 lib/generators/active_fedora/noid/seed_generator.rb
active_fedora-noid-2.0.0.beta3 lib/generators/active_fedora/noid/seed_generator.rb
active_fedora-noid-2.0.0.beta2 lib/generators/active_fedora/noid/seed_generator.rb