Sha256: d86e7796b4d700f78c1fbbf66adbf1234e30b8f46cba3afcd8afa0bfac5a00c6

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'

class SocializationGenerator < Rails::Generators::Base
  include Rails::Generators::Migration
  source_root File.expand_path(File.join('..', '..', '..', 'generators', 'socialization', 'templates'), File.dirname(__FILE__))

  def self.next_migration_number(dirname)
    if ActiveRecord::Base.timestamped_migrations
      Time.now.utc.strftime("%Y%m%d%H%M%S")
    else
      "%.3d" % (current_migration_number(dirname) + 1)
    end
  end

  def create_migration_file
    copy_file 'model_follow.rb',  'app/models/follow.rb'
    copy_file 'model_like.rb',    'app/models/like.rb'
    copy_file 'model_mention.rb', 'app/models/mention.rb'

    migration_template 'migration_follows.rb',  'db/migrate/create_follows.rb'
    sleep 1 # wait a second to have a unique migration timestamp
    migration_template 'migration_likes.rb',    'db/migrate/create_likes.rb'
    sleep 1 # wait a second to have a unique migration timestamp
    migration_template 'migration_mentions.rb', 'db/migrate/create_mentions.rb'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
socialization-0.4.0 lib/generators/socialization/socialization_generator.rb
socialization-0.3.0 lib/generators/socialization/socialization_generator.rb