Sha256: f3b6b579851e00905167f776bede1b0e6292819155595eb7ce6d8cae27440ae1

Contents?: true

Size: 1.26 KB

Versions: 33

Compression:

Stored size: 1.26 KB

Contents

require 'rails/generators'

module ActiveFedora
  class ModelGenerator < Rails::Generators::NamedBase
    source_root ::File.expand_path('../templates', __FILE__)
    check_class_collision

    class_option :directory, type: :string, default: 'models', desc: "Which directory to generate? (i.e. app/DIRECTORY)"
    class_option :datastream_directory, type: :string, default: 'models/datastreams', desc: "Which datastream directory to generate? (i.e. models/datastreams)"
    class_option :contains, type: :string, default: nil, desc: "Name a file to attach"
    class_option :datastream, type: :string, default: nil, desc: "Name a metadata datastream to create"

    def install
      template('model.rb.erb', ::File.join('app', directory, "#{file_name}.rb"))
      template('model_spec.rb.erb', ::File.join('spec', directory, "#{file_name}_spec.rb"))
      return unless options[:datastream]
      template('datastream.rb.erb', ::File.join('app', datastream_directory, "#{file_name}_metadata.rb"))
      template('datastream_spec.rb.erb', ::File.join('spec', datastream_directory, "#{file_name}_metadata_spec.rb"))
    end

    protected

      def directory
        options[:directory]
      end

      def datastream_directory
        options[:datastream_directory]
      end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
active-fedora-10.3.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.7.3 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.3.0.rc2 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.3.0.rc1 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.2.1 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.2.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.1.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.1.0.rc1 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.7.2 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.0.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.0.0.beta4 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.0.0.beta3 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.0.0.beta2 lib/generators/active_fedora/model/model_generator.rb
active-fedora-10.0.0.beta1 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.13.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.12.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.11.0 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.10.4 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.10.3 lib/generators/active_fedora/model/model_generator.rb
active-fedora-9.10.2 lib/generators/active_fedora/model/model_generator.rb