module AsProject class SWFMillError < StandardError; end class SWFMill < RemoteFileTask attr_accessor :name, :simple, :input, :input_expr, :output, :template, :version def initialize(name, do_not_define=false) @simple = true @input = nil @template = nil @input_expr = nil @output = nil @options = [] @version = '0.2.12' @win_url = "http://www.swfmill.org/releases/swfmill-#{version}-win32.zip" @win_extracted_file = "/swfmill-#{version}-win32/swfmill.exe" # @osx_url = "http://www.swfmill.org/releases/swfmill-0.2.12-macosx.tar.gz" # @osx_extracted_file = nil # @unix_url = nil # @unix_extracted_file = nil super(name, true) define unless do_not_define end def remote_task_name return "swfmill-#{version}" end def define super if(@input.nil?) raise SWFMillError.new('SWFMill task requires that input be set') end if(@output.nil?) raise SWFMillError.new('SWFMill task requires that output be set') end if(File.directory?(input)) @input = define_xml_task(input).xml_file end file input file output => input do |f| cleaned_options = [] option_list.each do |item| cleaned_options << clean_path(item) end execute(cleaned_options.join(' ')) end desc "#{name} using SWFMill" task name => [input, output] CLEAN.add(output) self end def define_xml_task(path) # build the input xml file automatically # Based on a directory full of images... if(@template.nil?) raise SWFMillError.new('If input is a directory, you must assign a template to use for the generated xml document') end return SWFMillInput.new(path, template, input_expr) end def option_list result = @options.dup result << "simple" if simple result << input if input result << output if output return result end end end