Opera Software ASA > Arepa > Arepa::Config

Download:
Arepa-0.93.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Stalled  1
View/Report Bugs
Source  

NAME ^

Arepa::Config - Arepa package database API

SYNOPSIS ^

 my $config = Arepa::Config->new('path/to/config.yml');
 my $config = Arepa::Config->new('path/to/config.yml',
                                 builder_config_dir => 'path/to/builderconf');

 my $pdb_path = $config->get_key('package_db');
 my $repo_path = $config->get_key('repository:path');
 if ($config->key_exists('optional:key')) {
     $value = $config->get_key('optional:key');
 }

 my @builder_names = $config->get_builders;
 my %builder_config = $config->get_builder_config('some-builder');
 my $value = $config->get_builder_config_key('some-builder', $key);

DESCRIPTION ^

This class allows easy access to the Arepa configuration. The configuration is divided in two parts: the basic configuration (a single YAML file) and the configuration for the builders (a YAML file for each builder). Typically you would pass a single path for the main configuration, and the builder configuration would be loaded from the directory builders inside the same parent directory as the main configuration file. However, if you want you can specify a custom directory to load the builder configuration from.

This is an excerpt of an example configuration file:

 ---
 repository:
   path: /home/zoso/src/apt-web/test-repo/
 upload_queue:
   path: /home/zoso/src/apt-web/incoming
 package_db: /home/zoso/src/apt-web/package.db
 web_ui:
   base_url: http://localhost
   user_file: /home/zoso/src/apt-web/repo-tools-web/users.yml

This is an example of a builder configuration file (say, squeeze32.yaml):

 ---
 type: sbuild
 architecture: i386
 distribution: my-squeeze
 other_distributions: [squeeze, unstable]

Usually this class is not used directly, but internally in Arepa::Repository or Arepa::BuilderFarm.

METHODS ^

new($path)
new($path, %options)

It creates a new configuration access object for the configuration file in the given $path. The only valid option is builder_config_dir, the path where the builder configuration files are located.

key_exists($key)

Return true/false if the given configuration key is defined or not.

get_key($key)

Returns the value of the given $key in the configuration file. If it's not a top-level key, the subkeys must be separated by a colon (":"). If the key cannot be found, an exception is thrown.

get_builders

Returns an array of names of the defined builders.

get_builder_config($builder_name)

Returns a hash with the configuration of the given $builder_name. If no builder (or more than one) is found by that name, an exception is thrown.

get_builder_config_key($builder_name, $key)

Returns the value for the given configuration $key for the given $builder_name.

SEE ALSO ^

Arepa::BuilderFarm, Arepa::Repository.

AUTHOR ^

Esteban Manchado Velázquez <estebanm@opera.com>.

LICENSE AND COPYRIGHT ^

This code is offered under the Open Source BSD license.

Copyright (c) 2010, Opera Software. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

DISCLAIMER OF WARRANTY ^

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax highlighting: