Sha256: c363a19314a84c431e3a38a5357c2340a0987029249f5d9f1cd7bd7f42829487

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'rails/generators/base'

module Cccode
  module Generators
    
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../../templates', __FILE__)

      desc "Creates a Cccode initializer and copy locale files to your application."
      def hi
        puts "hi am Cccode installer running fine ..."
      end
      
      desc "add the migrations"
      def self.next_migration_number(path)
        unless @prev_migration_nr
          @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
        else
          @prev_migration_nr += 1
        end
        @prev_migration_nr.to_s
      end
      
      def copy_migrations
        copy_migration 'create_country_codes'
      end
      
      protected

      def copy_migration(filename)
        if self.class.migration_exists?("db/migrate", "#{filename}")
          say_status("skipped", "Migration #{filename}.rb already exists")
        else
          migration_template "#{filename}.rb", "db/migrate/#{filename}.rb"
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cccode-0.1.0 lib/generators/cccode/install_generator.rb