Class: FlexUtils::Asc
- Inherits:
-
AbstractTool
- Object
- AbstractTool
- FlexUtils::Asc
- Defined in:
- lib/flexutils/asc.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
writeonly
output file path.
-
#defines ⇒ Object
writeonly
output file path.
-
#external_library_path ⇒ Object
writeonly
output file path.
-
#fail_on_error ⇒ Object
writeonly
output file path.
-
#fail_on_warning ⇒ Object
writeonly
output file path.
-
#incremental ⇒ Object
writeonly
output file path.
-
#keep_as3_metadata ⇒ Object
writeonly
output file path.
-
#library_path ⇒ Object
writeonly
output file path.
-
#locale ⇒ Object
writeonly
output file path.
-
#optimize ⇒ Object
writeonly
output file path.
-
#output ⇒ Object
writeonly
output file path.
-
#source_path ⇒ Object
writeonly
output file path.
-
#strict ⇒ Object
writeonly
output file path.
-
#target_player ⇒ Object
writeonly
output file path.
-
#use_network ⇒ Object
writeonly
output file path.
-
#verbose_stacktraces ⇒ Object
writeonly
output file path.
-
#warnings ⇒ Object
writeonly
output file path.
Class Method Summary collapse
Instance Method Summary collapse
- #command_string ⇒ Object
- #compile! ⇒ Object
- #compiler=(name) ⇒ Object
- #compiler_base_name ⇒ Object
- #compiler_flags ⇒ Object
- #defines_str ⇒ Object
-
#initialize(output) ⇒ Asc
constructor
A new instance of Asc.
Constructor Details
#initialize(output) ⇒ Asc
Returns a new instance of Asc.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/flexutils/asc.rb', line 23 def initialize( output ) @output = output @debug = false @optimize = true @strict = true @verbose_stacktraces = true @incremental = false @target_player = "9.0.0" @source_path = [] @library_path = [] @external_library_path = [] @locale = [] @keep_as3_metadata = [] @defines = Hash.new @warnings = Hash.new @fail_on_error = true @fail_on_warning = false self.compiler = "flex" end |
Instance Attribute Details
#debug=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def debug=(value) @debug = value end |
#defines=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def defines=(value) @defines = value end |
#external_library_path=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def external_library_path=(value) @external_library_path = value end |
#fail_on_error=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def fail_on_error=(value) @fail_on_error = value end |
#fail_on_warning=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def fail_on_warning=(value) @fail_on_warning = value end |
#incremental=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def incremental=(value) @incremental = value end |
#keep_as3_metadata=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def (value) @keep_as3_metadata = value end |
#library_path=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def library_path=(value) @library_path = value end |
#locale=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def locale=(value) @locale = value end |
#optimize=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def optimize=(value) @optimize = value end |
#output=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def output=(value) @output = value end |
#source_path=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def source_path=(value) @source_path = value end |
#strict=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def strict=(value) @strict = value end |
#target_player=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def target_player=(value) @target_player = value end |
#use_network=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def use_network=(value) @use_network = value end |
#verbose_stacktraces=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def verbose_stacktraces=(value) @verbose_stacktraces = value end |
#warnings=(value) ⇒ Object (writeonly)
output file path
5 6 7 |
# File 'lib/flexutils/asc.rb', line 5 def warnings=(value) @warnings = value end |
Class Method Details
.compile(*args) {|c| ... } ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/flexutils/asc.rb', line 53 def self.compile( *args ) c = self.new(*args) yield c c.compile! end |
Instance Method Details
#command_string ⇒ Object
114 115 116 117 118 |
# File 'lib/flexutils/asc.rb', line 114 def command_string all_flags = compiler_flags.delete_if { |item| (item.nil? || item =~ /^\s*$/) }.join(" ") "#{@compiler} #{all_flags}" end |
#compile! ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/flexutils/asc.rb', line 120 def compile! output = execute_command if block_given? yield($?, output) else puts output end if @fail_on_error and ($?.exitstatus != 0 or output.include? "Error:") fail "Compilation failed because of an error, see output above" end if @fail_on_warning and output.include? "Warning:" fail "Compilation failed because of a warning, see output above" end end |
#compiler=(name) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/flexutils/asc.rb', line 61 def compiler=( name ) if name.to_s == "air" @configname = "air" @compiler = "a" + compiler_base_name else @configname = "flex" @compiler = compiler_base_name end @compiler = command_path @compiler end |
#compiler_base_name ⇒ Object
49 50 51 |
# File 'lib/flexutils/asc.rb', line 49 def compiler_base_name "" end |
#compiler_flags ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/flexutils/asc.rb', line 87 def compiler_flags all_flags = [] all_flags << ("+configname=" + @configname) all_flags << "-source-path+=#{@source_path.join(",")}" unless @source_path.empty? all_flags << "-library-path+=#{@library_path.join(",")}" unless @library_path.empty? all_flags << "-external-library-path+=#{@external_library_path.join(",")}" unless @external_library_path.empty? all_flags << "-locale=#{@locale.join(",")}" unless @locale.empty? all_flags << "-keep-as3-metadata=#{@keep_as3_metadata.join(",")}" unless @keep_as3_metadata.empty? all_flags << "-debug" if @debug all_flags << "-strict" if @strict all_flags << "-optimize" if @optimize all_flags << "-verbose-stacktraces" if @verbose_stacktraces all_flags << "-use-network" if @use_network all_flags << "-incremental" if @incremental all_flags << "-target-player #{@target_player}" all_flags << (@warnings.keys.map { |item| "-#{item}=#{@warnings[item]}" }.join(" ")) all_flags << defines_str all_flags end |
#defines_str ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/flexutils/asc.rb', line 73 def defines_str defines = @defines.keys.map do |item| value = if @defines[item] =~ /\s/ "'#{@defines[item]}'" else @defines[item] end "-define+=#{item},#{value}" end defines.join(' ') end |