=begin Copyright (c) 2007 Pattern Park Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =end module Rake # :nodoc: class Tasks # :nodoc: # Override Rake::Task.actions so that we can # pull them from our dependent tasks def actions @actions end end end module Sprout class AsUnitError < StandardError # :nodoc: end # This task does not yet work! # The AsUnitTask provides a shortcut to compiling a test harness # directly from a related MXMLCTask. The first prerequisite # that is an MXMLCTask or MTASCTask will be copied and modified # to generate a test swf using ProjectModel.instance.test_dir # and the AsUnit library gem. # # mxmlc 'bin/SomeProject.swf' => :corelib do |t| # t.input = 'src/SomeProject.as' # end # # asunit :test => 'bin/SomeProject.swf' # class AsUnitTask < Rake::FileTask # :nodoc: attr_accessor :input attr_accessor :output attr_accessor :asunit_gem attr_accessor :source_path =begin def initialize(name, app) # :nodoc: super @asunit_gem = :asunit3 @spawned = [] @source_path = [] end def self.define_task(args, &block) t = super yield t if block_given? t.define return t end def define puts ">> DEFINE CALLED with: #{prerequisites.size}" library @asunit_gem reqs = prerequisites.dup req = nil reqs.each_index do |index| req = reqs[index] puts "req: #{req}" t = get_task_instance(req) if(is_mxmlc?(t)) spawn_mxmlc_task(t) reqs.slice!(index) end end @spawned.each do |req| @prerequisites << req end @spawned = [] end def get_spawned_task_name end def spawn_mxmlc_task(task) puts "SPAWNING MXMLC TASK" cloned = task.dup task.actions.each do |action| cloned.actions << action end # cloned.name = 'bin/SomeProjectRunner.swf' cloned.input = 'src/SomeProjectRunner.as' cloned.output = 'bin/SomeProjectRunner.swf' cloned.prerequisites << asunit_gem cloned.define source_path.each do |path| cloned.source_path << path end @spawned << cloned end # Alias for source_path so that MTASCTasks can also use this feature def class_path=(path) @source_path = path end def class_path return self.source_path end def is_mxmlc?(task) task.is_a?(MXMLCTask) end def get_task_instance(name) Rake::application[name] end def execute(*args) puts ">> asunit task" # FileUtils.touch(name) end =end end end def asunit(args, &block) Sprout::AsUnitTask.define_task(args, &block) end