Class: Tidy::Compile

Inherits:
Object
  • Object
show all
Defined in:
lib/tidy/compile.rb

Constant Summary collapse

DEFAULTS =
{ 
  :default_background_color=>"#000000",
  :default_frame_rate=> 30,
  #:incremental=>true,
  :use_network=>false,
  :verbose_stacktraces=>true,
  :omit_trace_statements=>false,
  :static_link_runtime_shared_libraries=>true
  #:warnings=>true
}
DEFAULT_PATHS =

TODO: introduce config file for things like this.

%w[src ~/.tidy/tidy-as3]

Class Method Summary collapse

Class Method Details

.air(args) ⇒ Object

args can include: :width, :height, :output, etc… and underscore_versions of the compiler arguments



41
42
43
44
45
46
47
48
49
50
# File 'lib/tidy/compile.rb', line 41

def self.air(args) 
  build args, "mxmlc +configname=air " + parse_options(args)
  Axml.new( args )
  unless args[:do_not_launch]
  	#if File.exists? File.expand_path("~/mm.cfg")
    #	File.rename(File.expand_path("~/mm.cfg"), File.expand_path("~/mm.cfg") + ".bak")
    #end
    puts `adl bin/#{args[:output]}.axml`
  end
end

.build(args, command) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/tidy/compile.rb', line 73

def self.build(args,command)
  puts "Compiling with TidyFlash #{Tidy::Version.number}"
  puts "will execute: #{command}"
  #puts "cd #{FileUtils.pwd} && #{command}"
=begin
  command_result = command
  filtered_result = command_result.to_a.map{|l| l unless l.match(/^Reason|^Recompile/)}.compact
  puts filtered_result
=end
  IO.popen(command){ |process| process.each { |line| puts line } }
  swf_url(args)
end

.demo(args) ⇒ Object

usage: DemoConfig.new(:vars=>:anotherVar=>2.4, :output=>‘variation’)



60
61
62
63
64
65
# File 'lib/tidy/compile.rb', line 60

def self.demo(args)
  DemoConfig.new(:vars=>args[:vars] || {}, 
                :class=>'DemoConfig', 
                :output=>"src/DemoConfig.as")
  air(args.merge(:paths=>["src"]))
end

.get_compile_command(args, initial_command) ⇒ Object



67
68
69
70
71
# File 'lib/tidy/compile.rb', line 67

def self.get_compile_command(args, initial_command)
	command = initial_command + " " + parse_options(args)
	command_result = command
  	return command
end

.parse_options(args) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/tidy/compile.rb', line 88

def self.parse_options(args)
  options = DEFAULTS.dup()
  options.each_pair do |k,v|
  options[k] = args.delete(k) unless args[k].nil?
 end
 options.merge! args[:mxmlc] unless args[:mxmlc].nil?
  paths = DEFAULT_PATHS
  paths = args[:paths].concat(DEFAULT_PATHS) unless args[:paths].nil?
  paths = paths.map{|path| "-source-path+=#{File.expand_path path}" }.join(" ")
  "#{options.to_flex_arguments} -default-size #{args[:width]||WIDTH} #{args[:height]||HEIGHT} #{paths}  -o=#{File.expand_path swf_url(args)} #{File.expand_path args[:main]}"
end

.swf(args) ⇒ Object

TODO: make adl launch an air file with a webkit instance and the swf inside it



56
57
58
# File 'lib/tidy/compile.rb', line 56

def self.swf(args)
  build args, "mxmlc " + parse_options(args)
end

.swf_url(args) ⇒ Object

:warnings=>true



33
34
35
# File 'lib/tidy/compile.rb', line 33

def self.swf_url(args)
  "bin/#{args[:output]}.swf"
end