Sha256: a703974b97fd830f124a687f7a885e4c5a337557518a0de0933b4bb7651b1591

Contents?: true

Size: 929 Bytes

Versions: 5

Compression:

Stored size: 929 Bytes

Contents

module FileBlobs

class BlobModelGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)

  check_class_collision

  def create_file_blob_model
    template 'file_blob.rb.erb', File.join('app', 'models', "#{file_name}.rb")
    template 'file_blob_test.rb.erb',
             File.join('test', 'models', "#{file_name}_test.rb")
    template '001_create_file_blobs.rb.erb',
        File.join('db', 'migrate',
                  "20161029000001_create_#{file_name.tableize}.rb")
    template 'file_blobs.yml.erb',
             File.join('test', 'fixtures', "#{file_name.tableize}.yml")

    copy_file File.join('files', 'invoice.pdf'),
              File.join('test', 'fixtures', 'files', 'invoice.pdf')
    copy_file File.join('files', 'ruby.png'),
              File.join('test', 'fixtures', 'files', 'ruby.png')
  end
end  # class FileBlobs::BlobModelGenerator

end  # namespace FileBlobs

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
file_blobs_rails-0.2.3 lib/file_blobs_rails/generators/blob_model_generator.rb
file_blobs_rails-0.2.2 lib/file_blobs_rails/generators/blob_model_generator.rb
file_blobs_rails-0.2.1 lib/file_blobs_rails/generators/blob_model_generator.rb
file_blobs_rails-0.2.0 lib/file_blobs_rails/generators/blob_model_generator.rb
file_blobs_rails-0.1.0 lib/file_blobs_rails/generators/blob_model_generator.rb