Sha256: 16e94131ca443e9dc7d278abd9d3bf06724a6b6af9751193d5e1350c379cdd39

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module EffectiveMemberships
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration

      desc 'Creates an EffectiveClassifieds initializer in your application.'

      source_root File.expand_path('../../templates', __FILE__)

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

      def copy_initializer
        template ('../' * 3) + 'config/effective_classifieds.rb', 'config/initializers/effective_classifieds.rb'
      end

      def create_migration_file
        @classifieds_table_name  = ':' + EffectiveClassifieds.classifieds_table_name.to_s
        @classified_submissions_table_name  = ':' + EffectiveClassifieds.classified_submissions_table_name.to_s

        migration_template ('../' * 3) + 'db/migrate/01_create_effective_classifieds.rb.erb', 'db/migrate/create_effective_classifieds.rb'
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
effective_classifieds-0.1.0 lib/generators/effective_classifieds/install_generator.rb
effective_classifieds-0.0.3 lib/generators/effective_classifieds/install_generator.rb
effective_classifieds-0.0.2 lib/generators/effective_classifieds/install_generator.rb