Sha256: 91dc347a38a474e47608c063e8101f1c377c00f3ce95aa8853f63282eecbcc01

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

module Padrino
  module Generators

    class Migration < Thor::Group

      # Add this generator to our padrino-gen
      Padrino::Generators.add_generator(:migration, self)

      # Define the source template root
      def self.source_root; File.expand_path(File.dirname(__FILE__)); end
      def self.banner; "padrino-gen migration [name] [fields]"; end

      # Include related modules
      include Thor::Actions
      include Padrino::Generators::Actions
      include Padrino::Generators::Components::Actions

      desc "Description:\n\n\tpadrino-gen migration generates a new migration file"

      argument :name, :desc => "The name of your padrino migration"
      argument :columns, :desc => "The columns for the migration", :type => :array, :default => []
      class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
      class_option :destroy, :aliases => '-d', :default => false, :type => :boolean

      # Show help if no argv given
      require_arguments!

      def create_migration
        self.destination_root = options[:root]
        if in_app_root?
          self.behavior = :revoke if options[:destroy]
          if include_component_module_for(:orm)
            create_migration_file(name, name, columns)
          else
            say "<= You need an ORM adapter for run this generator. Sorry!"
            raise SystemExit
          end
        else
          say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root?
        end
      end
    end # Migration
  end # Generators
end # Padrino

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
padrino-gen-0.9.14 lib/padrino-gen/generators/migration.rb
padrino-gen-0.9.13 lib/padrino-gen/generators/migration.rb
padrino-gen-0.9.12 lib/padrino-gen/generators/migration.rb
padrino-gen-0.9.11 lib/padrino-gen/generators/migration.rb
padrino-gen-0.9.10 lib/padrino-gen/generators/migration.rb
padrino-gen-0.9.9 lib/padrino-gen/generators/migration.rb
padrino-gen-0.9.7 lib/padrino-gen/generators/migration.rb