Source

RubyLearning / flex_test / vendor / plugins / flex_dev / generators / flex_app / flex_app_generator.rb

Full commit
require "flex_dev"
class FlexAppGenerator < Rails::Generator::NamedBase
  def manifest
    record do |m|
      if(!File.exist?(File.join( "config", "flex-config.yml")))
        write_flex_config
      end
      flex_apps = {}
      if(File.exist?(File.join( "config", "flex-apps.yml")))
        flex_apps = YAML::load(File.open(File.join( "config", "flex-apps.yml")))
      end
      
      # create flex flex app data
      app_name = "#{class_name}"
      flex_bin = "public"
      flex_src = "flex/#{file_name}/src"
      flex_lib = "flex/#{file_name}/lib"
      flex_main = "#{flex_src}/main.mxml"

      m.directory flex_bin
      m.directory flex_src
      m.directory flex_lib
      m.template "main.mxml", flex_main

      flex_app = {
        "flex-bin" => flex_bin,
        "flex-src" => flex_src,
        "flex-lib" => flex_lib,
        "flex-main" => flex_main,
      }
      flex_apps[app_name] =  flex_app
      puts "modifing config/flex-apps.yml"
      File.open(File.join("config", "flex-apps.yml"), "w") do |f|
        f.puts YAML::dump(flex_apps)
      end
      # m.template 'README', "README"
    end
  end
end