Archives For Airake

Rake tasks and generators for Adobe AIR apps.

popen'ing part 2

November 9, 2007 — Leave a comment

I guess I should rtfm before blogging about something. This is my new IO.popen block which allows you to run a process which wants input, like the adt (Adobe Debug Tool) package task (which asks for your certificate password):

IO.popen(@cmd) do |f|
  while s = f.read(1)
    printf s
    STDOUT.flush
  end
end
@process = $?

View the airake/runner.rb. The IO.read call if not given args will block until EOF. This means we can’t output anything until the process ends which makes it appear hung if its asking for input. The waitpid call in the previous version just picks up the Process::Status since the read was the blocking call, but you can get that from $? after the popen block returns. I needed to add the STDOUT flush since printf isn’t guaranteed to (and wasn’t) outputing on the adt password input since I think it waits for a newline. Also this totally works on windows, although the whole read char + printf + flush makes it feel like a typewriter. This might be solved by using the IO.read_nonblock method. I’ll need to look into that.

Also, I updated the blog css, which I was told was depressing. Now its a total ripoff of coudal.com instead of danwebb.net

popen'ing

November 7, 2007 — Leave a comment

I updated airake to work on windows (thanks Todd). Instead of using system (or %x), I am trying IO.popen:

IO.popen(@cmd) do |f|
  @output = f.read
  @process = Process.waitpid2(f.pid)[1]
end

and in windows you’ll need to cmd.exe /c it:

@cmd = RUBY_PLATFORM =~ /win32/ ? "cmd.exe /c #{cmd}" : cmd

This thread was helpful and I popened a new airake/runner.rb version. The FCSH daemon still doesn’t work in windows yet.

airake gives you tasks for compiling, debugging, testing and packaging Adobe AIR applications. It also has a basic project generator/scaffold. All this was made possible because of the prolific newgem and rubigen gems.

To get started, checkout airake.rubyforge.org

The tasks and project might be a little Flex specific (cause of the particular project we are working on), so feel free to poke around or contribute back. Also I only tested it on MacOSX.

Some of the FCSH (flex compiler shell) daemon and wrappers are from the Sprout project, so be sure to check them out.