Sha256: b76a780ab27944ba228033d20534ff06036c9cc99ded7878caf81571cda845aa

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true
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

2 entries across 2 versions & 1 rubygems

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