Sha256: 1d2551cbd4222c40a00937c938cea0abd0748674839676b99ec3f2cca8b8df5d

Contents?: true

Size: 1.7 KB

Versions: 2

Compression:

Stored size: 1.7 KB

Contents

module Airake #:nodoc:
  
  module Commands #:nodoc:
    
    # ACOMPC (Air component compiler)
    #
    # http://livedocs.adobe.com/labs/flex3/html/help.html?content=CommandLineTools_3.html
    class Acompc < Base
      
      attr_reader :path, :extra_opts, :source_path, :include_packages, :output_path
      
      # Initialize command
      #
      # options:: :acompc_path, :acompc_extra_opts, :source_path, :include_packages, :output_path
      #
      # :include_packages:
      #   com.airake.utils will include all classes from Dir["com/airake/utils/**/*.as"]
      def initialize(options = {})
        @path = options[:acompc_path] || "acompc"
        @extra_opts = options[:acompc_extra_opts]
        with_options(options, { :source_path => "src" })
        
        raise "No output path specified" unless output_path
      end
      
      def include_classes_option
        classes = []
        paths = []
        include_packages.each do |include_package|
          path = File.join(source_path, include_package.gsub(".", "/")) + "/**/*.as"
          paths << path
          Dir[path].each do |file|
            classes << include_package + "." + File.basename(file).gsub(".as", "")
          end
        end
        raise "No classes found at:\n\t#{paths.join("\n\t")}" if classes.empty?
        classes.join(" ")
      end
            
      # Get the acompc compile command
      def compile
        command = []
        command << path
        command << "-source-path"
        command << source_path
        command << "-include-classes"
        command << include_classes_option
        command << "-output"
        command << output_path        
        process(command)
      end
            
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
airake-0.2.8 lib/airake/commands/acompc.rb
airake-0.2.7 lib/airake/commands/acompc.rb