require 'rbconfig' class ShatteredAppGenerator < Rails::Generator::Base #:nodoc:all DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) default_options :gem => true, :shebang => DEFAULT_SHEBANG mandatory_options :source => "#{File.dirname(__FILE__)}/../../../.." def initialize(runtime_args, runtime_options = {}) super usage if args.empty? @destination_root = args.shift end def manifest script_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 "templates/Rakefile", "Rakefile" m.file "templates/README", "README" # ogre plugins and configuration m.file "templates/configs/ogre_plugins.rcfg", "config/ogre_plugins.rcfg" m.template "templates/configs/ogre.cfg", "config/ogre.cfg" m.template "templates/configs/boot.rb", "config/boot.rb" # Environments m.file "templates/environments/environment.rb", "config/environment.rb" # Testing m.file "templates/test/test_helper.rb", "test/test_helper.rb" # Mac OSX m.file "templates/configs/Mac/shattered.app/Contents/Info.plist", "config/Mac/shattered.app/Contents/Info.plist" m.file "templates/configs/Mac/shattered.app/Contents/MacOS/shattered_mac", "config/Mac/shattered.app/Contents/MacOS/shattered_mac" m.file "templates/configs/Mac/shattered.app/Contents/pbdevelopment.plist", "config/Mac/shattered.app/Contents/pbdevelopment.plist" m.file "templates/configs/Mac/shattered.app/Contents/PkgInfo", "config/Mac/shattered.app/Contents/PkgInfo" m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/InfoPlist.strings", "config/Mac/shattered.app/Contents/Resources/English.lproj/InfoPlist.strings" m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib", "config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/classes.nib" m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib", "config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/info.nib" m.file "templates/configs/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/objects.nib", "config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib/objects.nib" m.file "templates/configs/Mac/shattered.app/Contents/Resources/rb_main.rb", "config/Mac/shattered.app/Contents/Resources/rb_main.rb" # Scripts %w( generate runner console destroy ).each do |file| m.file "../bin/#{file}", "script/#{file}", script_options end m.file "templates/configs/runner.rb", "script/runner.rb" # Docs m.file "templates/doc/README_FOR_APP", "doc/README_FOR_APP" # Logs %w(ogre shattered).each { |file| m.file "templates/configs/empty.log", "log/#{file}.log", :chmod => 0666 } # basic rmaterial m.file "templates/media/basic.rmaterial", "app/media/common/templates/basic.rmaterial" m.file "templates/media/offset_map.rmaterial", "app/media/common/templates/offset_map.rmaterial" end end protected def banner "Usage: #{$0} /path/to/your/app [options]" end def add_options!(opt) opt.separator '' opt.separator 'Options:' opt.on("--ruby [#{DEFAULT_SHEBANG}]", "Path to the Ruby binary of your choice.") { |options[:shebang]| } opt.on("--without-gems", "Don't use the Shattered gems for your app.", "This does not currently work.") { |options[:gem]| } end # Installation skeleton. Intermediate directories are automatically # created so don't sweat their absence here. BASEDIRS = %w( app/models app/views app/media/common/programs app/media/common/templates config/Mac/shattered.app/Contents/MacOS config/Mac/shattered.app/Contents/Resources/English.lproj/MainMenu.nib doc log script test/unit vendor vendor/plugins ) end