|
|||
Last update: 2015-10-09 | |||
Welcome License GemCutter Downloads DocumentationQuick StartUser Guide Tasks Reference Compiling Bee Developer Guide Slides (French) ProjectGIT RepositoryReleases Contributors Source API Test Coverage Bugs |
Tasks ReferenceHere is the reference for bee tasks: beeRun another bee build file.
Example - bee: file: "doc/build.yml" target: "pdf" properties: true catPrint 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" cdChange 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" chmodChange permissions for a set of files. Parameters is a Hash with following entries:
Example: - chmod: files: /usr/local/bin/* mode: 0755 Note: This task is not implemented under Windows. chownChange owner and group for a set of files. Parameters is a Hash with following entries:
Example: - chown: files: /home/casa user: casa group: staff recursive: true Note: This task is not implemented under Windows. copyCopy filtered files. Parameter is a hash with following entries:
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. cpCopy files or directories to destination file or directory. Parameter is a Hash with following entries:
Example - cp: src: "img/*" dest: :doc echoPrint a message on console. If message is not a string, this task outputs the inspected value of the object.
Example - echo: "Hello World!" erbRun an ERB file or source in bee context and store result in a file or property. Parameter is a Hash with following entries:
For more information ebout ERB syntax, please see documentation at: http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/. 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> findFind files for a glob or list of globs and store list in a property. Parameter is a Hash with entries:
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" forFor construct iterates on a list in the ‘in’ entry, putting values in a property which name is in the ‘for’ entry and running the block in the ‘do’ entry for each value.
Example - for: file in: [foo, bar] do: - print: "Creating #{file}..." - touch: :file The same using a reference to a property that is a list: - properties: list: ['foo', 'bar'] - target: test script: - for: name in: :list do: - print: "Hi #{name}!" To iterate five times, we could write (using a Ruby Range): - for: i in: (1..5) do: - print: :i To iterate on files in current directory, we could write: - for: file in: "Dir.glob('*')" do: - print: :file ftp_getGet a file from a remote FTP site. Raises a build error this operation fails. Parameter is a hash with following entries:
Example: - ftp_get: username: foo password: bar host: foo file: test.txt ftp_loginLogin to a remote FTP site. Useful to test a connection. Raises a build error if connection fails. Parameter is a hash with following entries:
Example - ftp_login: username: foo password: bar host: example.com ftp_mkdirMake a directory on a remote FTP site. Raises a build error this operation fails. Parameter is a hash with following entries:
Example: - ftp_mkdir: username: foo password: bar host: foo dir: test ftp_putPut a file to a remote FTP site. Raises a build error this operation fails. Parameter is a hash with following entries:
Example: - ftp_put: username: foo password: bar host: foo file: test.txt gemGenerate 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 gunzipExpand a GZIP archive for a given file. Parameter is a Hash with following entries:
Example - gunzip: src: "dist.tar.gz" dest: "dist.tar" gzipGenerate a GZIP archive for a given file. Parameter is a Hash with following entries:
Example - gzip: src: "dist.tar" dest: "dist.tar.gz" http_getGet a given URL and store its content in a given file. Parameters is a Hash with following entries:
Example - get: url: http://rubyforge.org/frs/download.php/22185/bee-0.4.0.zip ifIf construct will evaluate the expression in the ‘if’ entry and run block in the ‘then’ entry or ‘else’ entry accordingly.
Example - if: RUBY_PLATFORM =~ /darwin/ then: - print: Hello, I'm a Mac else: - print: Hello, I'm a PC linkAlias for ln. lnMake a symbolic link from a source file to a destination one. Parameter is a Hash with following entries:
Example - ln: old: /usr/local new: /opt Note: This task is not implemented under Windows. Send an email using SMTP.
Example - mail: from: "foo@bee.com" to: "bar@bee.com" subject: "Bee Release 0.6.2" message: "Hi! There is a new Bee release!" smtp: "smtp.bee.com" mkdirMake 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" moveMove filtered files. Parameter is a hash with following entries:
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. mvMoves files or directories to destination file or directory. Parameter is a Hash with following entries:
Example - mv: src: "**/*~" dest: :trash Alias for echo. promptPrompt the user for the value of a given property matching a pattern.
Example - prompt: message: "Enter your age" property: "age" default: "18" pattern: "^\\d+$" error: "Age must be a positive integer" pwdPut working directory in a given property. Parameter is the name of the property to write current directory into. Example - pwd: current_dir raiseAlias for throw. rdocGenerate RDoc documentation for a given list of globs to include or exclude and a destination directory. Parameter is a Hash with following entries:
Example - rdoc: includes: ["README", "LICENSE", "#{src}/**/*"] dest: :api requiredTests a required library and prints an error message if import fails. Parameter is a Hash with entries:
Example - required: library: foo message: > Library foo must be installed (gem install foo) to run task bar. rmDelete 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"] rmdirAlias for rmrf. rmrfDelete files and directories recursively. Parameter is a glob or list of globs for files and directories to delete. Example - rmrf: :build sleepWait for a given amount of time.
Example - sleep: 3.5 tarGenerate a TAR archive. Parameter is a Hash with following entries:
Example - tar: includes: "**/*" excludes: ["build", "build/**/*", "**/*~"] dest: :tar_archive Note If archive already exists, it’s overwritten. targzGenerate a TAR.GZ archive. Parameter is a Hash with following entries:
Example - targz: excludes: ["build/**/*", "**/*~"] dest: :targz_archive Note If archive already exists, it’s overwritten. testRun 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:
Example - find: root: :test includes: "**/tc_*.rb" dir: "test" Notes For ruby 1.9 and later, you must install gem ‘test-unit’ to run this task. throwThrow a build error with a given message.
Example - if: "not File.exists?('/etc/config')" then: - throw: "No /etc/config file found!" touchUpdate 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' tryTry construct will run the block in the ‘try’ entry and will switch to block in the ‘catch’ entry if an error occurs.
Example: - try: - print: "In the try block" - throw: "Something went terribly wrong!" catch: - print: "An error occured" untarExtract 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:
Example - untar: src: myarchive.tar.gz dest: mydir unzipExtract ZIP archive to a destination directory. Existing extracted files are not overwritten and result in an error. Parameter is a Hash with following entries:
Example - unzip: src: myarchive.zip dest: mydir waitAlias for sleep. whileWhile construct will run the block in the ‘do’ entry while the condition in the ‘while’ entry is true.
Example: - while: i > 0 do: - print: :i - rb: i -= 1 yaml_dumpDump the content of a given property into a YAML file.
Example - yaml_dump: prop: "my_list" file: "my_list.yml" yaml_loadLoad a YAML file in a given property.
Example - yaml_load: file: "my_list.yml" prop: "my_list" zipGenerate a ZIP archive. Parameter is a Hash with following entries:
Example - zip: excludes: ["build/**/*", "**/*~"] dest: :zip_archive Note If archive already exists, files are added to the archive. |
(C) Michel Casabianca & Contributors - 2006-2010 - Pictures courtesy of PD Photo.org |