Sha256: ca9627b7ad052cab9ef951883d10acfdef709872c546fa2a0d1ee613c076e103

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

require 'thor'

module Padrino
  module Generators

    class Migration < Thor::Group
      # 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, :aliases => '-r', :default => nil, :type => :string

      # Copies over the base sinatra starting project
      def create_model
        if in_app_root?(options[:root])
          include_component_module_for(:orm, options[:root])
          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

2 entries across 2 versions & 1 rubygems

Version Path
padrino-gen-0.2.2 lib/generators/migration.rb
padrino-gen-0.2.1 lib/generators/migration.rb