Sha256: 6d78ef2988ee322da64273d63a58b84a6c4f4d74c74da60afa63923c372ab87f

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 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
      def self.start(given_args=ARGV, config={})
        given_args = ["-h"] if given_args.empty?
        super
      end

      def create_migration
        self.destination_root = options[:root]
        if in_app_root?
          self.behavior = :revoke if options[:destroy]
          include_component_module_for(:orm)
          create_migration_file(name, name, columns)
        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

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
padrino-gen-0.8.1 lib/padrino-gen/generators/migration.rb
padrino-gen-0.8.0 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.9 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.8 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.7 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.6 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.5 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.4 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.3 lib/padrino-gen/generators/migration.rb
padrino-gen-0.7.2 lib/padrino-gen/generators/migration.rb