lib/airake/project.rb in airake-0.4.3 vs lib/airake/project.rb in airake-0.4.4

- old
+ new

@@ -1,48 +1,35 @@ module Airake - # Project for AIR application - # class Project - attr_reader :base_dir, :src_dirs, :lib_dir - attr_reader :mxml_path, :appxml_path, :air_path, :swf_path - attr_reader :debug, :assets, :certificate + attr_reader :env, :base_dir, :src_dirs, :lib_dir, :swf_path, :debug # Create project. # # ==== Options: # +env+: Environment, such as development, test, production. Defaults to ENV["AIRAKE_ENV"]. # +base_dir+: Base (project) directory. Defaults to ENV["AIRAKE_ROOT"] # +options+: If nil, options are loaded from airake.yml in root. (All paths relative to base directory) - # - +mxml_path+: Path to the ProjectName.mxml - # - +appxml_path+: Path to application descriptor # - +src_dirs+: Paths to source # - +lib_dir+: Path to lib directory - # - +air_path+: Path to AIR file # - +swf_path+: Path to SWF file # - +debug+: "true" or "false" - # - +assets+: Path to assets - # - +certificate+: Path to certificate # # ==== More options: # * mxmlc_path - # * adt_path - # * adl_path # * asdoc_path # * mxmlc_extra_opts - # * adt_extra_opts - # * adl_extra_opts # * asdoc_extra_opts # def initialize(env = nil, base_dir = nil, options = nil) - - env = ENV["AIRAKE_ENV"] if env.nil? + @env = env + @env = ENV["AIRAKE_ENV"] if @env.nil? base_dir = ENV["AIRAKE_ROOT"] if base_dir.nil? raise "Need to specify an AIRAKE_ROOT (project root)" if base_dir.blank? - #puts "Using environment: #{env}" if ENV["DEBUG"] + @base_dir = base_dir if options.nil? conf_path = File.join(base_dir, "airake.yml") unless File.exist?(conf_path) raise <<-EOS @@ -56,76 +43,37 @@ options = YAML.load_file(File.join(base_dir, "airake.yml")) env_options = options[env] options = options.merge(env_options) if env_options options.symbolize_keys! - #puts "Options: #{options.to_yaml}" if ENV["DEBUG"] end - @base_dir = base_dir - - @mxml_path = File.join(base_dir, options[:mxml_path]) - @appxml_path = File.join(base_dir, options[:appxml_path]) - - @src_dirs = options[:src_dirs].collect { |src_dir| File.join(base_dir, src_dir) } - @lib_dir = File.join(base_dir, options[:lib_dir]) if options[:lib_dir] - - # Dest package files - @air_path = File.join(base_dir, options[:air_path]) - @swf_path = File.join(base_dir, options[:swf_path]) + load(options) + + ensure_exists([ *@src_dirs ]) + end - # Debug options - @debug = options[:debug] - - with_keyed_options([ :assets, :certificate, :mxmlc_path, :adt_path, :adl_path, :asdoc_path, - :mxmlc_extra_opts, :adt_extra_opts, :adl_extra_opts, :asdoc_extra_opts ], options) + # Load options + def load(options = {}) + @src_dirs = [] + @src_dirs = options[:src_dirs].collect { |src_dir| File.join(base_dir, src_dir) } if options[:src_dirs] - ensure_exists([ @mxml_path, @appxml_path, *@src_dirs ]) + @lib_dir = File.join(base_dir, options[:lib_dir]) if options[:lib_dir] + @swf_path = File.join(base_dir, options[:swf_path]) + + with_keyed_options([ :debug ], options) end - - # Flex compiler command (under AIR) for this project - def amxmlc - mxmlc({ :config_name => "air" }) - end - # Flex compiler command for this project - def mxmlc(options = {}) - options = options.merge({ :swf_path => @swf_path, :mxml_path => @mxml_path, :lib_dir => @lib_dir, - :src_dirs => @src_dirs, :debug => @debug, :mxmlc_extra_opts => @mxmlc_extra_opts, - :mxmlc_path => @mxmlc_path }) - - Airake::Commands::Mxmlc.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, :cert => @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 # Remove files def clean - paths = [ swf_path, air_path ] - paths.each do |path| - FileUtils.rm(path, :verbose => true) if File.exist?(path) - end + FileUtils.rm(@swf_path, :verbose => true) if File.exist?(@swf_path) end protected # Load options into instance vars \ No newline at end of file