Roman F.

NAME

Project::Environment::Role - Moose role for Project::Environment

VERSION

version v1.2.0

DESCRIPTION

This role defines most of the logic for Project::Environment.

ATTRIBUTES

project_root

An instance of Path::Tiny, which defines the root path of the project as detected by Path::FindDev.

Will croak if it cannot successfully build project_root.

mpath()

environment_filename

A name of the file to look for in the "project_root" directory to read the environment string from.

File must contain a single line with the environment name. It will attempt to chomp the line. So, this will work:

 echo "develop" > .environment

Default: .environment

environment_path

Full path to the "environment_filename". Basically just concatenation of project_root and environment_filename.

default_environment

You can set a default environment in your subclass for when no environment could be detected.

 package MyApp::Environment;
 use Moose;
 extends 'Project::Environment';

 has '+default_environment' => (default => 'development');

has_default_environment

A predicate method to test if a default environment is set or not.

environment_variable

An environment variable name to look for the value. This will always take precedence over anything.

 PROJECT_ENVIRONMENT=test prove t/app.t

Default: PROJECT_ENVIRONMENT

project_environment

Finally the star of the show. This attribute stores the actual value of the environment as it was established. The value is determined in the following order:

environment_variable

First, we check the value of the environment variable. If the value is set, then we use that as project_environment.

.environment

Second, we check the .environment file in the project_root.

default_environment

Lastly, we check the default_environment attribute for a default value

If the value cannot be established, the builder will croak with an explanation.

METHODS

environment

Shortcut for "project_environment".

env

Shortcut for "project_environment".

AUTHOR

Roman F. <romanf@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Roman F..

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.