Class: MugenGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/mugen/mugen_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descriptionObject



39
40
41
42
43
44
45
46
47
# File 'lib/generators/mugen/mugen_generator.rb', line 39

def self.description
  <<-DESCRIPTION
*******************************************************************    
MyGengo scaffold complete


*******************************************************************    
  DESCRIPTION
end

Instance Method Details

#installObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/mugen/mugen_generator.rb', line 4

def install  
  # Create directories 
  %W( 
    app/controllers/mygengo
    app/views/mygengo/account
    app/views/mygengo/comments
    app/views/mygengo/jobs
    public/stylesheets/mygengo
    public/images/mygengo
  ).each {|dir|
    directory dir 
  }
  
  # Copy files 
  %W(
    config/initializers/mugen.rb    
    app/helpers/mugen_helper.rb
    app/views/layouts/mygengo.html.erb
  ).each do |filename|
    copy_file filename, filename
  end 
  
  # Add routes
  sentinel = '::Application.routes.draw do'
  new_routes = IO.read(File.dirname(__FILE__) + '/templates/config/routes3.rb')
  
  gsub_file 'config/routes3.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
    "#{match}\n #{new_routes}"
  end
  
  

  puts MugenGenerator.description
end