summaryrefslogtreecommitdiff
path: root/usr/src/libpiny/lib/Piny/Repo.pm
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2010-10-11 21:53:06 -0700
committerJulian Blake Kongslie <jblake@omgwallhack.org>2010-10-11 21:53:06 -0700
commit0e5be768a7128745bd1f4a6a3904eb67a131e719 (patch)
tree5cd7ce823f97a45ed3cb853b251084d4e81c17a3 /usr/src/libpiny/lib/Piny/Repo.pm
parent2d90167e054a7dbbf2ccb1bb68e0160c355b1b8c (diff)
downloadpiny-code-0e5be768a7128745bd1f4a6a3904eb67a131e719.tar.gz
piny-code-0e5be768a7128745bd1f4a6a3904eb67a131e719.zip
Making libpiny saner
This is a rewrite of libpiny to make much better use of Moose, and have a cleaner overall architecture. Signed-off-by: Julian Blake Kongslie <jblake@omgwallhack.org>
Diffstat (limited to 'usr/src/libpiny/lib/Piny/Repo.pm')
-rw-r--r--usr/src/libpiny/lib/Piny/Repo.pm39
1 files changed, 14 insertions, 25 deletions
diff --git a/usr/src/libpiny/lib/Piny/Repo.pm b/usr/src/libpiny/lib/Piny/Repo.pm
index de8501b..31b7a70 100644
--- a/usr/src/libpiny/lib/Piny/Repo.pm
+++ b/usr/src/libpiny/lib/Piny/Repo.pm
@@ -1,12 +1,15 @@
# Copyright © 2010 Julian Blake Kongslie <jblake@omgwallhack.org>
# Licensed under the BSD 3-clause license.
+use strict;
+use warnings;
+
package Piny::Repo;
use Moose;
use Moose::Util::TypeConstraints;
+use MooseX::StrictConstructor;
-use Config::Tiny qw( );
use File::Find qw( find );
use File::Temp qw( );
use IO::Dir qw( );
@@ -165,7 +168,7 @@ has 'apache_config' =>
has 'config' =>
( is => 'ro'
- , isa => 'HashRef[Str]'
+ , isa => 'Piny::Config'
, lazy_build => 1
, init_arg => undef
);
@@ -313,7 +316,7 @@ sub all_repos {
sub create {
my ( $class, $name, $description ) = @_;
- my $user = Piny::Environment->new->user;
+ my $user = Piny::Environment->instance->user;
find_type_constraint( "Reponame" )->assert_valid( $name );
find_type_constraint( "SimpleText" )->assert_valid( $description );
@@ -511,39 +514,31 @@ sub _build_ikiwiki_setup {
sub _build_ikiwiki_destdir {
my ( $s ) = @_;
- return Piny::Config->instance->ikiwiki_destdir . $s->name;
+ return $s->config->piny_ikiwiki_destdir . $s->name;
};
sub _build_ikiwiki_srcdir {
my ( $s ) = @_;
- return Piny::Config->instance->ikiwiki_srcdir . $s->name;
+ return $s->config->piny_ikiwiki_srcdir . $s->name;
};
sub _build_ikiwiki_url {
my ( $s ) = @_;
- if ( defined $s->config->{"http_url"} ) {
- return $s->config->{"http_url"} . $s->name;
- } else {
- return Piny::Config->instance->ikiwiki_url . $s->name;
- };
+ return $s->config->piny_ikiwiki_url . $s->name;
};
sub _build_ikiwiki_cgiurl {
my ( $s ) = @_;
- if ( defined $s->config->{"https_url"} ) {
- return $s->config->{"https_url"} . "repos/" . $s->name . "/ikiwiki.cgi";
- } else {
- return Piny::Config->instance->ikiwiki_secure_url . "repos/" . $s->name . "/ikiwiki.cgi";
- };
+ return $s->config->piny_ikiwiki_secure_url . "repos/" . $s->name . "/ikiwiki.cgi";
};
sub _build_secure_path {
my ( $s ) = @_;
- return Piny::Config->instance->ikiwiki_secure_path . "repos/" . $s->name;
+ return $s->config->piny_ikiwiki_secure_path . "repos/" . $s->name;
};
sub _build_ikiwiki_cgipath {
@@ -558,7 +553,7 @@ sub _build_ikiwiki_historyurl {
if ( defined $s->config->{"https_url"} ) {
return $s->config->{"https_url"} . "cgit/" . $s->name . "/log/[[file]]";
} else {
- return Piny::Config->instance->ikiwiki_secure_url . "cgit/" . $s->name . "/log/[[file]]";
+ return $s->config->piny_ikiwiki_secure_url . "cgit/" . $s->name . "/log/[[file]]";
};
};
@@ -568,7 +563,7 @@ sub _build_ikiwiki_diffurl {
if ( defined $s->config->{"https_url"} ) {
return $s->config->{"https_url"} . "cgit/" . $s->name . "/diff/?id=[[sha1_commit]]";
} else {
- return Piny::Config->instance->ikiwiki_secure_url . "cgit/" . $s->name . "/diff/?id=[[sha1_commit]]";
+ return $s->config->piny_ikiwiki_secure_url . "cgit/" . $s->name . "/diff/?id=[[sha1_commit]]";
};
};
@@ -581,13 +576,7 @@ sub _build_apache_config {
sub _build_config {
my ( $s ) = @_;
- my $c = Config::Tiny->read( $s->path . "/config" );
-
- if ( defined $c and defined $c->{"piny"}) {
- return $c->{"piny"};
- } else {
- return { };
- };
+ return Piny::Config->new( confpath => $s->path . "/config" );
};
# Moose boilerplate