### Home Classes Methods

### In Files

- lib/padrino-gen/generators/component.rb

### Parent

Thor::Group

### Methods

- ::banner
- ::source_root
- #setup_components

### Included Modules

- Thor::Actions
- Padrino::Generators::Actions
- Padrino::Generators::Components::Actions

### Files

- README.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- Padrino
- Padrino::Generators
- Padrino::Generators::Actions
- Padrino::Generators::Actions::ClassMethods
- Padrino::Generators::App
- Padrino::Generators::AppRootNotFound
- Padrino::Generators::Cli
- Padrino::Generators::Component
- Padrino::Generators::Components
- Padrino::Generators::Components::Actions
- Padrino::Generators::Controller
- Padrino::Generators::Mailer
- Padrino::Generators::Migration
- Padrino::Generators::Model
- Padrino::Generators::Plugin
- Padrino::Generators::Project
- Padrino::Generators::Runner
- Padrino::Generators::SqlHelpers
- Padrino::Generators::Task
- ActiveRecord
- ActiveRecord::Schema
- Object

No matching classes.

# Padrino::Generators::Component

Responsible for add components within a Padrino project.

### Public Class Methods

banner() click to toggle source

    # File lib/padrino-gen/generators/component.rb, line 12
    def self.banner; "padrino-gen component [options]"; end

source_root() click to toggle source

    # File lib/padrino-gen/generators/component.rb, line 11
    def self.source_root; File.expand_path(File.dirname(__FILE__)); end

### Public Instance Methods

setup_components() click to toggle source

For each component, retrieve a valid choice and then execute the associated generator.

    # File lib/padrino-gen/generators/component.rb, line 29
    def setup_components
      self.destination_root = options[:root]
      if in_app_root?
        @_components = options.dup.slice(*self.class.component_types)
        @app_name = (options[:app] || "App").gsub(/\W/, '_').underscore.camelize
        if @_components.values.delete_if(&:blank?).empty?
          self.class.start(["-h"])
          say
          say "Current Selected Components:"
          list = []
          self.class.component_types.each do |comp|
            list << [comp, fetch_component_choice(comp)]
          end
          print_table(list, :indent => 2)
          exit
        end

        self.class.component_types.each do |comp|
          next if @_components[comp].blank?

          choice = @_components[comp] = resolve_valid_choice(comp)
          existing = fetch_component_choice(comp)
          if existing != 'none' && existing != choice
            next unless yes?("Switch #{comp} to '#{choice}' from '#{existing}' ?[yes/no]:")
          end
          @project_name = fetch_component_choice(:namespace)
          if comp.to_s == 'test' && !already_exists?(@app_name, @project_name)
            say "#{@project_name}::#{@app_name} does not exist."
            say "Please, change app name."
            next
          end
          execute_component_setup(comp, choice)
          store_component_choice(comp, choice)
          if comp.to_s == 'orm' && choice.to_s != 'none'
            inject_into_file destination_root('Rakefile'), "PadrinoTasks.use(:database)\n", :before => "PadrinoTasks.init"
            inject_into_file destination_root('Rakefile'), "PadrinoTasks.use(#{choice.to_sym.inspect})\n", :before => "PadrinoTasks.init"
          end
        end
      else
        say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.