class ContentfulMigrationGenerator

Public Instance Methods

copy_initializer_file() click to toggle source

source_root File.expand_path(“../templates”, __FILE__)

# File lib/generators/contentful_migration/contentful_migration_generator.rb, line 6
  def copy_initializer_file
    name = file_name.to_s
    migration_file = "db/contentful_migrations/#{next_migration_number}_#{name.underscore}.rb"
    create_file migration_file, <<-FILE.strip_heredoc
      class #{name.camelize} < ContentfulMigrations::Migration

        def up
          with_space do |space|
            # TODO: use contentful-management.rb here
          end
        end

        def down
          with_space do |space|
            # TODO: use contentful-management.rb here
          end
        end

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