class CsvImportMagic::Generators::InstallGenerator

Public Class Methods

next_migration_number(_dir) click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 28
def self.next_migration_number(_dir)
  Time.now.utc.strftime('%Y%m%d%H%M%S')
end

Public Instance Methods

add_csv_import_magic_routes() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 14
def add_csv_import_magic_routes
  route "mount CsvImportMagic::Engine => '/csv_import_magic'"
end
add_importer_migration() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 18
def add_importer_migration
  migration_template 'migration.rb', "db/migrate/create_#{table_name}.rb"
end
copy_locale() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 24
def copy_locale
  template '../../../config/locales/en.yml', 'config/locales/csv_import_magic.en.yml'
end
migration_data() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 36
      def migration_data
        <<RUBY
      t.attachment :attachment
      t.attachment :attachment_error
      t.string :source
      t.string :parser
      t.string :columns
      t.string :message
      t.string :status, default: 'pending'
      t.string :additional_data
      t.references :importable, polymorphic: true
RUBY
      end
migration_version() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 54
def migration_version
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails5?
end
rails5?() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 50
def rails5?
  Rails.version.start_with? '5'
end
table_name() click to toggle source
# File lib/generators/csv_import_magic/install_generator.rb, line 32
def table_name
  'importers'
end