Sha256: 8386532da8a7df8e7409e76ccbc0b473ed40030f003a4fca505b598fa9b44422

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

require 'rails/generators/active_record/migration'

module UcbRails
  # @private
  module Generators
    # @private
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration
      extend ActiveRecord::Generators::Migration
      source_root File.join(File.dirname(__FILE__), "templates")

      desc 'Copy ucb_rails files'
      class_option :readme, aliases: '-r', type: :boolean, desc: 'Display README and exit'
      
      def install
        return if options.readme?
        
        directory 'app/assets'
        directory 'app/helpers'
        directory 'app/views'
        directory 'config'
        install_migrations
      end

      def show_readme
        if behavior == :invoke
          readme "README"
        end
      end
      
      private
      
      def install_migrations
        template_dir = Pathname.new(self.class.source_root)
        Dir["#{template_dir}/db/migrate/*.rb"].each do |migration_file|
          # migration_template migration_file
          # puts migration_file
          relative_name = Pathname.new(migration_file).relative_path_from(Pathname.new(template_dir))
          migration_template relative_name
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ucb_rails-0.0.13 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.12 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.11 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.10 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.9 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.8 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.7 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.6 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.5 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.4 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.3 lib/generators/ucb_rails/install_generator.rb
ucb_rails-0.0.2 lib/generators/ucb_rails/install_generator.rb