Skip to content

Commit

Permalink
#80 implemented ado_home
Browse files Browse the repository at this point in the history
  • Loading branch information
kberov committed Feb 23, 2015
1 parent a48e770 commit 2d1b229
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Ado

0.81 2015-02-23
- Implemented Ado::ado_home - pointing always to where
Ado is installed.

0.80 2015-02-22
- Implemented do_sql_file application helper in Ado::Plugin::AdoHelpers.
- Improved documentation.
Expand Down
24 changes: 22 additions & 2 deletions lib/Ado.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ our $CODENAME = 'U+2C07 GLAGOLITIC CAPITAL LETTER DZELO (Ⰷ)';
use Ado::Control;
use Ado::Sessions;

has ado_home => sub {
my $app = shift;
my $class = ref $app;
my @home = splitdir $INC{class_to_path $class};
while (pop @home) {
return Mojo::Home->new->parts([@home])
if -s catfile(@home, 'bin', 'ado'); # bin/..
}
return;
};
sub CODENAME { return $CODENAME }
has sessions => sub { Ado::Sessions::get_instance(shift->config) };

Expand Down Expand Up @@ -137,6 +147,16 @@ For a more detailed description on what Ado is and how to get started with Ado s
Ado inherits all attributes from Mojolicious and implements the following ones.
=head2 ado_home
Returns an instance of L<Mojo::Home> pointing to the
base directory where Ado is installed.
~$ ado eval 'say app->ado_home'
/home/berov/opt/public_dev/Ado
=head2 CODENAME
Returns the current C<CODENAME>.
Expand All @@ -152,8 +172,8 @@ The guessing order is the following:
=item 1. If C<$ENV{MOJO_HOME}> is defined, it is honored.
=item 2. The upper directory of the directory in which the starting executable C<$app-E<gt>>moniker>
s found, eg C<bin/..>
=item 2. The upper directory of the directory in which the starting executable C<$app-E<gt>>moniker> is found, eg C<bin/..>.
This may happen to be the same as L</ado_home>.
=item 3. Fallback to L<Mojo/home>. This is the usual behavior of any L<Mojo> application.
Expand Down

0 comments on commit 2d1b229

Please sign in to comment.