Sha256: a889cba9475536fb9fc6349bc4a4734bc3fd6e5f2569b4a935b5cfb372440536

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

module Airake #:nodoc:
  
  module Commands #:nodoc:
    
    # MXMLC (MXML compiler)
    class Mxmlc < Base
      
      attr_reader :mxmlc_path, :mxmlc_extra_opts, :swf_path, :mxml_path, :lib_dir, :src_dirs, :debug
      attr_reader :config_name
      
      # Create MXMLC command.
      #
      # ==== Options
      # +mxmlc_path+:: Path to flex compiler, defaults to 'mxmlc'
      # +swf_path+:: Path to generated swf (required)
      # +mxml_path+:: Path to mxml (required)
      # +lib_dir+:: Path to lib directory. Will load swc files from here or source directories
      # +src_dirs+:: Path to source directories (required)
      # +config_name+:: Config name, like 'air'
      # +mxmlc_extra_opts+:: Extra options to pass to compiler
      #
      def initialize(options = {})
        assert_required(options, [ :swf_path, :mxml_path, :src_dirs ])
        
        default_mxmlc_path = options[:config_name].blank? ? "mxmlc" : "mxmlc +configname=#{options[:config_name]}"
        
        with_options(options, { :mxmlc_path => default_mxmlc_path })               
        
        @source_paths = source_paths(@src_dirs, @lib_dir)
        raise ArgumentError, "There aren't any valid source directories to compile" if @source_paths.empty?                
        @library_path = escape(@lib_dir) if @lib_dir and File.directory?(@lib_dir)
      end
            
      # Get the mxmlc compile command
      def compile
        command = []
        command << @mxmlc_path
        command << @mxmlc_extra_opts
        command << "-source-path #{@source_paths.join(" ")}"
        command << "-library-path+=#{@library_path}" unless @library_path.blank?
        command << "-output"
        command << escape(@swf_path)
        command << "-debug=#{@debug}" unless @debug.nil?        
        command << "--"
        command << escape(@mxml_path)
        process(command)
      end
      
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
airake-0.4.2 lib/airake/commands/mxmlc.rb
airake-0.4.3 lib/airake/commands/mxmlc.rb