++ed by:

1 non-PAUSE user.

Jan Gehring

NAME

Rex::Apache::Build - Build your WebApp Package

DESCRIPTION

With this module you can prepare your WebApp for deployment.

SYNOPSIS

 yui_path "./yuicompressor-2.4.6.jar";

 get_version_from "webapp/lib/MyApp.pm", qr{\$VERSION=([^;]+);};

 get_version_from "webapp/index.php", qr{\$VERSION=([^;]+);};

 task "build", sub {
   sprocketize;
   sprocketize "app/assets/javascript/*.js",
    out => "public/js/sprockets.js";

   coffee;
   coffee "app/assets/coffee",
    out => "public/js";

   sass;
   sass "app/assets/stylesheets",
    out => "public/stylesheets";

   yui;
   yui compress => "file1.js", "file2.js", "file3.css";
   yui compress => glob("public/javascript/*.js"), glob("public/css/*.css");

   build;

   build "webapp",
    source  => "webapp/",
    version => "1.0";
 };

EXPORTED FUNCTIONS

yui_path($path_to_yui_compressor)

This function sets the path to the yui_compressor. If a relative path is given it will search from the path where the Rexfile is in.

coffee_path($path_to_coffee)

This function sets the path to the coffee compiler. If a relative path is given it will search from the path where the Rexfile is in.

sprocketize_path($path_to_sprocketize)

This function sets the path to the sprocketize compiler. If a relative path is given it will search from the path where the Rexfile is in.

sass_path($path_to_sass)

This function sets the path to the sass compiler. If a relative path is given it will search from the path where the Rexfile is in.

yui($action, @files)

Run a yui command.

 task "build", sub {
   # this will compress the given files
   yui compress => "file1.js", "file2.js", ...;

   # yui without any parameters will compress all files in public/javascripts
   yui;
 };
build([$name, %options])

This function builds your package. Currently only tar.gz packages are supported.

 # this will a package of the current directory named after the
 # directory of the Rexfile and append the version provided by
 # get_version_from() function
 # This function builds a tar.gz archive.
 task "build", sub {
   build;
 };

 # this will build a package of the current directory named "my-web-app" and
 # append the version provided by get_version_from() function.
 task "build", sub {
   build "my-web-app";
 };

 # this function will build a package of the directory "html", name it
 # "my-web-app" and append the version "1.0" to it.
 task "build", sub {
   build "my-web-app",
     path => "html",
     version => "1.0",
     exclude => ["yuicompressor.jar", "foobar.html"],
     type => "tgz";
 };
get_version_from($file, $regexp)

Get the version out of a file.

sprocketize($path_to_js_files, %option)

This function calls the sprocketize command with the given options.

 task "build", sub {
   sprocketize "app/javascript/*.js",
            include   => [qw|app/javascripts vendor/sprockets/prototype/src|],
            asset_root => "public/js",
            out      => "public/js/sprockets.js";

   # to include more use an arrayRef
   sprocketize ["app/javascript/*.js", "app/javascript/po/*.js"],
            include   => [qw|app/javascripts vendor/sprockets/prototype/src|],
            asset_root => "public/js",
            out      => "public/js/sprockets.js";

   # if called without parameters

   sprocketize;

   # it will use the following defaults:
   # - javascript (sprockets) in assets/javascripts/*.js
   # - include  assets/javascripts
   # - asset_root public
   # - out public/${name_of_directory_where_Rexfile_lives}.js
 };
coffee($path, %options)

Compile coffee files to javascript.

 task "build", sub {
   # this command will build all files in "coffeesrc" and
   # write the output to "javascripts"
   coffee "coffeesrc",
      out  => "javascripts";

   # without parameters it will build all files in assets/coffee
   # and write the output to public/javascripts.
   coffee;
 };
sass($input_dir, %option)

This command will compile all sass files in $input_dir.

 task "build", sub {
   # this command will compile all sass files from app/assets/stylesheets
   # and put the output into public/stylesheets.
   sass "app/assets/stylesheets",
    out => "public/stylesheets";

   # The default is to build all files in assets/sass and put the output
   # into public/css.
   sass;
 };