Running Project Sprouts

A few weeks ago I attended the SanFlashCisco usergroup meeting which was really great. After the meeting we moved to the Mars bar where I got to know Luke Bayes who founded Project Sprouts. Project Sprouts is a Ruby based open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3, Adobe AIR and Flex projects. Also be sure to check the the GitHub repository.

The following works on a Mac with Ruby and RubyGems installed but should be similar under Windows. Open the Terminal, switch to your working directory where you want to create your new project and:

# installs project sprouts
sudo gem install sprout
# creates a new Flex 4 project named SproutsExample
sprout -n flex4 SproutsExample
# switch directory
cd SproutsExample
# build the project
rake

Now you see all dependencies like SDK and Flash Player being downloaded. So you can run this on a machine without Flex SDK and Flash Player installed because Sprouts handles all dependencies. However, I got this error:

/Library/Ruby/Gems/1.8/gems/sprout-flashplayer-bundle-10.22.7/lib/clix_wrapper.rb:20:  (RuntimeError)
[ERROR] You must install the rb-appscript gem to use the desktop debug Flash Player, you do this by running: sudo gem install rb-appscript

As being told I tried to run: sudo gem install rb-appscript which ended up in this error:

ERROR:  Error installing rb-appscript:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

After a little web search I found out that I need to install the latest XCode since I am on Snow Leopard.

Having XCode installed I tried again sudo gem install rb-appscript and it works!

So another try with rake and horray, the project gets compiled and the standalone flash player comes up showing the compiled default project!

So far so good. Now let’s try to create a class and a unit test for it.
Due to a little bug in the flex 4 gem edit scripts/generate and replace

 begin
      Sprout::Sprout.generate('flex4', ARGV.shift, ARGV, File.dirname(File.dirname(__FILE__)))
    rescue RubiGen::GeneratorError => e
      Sprout::Sprout.generate('as3', ARGV.shift, ARGV, File.dirname(File.dirname(__FILE__)))
    end

with

Sprout::Sprout.generate('as3', ARGV.shift, ARGV, File.dirname(File.dirname(__FILE__)))

btw: when the fix for this is in place update with

sudo gem update sprout-flex4-bundle

So, now you are ready to create a class including test classes:

# creates the class com.soenkerohde.util.MathUtil and test classes
script/generate com.soenkerohde.util.MathUtil

You see the output

create  src/com/soenkerohde/util
create  src/com/soenkerohde/util/MathUtil.as
create  test/com/soenkerohde/util
create  test/com/soenkerohde/util/MathUtilTest.as
force  test/AllTests.as
# Run the tests
rake test

Now you see your tests compiling and they fail for now to remind you that you haven’t implemented the actual test code yet.

Pretty impressed by Sprouts so far but enough for now. In my next post I will try to go a little bit deeper and check what else Sprouts can do for me to not waste time on what can be automated.

3 comments to Running Project Sprouts

  • Alan

    I was looking for the ‘mkmf.rb can’t find header files for ruby’ issue as well and got here. Thanks. Are you still working with Sprouts?

  • Glad it helped! Currently not but I want to use it in the future when I find some free time.

  • Hey, thanks for this. Sprout is a real time saver and really helps set patterns for team development! Thanks for sharing. Curious, am I missing any command line option to list out the installed bundles, etc. that I could use here with this? For example, ‘flex4′ is not really a readily recognizable option right off the top… I ended up having to do a `gem search sprout` in order to hunt down the option initially. Seems awkward.