Sha256: 1b8899777f33ba89653758bfcd8057becff75ffec34bd67a35714598f9f92925

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require 'rails/generators'

class Curate::CurationConcernGenerator < Rails::Generators::NamedBase

  source_root File.expand_path('../templates', __FILE__)
  class_option :test_dir, :type => :string, :default => "spec/factories", :desc => "The directory where the factories should go"
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"

  def create_curation_concern
    template(
      'curation_concern.rb.erb',
      File.join('app/repository_models/', "#{file_name}.rb")
    )
  end

  def create_curation_concern_spec
    template(
      'curation_concern_spec.rb.erb',
      File.join('spec/repository_models/', "#{file_name}_spec.rb")
    )
  end

  def create_metadata_datastream
    template(
      'metadata_datastream.rb.erb',
      File.join('app/repository_datastreams/', "#{file_name}_metadata_datastream.rb")
    )
  end

  def create_metadata_datastream_spec
    template(
      'metadata_datastream_spec.rb.erb',
      File.join('spec/repository_datastreams/', "#{file_name}_metadata_datastream_spec.rb")
    )
  end

  def create_fixture_file
    template 'curation_concern_factory.rb.erb', File.join(options[:test_dir], "#{file_name}_factory.rb")
  end

  def create_serializer
    template(
      'curation_concern_serializer.rb.erb',
      File.join('app/repository_serializers/', "#{file_name}_serializer.rb")
    )
  end

  def create_serializer_spec
    template(
      'curation_concern_serializer_spec.rb.erb',
      File.join('spec/repository_serializers/', "#{file_name}_serializer_spec.rb")
    )
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curate-0.1.1 lib/generators/curate/curation_concern/curation_concern_generator.rb