lib/airake/project.rb in airake-0.1.10 vs lib/airake/project.rb in airake-0.1.11

- old
+ new

@@ -13,14 +13,16 @@ attr_reader :mxmlc_command, :adt_command, :adl_command, :mxmlc_extra_opts Options = [ :mxmlc_path, :adt_path, :bin_dir, :src_dir, :lib_dir, :test_dir, :appxml_path, :air_path, :swf_path, :debug, :mxmlc_command, :adt_command, :adl_command, :mxmlc_extra_opts, :adl_extra_opts, :adt_extra_opts ] - - # Settings - # Specify base directory, the path to Project.mxml (relative) and options. - # Options override default settings, see Options class var. + + # Construct project + # + # base_dir:: Base (project) directory + # mxml_path: Path to the project.mxml (relative) + # options:: Override default paths, commands, extra opts, etc; See Options class var def initialize(base_dir, mxml_path, options = {}) @base_dir = base_dir @mxml_path = mxml_path @mxmlc_path = options[:mxmlc_path] || "mxmlc" @@ -49,11 +51,11 @@ @mxmlc_command = options[:mxmlc_command] || load_mxmlc_command @adt_command = options[:adt_command] || load_adt_command @adl_command = options[:adl_command] || load_adl_command end - # Run the ADT + # Run the Adobe Developer Tool def run_adt run(adt_command) end # Run the Flex compiler @@ -65,12 +67,14 @@ def run_adl run(adl_command) end # Create project using parameters from rake ENV + # # You can set any of the options via ENV; just upcase it. <tt>:foo_bar => ENV["FOO_BAR"]</tt> - # Booleans must be "true" for true and false for anything else. + # + # Booleans must be "true" for true def self.new_from_rake(env, is_test = false) base_dir = env["BASE_DIR"] mxml = is_test ? env["MXML_TEST"] : env["MXML"] # For any option check to see if its in the ENV @@ -133,14 +137,16 @@ def debug_option "-debug=#{@debug}" if @debug end + # Get relative path from base (project) directory def relative_path(path) Pathname.new(path).relative_path_from(Pathname.new(@base_dir)) end + # Handle system command failure def fail(cmd, error_status) fail_message = <<-EOS The '#{cmd.split.first}' command failed to run. This could be because this executable isn't in the path. @@ -153,9 +159,10 @@ EOS #puts fail_message if error_status != 256 && error_status != 4096 raise "[#{error_status}] Failed to run command: #{cmd}" end + # Run the (system) command def run(cmd) puts "Running: #{cmd}" system cmd or fail(cmd, $?) end \ No newline at end of file