Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9d85133d99
Fetching contributors…

Cannot retrieve contributors at this time

141 lines (114 sloc) 4.31 kb
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
require 'emergent'
# Files to be used for describeType
attr_accessor :imported_files
# metadata tags in actionscript/flex project
attr_accessor :metadata
# path to the application file
attr_accessor :application_path
desc "Very advanced Flex compilation"
task :debug => [:copy, :replace, :compile]
desc "Very advanced Flex compilation, without the metadata"
task :run => [:replace, :compile]
desc "Copy files to temp directories"
task :copy => :environment do
FileUtils.cp(flex_path, generated_path)
@application_path = generated_path
end
desc "Replace any patterns we want in the temp files"
task :replace => :environment do
@application_path ||= flex_path # if we skipped over the copy part
parse
generate
end
desc "Compile the application"
task :compile => :environment do
@application_path ||= flex_path # if we skipped over the copy part
end
# Now that we have all of the applications metadata, we can EASILY customize
# the source code and how metadata works
# goes through and parses the metadata in your app
# does not do it for library projects, you would have to run this for them too
def parse
parse_describe_type_xml
parse_metadata
end
# replaces all the patterns
def generate
#File.replace_all( meadata patterns with somehting else)
end
# After we have run the DescribeTypeApplication swf, and stored the output to a file,
# we want to get that data, and save it as a ClassDocument object, so ruby can use it
def parse_describe_type_xml
# This is a very neat hack:
# 1) Get all the files in your app
# 2) Pass them into the DescribeTypeGenerator.mxml.erb template
# 3) Compile a swf
# 4) Get the XML output for all the describeType entries in your app
# 5) Save that data to a temporary file for rails to read
@imported_files = flex_files
template_path = File.join(@application_path, "templates/generation")
trace_output # set up crontab for reading flashlog output
app = File.join(@application_path, "DescribeTypeApplication.mxml")
File.open(app, 'r+') do |f|
f.print template(template_path) # parse the template file into this
end
compile app
end
#
# soon will use the javac-whenever cron library to check if the file is done being written to,
# for now it just sleeps a bit, you can modify the duration
def trace_output
tmp = File.join(File.expand_path("."), "sampleFile.txt")
flashlog_path = File.expand_path('~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt')
FileUtils.touch(tmp)
command = "tail -f #{flashlog_path} >> #{tmp} &"
system(command)
sleep 3
output = %x[lsof -c tail | grep flash] # captures the output of the command, like system but better
output.gsub(TAIL_PATTERN) do |item|
# if $2.to_i != previous, then don't yet kill it
system("kill -9 #{$1}")
end
end
def parse_metadata
end
def flex_files
File.list_files(File.join(RAILS_ROOT, "app/flex"), true, [".mxml, .as"])
end
def template(file)
ERB.new(file.read, nil, '-').result(b)
end
def flex_path
File.join(RAILS_ROOT, "app/flex")
end
def generated_path
File.join(flex_path, "generated")
end
# Create a remote library dependency on the corelib swc.
library :corelib
# Alias the compilation task with one that is easier to type
task :compile => [:tail, 'SomeProject.swf']
# Create an MxmlCTask named for the output file that it creates. This task depends on the
# corelib library and will automatically add the corelib.swc to it's library_path
mxmlc 'SomeProject.swf' => :corelib do |t|
t.input = 'src/SomeProject.as'
t.default_size = '800 600'
t.default_background_color = "#FFFFFF"
end
task :tail do |t|
puts 'tailing'
tmp = File.join(File.expand_path("."), "sampleFile.txt")
flashlog_path = File.expand_path('~/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt')
FileUtils.touch(tmp)
command = "tail -f #{flashlog_path} >> #{tmp} &"
system(command)
sleep 0.1
File.truncate(tmp, 0)
end
Jump to Line
Something went wrong with that request. Please try again.