Class Bee::Task::Default
In: lib/bee_task_default.rb
Parent: Package

Package for default tasks (tasks with no package).

Methods

bee   cat   cd   chmod   chown   copy   cp   echo   erb   find   gem   get   gunzip   gzip   link   ln   mkdir   move   mv   print   prompt   pwd   rdoc   required   rm   rmdir   rmrf   sleep   tar   targz   test   touch   untar   unzip   wait   zip  

Public Instance methods

Run another bee build file.

  • file: the build file to run, relative to current build file. Optional, defaults to ‘build.yml’.
  • target: target or list of targets to run (default target if omitted).
  • properties: boolean (true or false) that tells if properties of current build file should be sent and overwrite those of target build. Properties modified in child build don‘t change in parent one. Defaults to false.

Example

 - bee:
     file:       "doc/build.yml"
     target:     "pdf"
     properties: true

Print contents of a given file on the console. Parameter is the name of the file to output, as a String.

Example

 - cat: "doc/welcome-message.txt"

Change working directory. This change will persist for all tasks in the current target. Entering a new target, working directory will recover its default value, which is the directory of the build file (or property ‘base’). Parameter is a String with directory to change to.

Example

 - cd: "build"

Change permissions for a set of files. Parameters is a Hash with following entries:

  • files: files to change permissions for, as a glob.
  • mode: permissons as an Unix integer (such as 0644 or 0755). Note that numbers starting with 0 are considered octal, with 0x, they are supposed to be hexa and in base 10 otherwise.
  • recursive: tells if should process directories recursively. Optional, defaults to ‘false’.

Example:

  - chmod:
      files: /usr/local/bin/*
      mode:  0755

Note:

  This task is not implemented under Windows.

Change owner and group for a set of files. Parameters is a Hash with following entries:

  • files: files to change owner for, as a glob.
  • user: the user to change for, may be a name or an ID (integer). If not set, the user is not changed.
  • group: the group to change for, may be a name or an ID (integer). If not set, the group is not changed.
  • recursive: tells if should process directories recursively. Optional, defaults to ‘false’.

Example:

  - chown:
      files:     /home/casa
      user:      casa
      group:     staff
      recursive: true

Note:

  This task is not implemented under Windows.

Copy filtered files. Parameter is a hash with following entries:

  • root: root directory for files to copy. Optional, defaults to current directory.
  • includes: list of globs for files to copy. Optional, defaults to ’**/*’ to include all files recursively.
  • excludes: list of globs for files to exclude from copy. Optional, default to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • flatten: tells if included files should be copied in destination directory, ignoring their subdirectory. Optional, defaults to false.

Example:

To copy all files from directory ‘src’, except those living in ‘CVS’ directories, into directory ‘destination’, you could write:

  - copy:
      root:     src
      includes: **/*
      excludes: **/CVS/**/*
      dest:     destination

Note: this task only deals with files. Thus, ‘includes’ and ‘excludes’ globs should be ones for files.

Copy files or directories to destination file or directory. Parameter is a Hash with following entries:

  • src: glob or list of globs for source files or directories to copy. Included source directories are copied recursively.
  • dest: destination file or directory.

Example

 - cp:
     src:  "img/*"
     dest: :doc

Print a message on console. If message is not a string, this task outputs the inspected value of the object.

  • message: message to print.

Example

 - echo: "Hello World!"

Run an ERB file or source in bee context and store result in a file or property. Parameter is a Hash with following entries:

  • source: ERB source text (if no ‘src’).
  • src: ERB file name (if no ‘source’).
  • dest: file where to store result (if no ‘property’).
  • property: property name where to store result (if no ‘dest’).

Example

 - erb: { src: "gem.spec.erb", dest: "gem.spec" }

Notes

In these ERB files, you can access a property foo writing:

 <p>Hello <%= foo %>!</p>

Find files for a glob or list of globs and store list in a property. Parameter is a Hash with entries:

  • root: root directory for file search. Defaults to ’.’ (current directory).
  • includes: glob or list of globs for files to look for. Defaults to ’**/*’ to include all files recursively.
  • excludes: glob or list of globs for files to exclude from search. Defaults to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • property: name of the property to set.
  • join: a character used to join the list in a string. Defaults to nil so that list is not joined.

Example

To find all PNG in files in ‘img’ directory, and store the list in property image_files, one could write:

 - find:
     root:     "img"
     includes: "**/*.png"
     property: "image_files"

Generate a Gem package in current directory, named after the Gem name and version. Parameter is the name of the Gem description file.

Example

 - gem: :gem_spec

Get a given URL and store its content in a given file. Parameters is a Hash with following entries:

  • url: the URL to get.
  • dest: destination file. Optional, defaults to retrieved file name in current directory. If destination is a directory, file is saved in destination directory with the name of the retrieved file.
  • limit: the redirections limit. Optional, defaults to 10.

Example

  - get:
      url: http://rubyforge.org/frs/download.php/22185/bee-0.4.0.zip

Expand a GZIP archive for a given file. Parameter is a Hash with following entries:

  • src: GZIP file to expand.
  • dest: destination for expanded file. Destination file can be guessed (and thus omitted) for src files ’.gz’, ’.gzip’ and ’.tgz’; corresponding dest for latest will be ’.tar’.

Example

 - gunzip:
     src: "dist.tar.gz"
     dest: "dist.tar"

Generate a GZIP archive for a given file. Parameter is a Hash with following entries:

  • src: source file to generate GZIP for.
  • dest: GZIP file to generate. Defaults to the src file with ’.gz’ extension added.

Example

 - gzip:
     src: "dist.tar"
     dest: "dist.tar.gz"
link(parameters)

Alias for ln

Make a symbolic link from a source file to a destination one. Parameter is a Hash with following entries:

  • old: source of the link, as a glob. If there are more than one file to link, this task will make links ‘new/file’ for each file of the glob.
  • new: destination of the link.

Example

  - ln:
      old: /usr/local
      new: /opt

Note:

  This task is not implemented under Windows.

Make a directory, and parent directories if necessary. Doesn‘t complain if directory already exists. Parameter is directory to create as a String or a list of directories as an Array of Strings.

Example

 - mkdir: "foo/bar"

Move filtered files. Parameter is a hash with following entries:

  • root: root directory for files to move. Optional, defaults to current directory.
  • includes: list of globs for files to move. Optional, defaults to ’**/*’ to include all files recursively.
  • excludes: list of globs for files to exclude from move. Optional, default to nil to exclude no file.
  • flatten: tells if included files should be moved to destination directory, ignoring their subdirectory. Optional, defaults to false.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.

Example:

To move all files from directory ‘src’, except those living in ‘CVS’ directories, into directory ‘destination’, you could write:

  - move:
      root:     src
      includes: **/*
      excludes: **/CVS/**/*
      dest:     destination

Note: this task only deals with files. Thus, ‘includes’ and ‘excludes’ globs should be ones for files and directories from root will not be affected by this task.

Moves files or directories to destination file or directory. Parameter is a Hash with following entries:

  • src: glob or list of globs for source files or directories to move. Included source directories are moved recursively.
  • dest: destination file or directory.

Example

 - mv:
     src:  "**/*~"
     dest: :trash
print(message)

Alias for echo

Prompt the user for the value of a given property matching a pattern.

  • message: message to print at prompt. Should include a description of the expected pattern.
  • property: the name of the property to set.
  • default: default value if user doesn‘t type anything. Written into square brakets after prompt message. Optional.
  • pattern: a Ruby pattern for prompted value. If this pattern is not matched, this task will prompt again. Optional, if no pattern is given, any value is accepted.
  • error: the error message to print when pattern is not matched.
  • attempts: number of allowed attempts. Optional, defaults to 0, which means an unlimited number of attempts.

Example

 - prompt:
     message:  "Enter your age"
     property: "age"
     default:  18
     pattern:  "^\\d+$"
     error:    "Age must be a positive integer"

Put working directory in a given property. Parameter is the name of the property to write current directory into.

Example

  - pwd: current_dir

Generate RDoc documentation for a given list of globs to include or exclude and a destination directory. Parameter is a Hash with following entries:

  • root: root directory for files to include. Defaults to current directory.
  • includes: glob or list of globs for files or directories to document. Defaults to ’**/*’ to include all files.
  • excludes: glob or list of globs for files or directories that should not be documented. Defaults to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • dest: destination directory for generated documentation.
  • options: additional options as a string or list of strings.

Example

 - rdoc:
     includes: ["README", "LICENSE", "#{src}/**/*"]
     dest: :api

Tests a required library and prints an error message if import fails. Parameter is a Hash with entries:

  • library: required library (as in require call).
  • message: error message to print if require fails.

Example

 - required:
     library: foo
     message: >
       Library foo must be installed (gem install foo) to run
       task bar.

Delete files for a given glob or list of globs. Parameter is a glob or list of globs for files to delete. This task will raise an error if told to delete a directory. Use task ‘rmrf’ to do so.

Example

 - rm: ["**/*~", "**/.DS_Store"]
rmdir(globs)

Alias for rmrf

Delete files and directories recursively. Parameter is a glob or list of globs for files and directories to delete.

Example

 - rmrf: :build

Wait for a given amount of time.

  • time: time to wait, in seconds, as an integer or float.

Example

 - sleep: 3.5

Generate a TAR archive. Parameter is a Hash with following entries:

  • root: root directory for files to include. Defaults to current directory.
  • includes: glob or list of globs for files to select for the archive. Defaults to ’**/*’ to include all files recursively.
  • excludes: glob or list of globs for files to exclude from the archive. Defaults to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • dest: the archive file to generate.

Example

 - tar:
     includes: "**/*"
     excludes: ["build", "build/**/*", "**/*~"]
     dest: :tar_archive

Note

If archive already exists, it‘s overwritten.

Generate a TAR.GZ archive. Parameter is a Hash with following entries:

  • root: root directory for files to include. Defaults to current directory.
  • includes: glob or list of globs for files to select for the archive. Defaults to ’**/*’ to include all files recursively.
  • excludes: glob or list of globs for files to exclude from the archive. Defaults to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • dest: the archive file to generate.

Example

 - targz:
     excludes: ["build/**/*", "**/*~"]
     dest:     :targz_archive

Note

If archive already exists, it‘s overwritten.

Run Ruby unit tests listed as a glob or list of globs in a given directory (that defaults to current one). Parameter is a Hash with following entries:

  • root: root directory for files to include. Defaults to current directory.
  • includes: glob or list of globs for unit test files to run. Defaults to ’**/*’ to include all files recursively.
  • excludes: glob or list of globs for unit test files to exclude. Defaults to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • dir: directory where to run unit tests.

Example

 - find:
     root:     :test
     includes: "**/tc_*.rb"
     dir:      "test"

Update modification time and access time of files in a list. Files are created if they don‘t exist. Parameter is a glob or list of globs for files to touch.

Example

  - touch: '#{target}/classes/**/*.class'

Extract TAR archive to a destination directory. Gziped archives are managed if their extension is ’.tgz’ or ’.tar.gz’. Extracted files are overwritten if they already exist. Parameter is a Hash with following entries:

  • src: archive to extract.
  • dest: destination directory for extracted files. Optional, defaults to current directory.

Example

  - untar:
      src:  myarchive.tar.gz
      dest: mydir

Extract ZIP archive to a destination directory. Existing extracted files are not overwritten and result in an error. Parameter is a Hash with following entries:

  • src: archive to extract.
  • dest: destination directory for extracted files. Optional, defaults to current directory.

Example

  - unzip:
      src:  myarchive.zip
      dest: mydir
wait(time)

Alias for sleep

Generate a ZIP archive. Parameter is a Hash with following entries:

  • root: root directory for files to include in the archive. Defaults to ’.’ for current directory.
  • includes: glob or list of globs for files to select for the archive. Defaults to ’**/*’ to include all files recursively.
  • excludes: glob or list of globs for files to exclude from the archive. Defaults to nil to exclude no file.
  • dotmatch: tells if joker matches dot files. Optional, defaults to false.
  • dest: the archive file to generate.
  • prefix: prefix for archive entries (default to nil).

Example

 - zip:
     excludes: ["build/**/*", "**/*~"]
     dest:     :zip_archive

Note

If archive already exists, files are added to the archive.

[Validate]