Class: Airake::Commands::Mxmlc

Inherits:
Base show all
Defined in:
lib/airake/commands/mxmlc.rb

Overview

MXMLC (MXML compiler)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#assert_not_blank, #assert_required, #escape, #include_classes, #library_paths, #process, #relative_path, #source_paths, #windows?, #with_options

Constructor Details

#initialize(options = {}) ⇒ Mxmlc

Create MXMLC command.

Options

mxmlc_path

Path to flex compiler, defaults to ‘mxmlc’

swf_path

Path to generated swf (required)

target_file

Path to target file (.mxml file) (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

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/airake/commands/mxmlc.rb', line 22

def initialize(options = {})
  assert_required(options, [ :swf_path, :target_file, :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

Instance Attribute Details

#config_nameObject (readonly)

Returns the value of attribute config_name.



9
10
11
# File 'lib/airake/commands/mxmlc.rb', line 9

def config_name
  @config_name
end

#debugObject (readonly)

Returns the value of attribute debug.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def debug
  @debug
end

#lib_dirObject (readonly)

Returns the value of attribute lib_dir.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def lib_dir
  @lib_dir
end

#mxmlc_extra_optsObject (readonly)

Returns the value of attribute mxmlc_extra_opts.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def mxmlc_extra_opts
  @mxmlc_extra_opts
end

#mxmlc_pathObject (readonly)

Returns the value of attribute mxmlc_path.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def mxmlc_path
  @mxmlc_path
end

#src_dirsObject (readonly)

Returns the value of attribute src_dirs.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def src_dirs
  @src_dirs
end

#swf_pathObject (readonly)

Returns the value of attribute swf_path.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def swf_path
  @swf_path
end

#target_fileObject (readonly)

Returns the value of attribute target_file.



8
9
10
# File 'lib/airake/commands/mxmlc.rb', line 8

def target_file
  @target_file
end

Instance Method Details

#compileObject

Get the mxmlc compile command



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/airake/commands/mxmlc.rb', line 35

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(@target_file)
  process(command)
end