Class: AppGenerator

Inherits:
Muding::Generator::Base show all
Defined in:
lib/muding_generator/generators/applications/app/app_generator.rb

Constant Summary collapse

DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])
DATABASES =
%w( mysql oracle postgresql sqlite2 sqlite3 )

Instance Attribute Summary

Attributes inherited from Muding::Generator::Base

#args, #destination_root, #source_root

Attributes included from Muding::Generator::Options

#options

Instance Method Summary collapse

Methods inherited from Muding::Generator::Base

#destination_path, #source_path

Methods included from Muding::Generator::Options

append_features

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ AppGenerator

Returns a new instance of AppGenerator.



12
13
14
15
16
17
# File 'lib/muding_generator/generators/applications/app/app_generator.rb', line 12

def initialize(runtime_args, runtime_options = {})
  super
  usage if args.empty?
  usage("Databases supported for preconfiguration are: #{DATABASES.join(", ")}") if (options[:db] && !DATABASES.include?(options[:db]))
  @destination_root = args.shift
end

Instance Method Details

#manifestObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/muding_generator/generators/applications/app/app_generator.rb', line 19

def manifest
  # Use /usr/bin/env if no special shebang was specified
  script_options     = { :chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
  dispatcher_options = { :chmod => 0755, :shebang => options[:shebang] }

  record do |m|
    # Root directory and all subdirectories.
    m.directory ''
    BASEDIRS.each { |path| m.directory path }

    # Root
    m.file "fresh_rakefile", "Rakefile"
    m.file "README",         "README"

    # Application
    m.template "helpers/mud.rb",        "mud/controllers/mud.rb"
    m.template "helpers/mud_helper.rb", "mud/helpers/mud_helper.rb"
    m.template "helpers/test_helper.rb",        "test/test_helper.rb"

    # database.yml and .htaccess
    m.template "configs/databases/#{options[:db]}.yml", "config/database.yml", :assigns => {
      :app_name => File.basename(File.expand_path(@destination_root)),
      :socket   => options[:db] == "mysql" ? mysql_socket_location : nil
    }
    #m.template "configs/routes.rb",     "config/routes.rb"
    #m.template "configs/apache.conf",   "public/.htaccess"
	m.file "configs/boot.rb",    "config/boot.rb"
	m.template "configs/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }

    # Environments
    
    #m.template "environments/environment.rb", "config/environment.rb", :assigns => { :freeze => options[:freeze] }
    #m.file "environments/production.rb",  "config/environments/production.rb"
    #m.file "environments/development.rb", "config/environments/development.rb"
    #m.file "environments/test.rb",        "config/environments/test.rb"

    # Scripts
    %w( server generate console destroy ).each do |file|
      m.file "bin/#{file}", "script/#{file}", script_options
    end



    # Docs
    m.file "doc/README_FOR_MUD", "doc/README_FOR_MUD"

    # Logs
    #%w(server production development test).each { |file|
    #  m.file "configs/empty.log", "log/#{file}.log", :chmod => 0666
    #}
  end
end