summaryrefslogtreecommitdiff
path: root/libpiny/lib/Piny/User.pm
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2011-04-20 21:11:57 -0700
committerJulian Blake Kongslie <jblake@omgwallhack.org>2011-04-20 21:11:57 -0700
commitbabfac96492ef68d51110f6dd5f74eb7362070b8 (patch)
tree4888591e850e5f29fd143f51032cb448d0404954 /libpiny/lib/Piny/User.pm
parentda6e245112270694be287e0aa019fc44d3486f7f (diff)
downloadpiny-code-babfac96492ef68d51110f6dd5f74eb7362070b8.tar.gz
piny-code-babfac96492ef68d51110f6dd5f74eb7362070b8.zip
Backend support for user configs.
Diffstat (limited to 'libpiny/lib/Piny/User.pm')
-rw-r--r--libpiny/lib/Piny/User.pm33
1 files changed, 32 insertions, 1 deletions
diff --git a/libpiny/lib/Piny/User.pm b/libpiny/lib/Piny/User.pm
index 6267ecb..aa01ba7 100644
--- a/libpiny/lib/Piny/User.pm
+++ b/libpiny/lib/Piny/User.pm
@@ -10,6 +10,7 @@ use Moose;
use Moose::Util::TypeConstraints;
use MooseX::StrictConstructor;
+use Piny::Config;
use Piny::Email;
use Piny::Group;
@@ -49,6 +50,20 @@ has 'password_hash' =>
, init_arg => undef
);
+has 'home' =>
+ ( is => 'ro'
+ , isa => 'Path'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'config' =>
+ ( is => 'ro'
+ , isa => 'Piny::Config'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
has 'email' =>
( is => 'ro'
, isa => 'Piny::Email'
@@ -180,10 +195,26 @@ sub _build_password_hash {
return $s->pwent( )->[1];
};
+sub _build_home {
+ my ( $s ) = @_;
+
+ return $s->pwent( )->[7];
+};
+
+sub _build_config {
+ my ( $s ) = @_;
+
+ return Piny::Config->new( confpath => $s->home . "/.gitconfig" );
+};
+
sub _build_email {
my ( $s ) = @_;
- return Piny::Email->new( address => $s->pwent( )->[6] );
+ if ( not defined $s->config->user_email ) {
+ die "You must provide a user.email attribute in your .gitconfig!";
+ };
+
+ return Piny::Email->new( address => $s->config->user_email );
};
sub _build_groups {