module Airake #:nodoc # # Project for AIR application # class Project attr_reader :base_dir, :bin_dir, :src_dir, :lib_dir, :test_dir attr_reader :mxml_path, :appxml_path, :air_path, :swf_path attr_reader :debug, :assets, :certificate attr_reader :build_env # Options to override defaults Options = [ :bin_dir, :src_dir, :lib_dir, :test_dir, :appxml_path, :air_path, :swf_path, :debug, :certificate, :assets, :amxmlc_path, :adl_path, :adt_path, :asdoc_path, :amxmlc_extra_opts, :adl_extra_opts, :adt_extra_opts, :asdoc_extra_opts ] # Build project: # # base_dir: Base (project) directory # mxml_path: Path to the ProjectName.mxml (relative) # options: # bin_dir: Path to generated output, defaults to 'bin' # src_dir: Path to source, defaults to 'src' # lib_dir: Path to lib directory, defaults to 'lib' # test_dir: Path to test directory, defaults to 'test' # appxml_path: Path to application descriptor, defaults to '/-app.xml'. Default assumes the app xml is in same directory as the root mxml. # air_path: Path to AIR file, defaults to '/.air' # swf_path: Path to SWF file, defaults to '/ @swf_path, :mxml_path => @mxml_path, :lib_dir => @lib_dir, :src_dirs => src_dirs, :debug => @debug, :amxmlc_extra_opts => @amxmlc_extra_opts, :amxmlc_path => @amxmlc_path } Airake::Commands::Amxmlc.new(options) end # ADL command for this project def adl options = { :appxml_path => @appxml_path, :base_dir => @base_dir, :adl_extra_opts => @adl_extra_opts, :adl_path => @adl_path } Airake::Commands::Adl.new(options) end # ADT command for this project def adt options = { :air_path => @air_path, :appxml_path => @appxml_path, :swf_path => @swf_path, :base_dir => @base_dir, :assets => @assets, :certificate => @certificate, :adt_extra_opts => @adt_extra_opts, :adt_path => @adt_path } Airake::Commands::Adt.new(options) end # AS docs def asdoc src_dirs = [ @src_dir ] options = { :lib_dir => @lib_dir, :src_dirs => src_dirs, :asdoc_extra_opts => @asdoc_extra_opts, :asdoc_path => @asdoc_path } Airake::Commands::Asdoc.new(options) end # List of files to remove on clean def to_clean case build_env when :normal then [ swf_path, air_path ] when :test then [ swf_path ] end end # # Create project using parameters from rake ENV: # # BASE_DIR: Path to project base # MXML: Path to mxml file # MXML_TEST: In test environment, path to test mxml file # # You can override any of the project options via ENV; just upcase it. :foo_bar => ENV["FOO_BAR"] # # This shouldn't really be here, but a Rakefile is a bad place to be :O # # Booleans must be "true" for true # def self.new_from_rake(env, build_env = :normal) base_dir = env["BASE_DIR"] mxml = case build_env when :test then env["MXML_TEST"] when :normal then env["MXML"] else raise "Invalid build env: #{build_env}" end # For any option check to see if its in the ENV options = {} Options.each do |option_key| env_key = option_key.to_s.upcase options[option_key] = env[env_key] if env.has_key?(env_key) end #puts "Using options: #{options.inspect}" unless options.empty? self.new(base_dir, mxml, options, build_env) end # Load options into instance vars def with_keyed_options(keys, options) keys.each do |key| value = options[key] instance_variable_set("@#{key}", value) if value end end end end