https://github.com/polettix/dotcloud-environment
Perl module DotCloud::Environment
https://github.com/polettix/dotcloud-environment
Last synced: 2 months ago
JSON representation
Perl module DotCloud::Environment
- Host: GitHub
- URL: https://github.com/polettix/dotcloud-environment
- Owner: polettix
- Created: 2011-09-09T17:40:09.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-09-23T19:47:27.000Z (over 12 years ago)
- Last Synced: 2025-02-07T18:53:19.094Z (4 months ago)
- Language: Perl
- Homepage:
- Size: 133 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
NAME
====DotCloud::Environment - easy handling of environment in dotcloud
SYNOPSIS
========# Most typical usage, suppose you have a shared 'lib' directory
# under the root of your dotCloud directory hierarchy
use DotCloud::Environment 'path_for';
use lib path_for('lib');
use My::Shared::Module; # in your project-root/lib directory
# Most typical usage when you set a default environment.json file
# in the root of your project and you need to access the variables
# of the 'redis' service
use DotCloud::Environment 'dotenv';
my $redis_vars = dotenv->service_vars('redis');
# Not-very-typical usage examples from now on!
# get an object, fallback to $path if not in dotCloud deploy
my $dcenv = DotCloud::Environment->new(fallback_file => $path);
# you should now which services make part of your stack!
my $nosqldb_conf = $dcenv->service('nosqldb');
my $type = $nosqldb_conf->{type}; # e.g. mysql, redis, etc.
my $vars = $nosqldb_conf->{vars}; # e.g. login, password, host...
# suppose your nosqldb service is redis...
require Redis;
my $redis = Redis->new(server => "$vars->{host}:$vars->{port}");
$redis->auth($vars->{password});
# another service, similar approach
my $conf = $dcenv->service('database');
die 'not MySQL?!?' unless $conf->{type} eq 'mysql';
my ($host, $port, $user, $pass)
= @{$conf->{vars}}{qw< host port login password >}
require DBI;
my $dbh = DBI->connect("dbi:mysql:host=$host;port=$port;database=db",
$user, $pass, {RaiseError => 1});ALL THE REST
============Want to know more? [See the module's documentation](http://search.cpan.org/perldoc?DotCloud::Environment) to figure out
all the bells and whistles of this module!Want to install the latest release? [Go fetch it on CPAN](http://search.cpan.org/dist/DotCloud-Environment/).
Want to contribute? [Fork it on GitHub](https://github.com/polettix/DotCloud-Environment).
That's all folks!