Sha256: d28df34d1169b79fdcb78ea3972b23da6c08d04f15f45eaf8cc1bf451bd99ab3

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

class TemplateGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)

  def copy_template_files
      copy_file 'app/controllers/welcome_controller.rb','app/controllers/welcome_controller.rb'
      template 'app/views/layouts/application.html.erb'
      template 'app/views/welcome/index.html.erb'
      template 'config/database.yml'      
      template 'public/stylesheets/screen.css'
  end	
  
  
  def add_routes
      route 'root :to => "welcome#index"'
  end
  
  def generate_navigation
      generate('navigation_config',"--force")
      @navigation = ''
      while !(controller_name = ask("Enter controller name: [no more controllers]")).blank? do
        c_name = controller_name.scan(/\w+/)[0] #get only first arg.
        generate('controller', c_name+' show') #TODO: push all other args onto end.
        @navigation += 'primary.item :'+controller_name.downcase+' ,\''+controller_name.capitalize+'\', '+controller_name.downcase+'_show_url'+'
        '
      end        
      template 'config/navigation.rb'
  end  

  
  def setup_db
      plugin('easypg', :git=>'git://github.com/rahim/easypg.git')
  end  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
template-1.0.0 lib/generators/template/template_generator.rb