Sha256: c83f96995fda591acd77998249cd238956902903f961da6a85fd97d50727e7cd

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

module AsProject
  class SWFMillInputError < StandardError; end

  class SWFMillInput
    attr_accessor :path,
                  :template,
                  :input_expr
    
    def initialize(path, template, input_expr=nil)
      @path = path
      @template = template
      if(input_expr.nil?)
        @input_expr = '/**/**/*'
      else
        @input_expr = input_expr
      end
      define
    end
    
    def define
      if(@path.nil?)
        raise SWFMillInputError.new('SWFMillInput needs a valid input');
      end
      
      if(@template.nil?)
        raise SWFMillInputError.new('CompileSkins needs a valid template to use');
      end

      input_files = FileList.new(path + input_expr)
      file xml_file => input_files
      file xml_file => path
      file xml_file => template

      file xml_file do |f|
        write_xml(xml_file, input_files, path)
      end
      
      CLEAN.add(xml_file)
      self
    end
    
    def skin_name
      return File.basename(path).capitalize
    end
    
    def xml_file
      return File.join(File.dirname(path), skin_name + '.xml')
    end
    
    def write_xml(file, files, base_dir)
      SWFMillInputResolver.new(template, file, files, base_dir)
      puts 'Created file at: ' + file
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
asproject-0.1.41 lib/tasks/swfmill_input.rb
asproject-0.1.42 lib/tasks/swfmill_input.rb
asproject-0.1.43 lib/tasks/swfmill_input.rb
asproject-0.1.44 lib/tasks/swfmill_input.rb
asproject-0.1.38 lib/tasks/swfmill_input.rb
asproject-0.1.40 lib/tasks/swfmill_input.rb