Skip to content

Commit

Permalink
Add some Moose best practices to the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott McWhirter committed Mar 18, 2010
1 parent cf3c19d commit 4d3f9e7
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 22 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -52,6 +52,7 @@ requires 'IO::String' => 0;
requires 'Net::SSL' => 0;
requires 'Email::Send' => 0;
requires 'Email::Simple' => 0;
requires 'namespace::autoclean' => 0;

tests_recursive();
auto_install;
Expand Down
2 changes: 2 additions & 0 deletions lib/RSP.pm
Expand Up @@ -42,6 +42,8 @@ sub BUILD {
}
}
}

$self->conf->meta->make_immutable;
}

use RSP::Transaction::Mojo;
Expand Down
2 changes: 2 additions & 0 deletions lib/RSP/AMQP.pm
@@ -1,6 +1,7 @@
package RSP::AMQP;

use Moose;
use namespace::autoclean;
use Net::RabbitMQ;

has host => (is => 'rw', isa => 'Str', default => 'localhost');
Expand Down Expand Up @@ -32,4 +33,5 @@ sub DEMOLISH {
$self->_mq->disconnect;
}

__PACKAGE__->meta->make_immutable;
1;
4 changes: 1 addition & 3 deletions lib/RSP/Config.pm
@@ -1,6 +1,7 @@
package RSP::Config;

use Moose;
use namespace::autoclean;
use RSP;
use Cwd qw(getcwd);

Expand Down Expand Up @@ -165,9 +166,6 @@ sub _build_log_dispatcher {
return Log::Dispatch::Config->instance;
}

no Moose;
#__PACKAGE__->meta->make_immutable;

1;

__END__
Expand Down
2 changes: 2 additions & 0 deletions lib/RSP/Config/AMQP.pm
@@ -1,6 +1,7 @@
package RSP::Config::AMQP;

use Moose;
use namespace::autoclean;

has user => (is => 'ro', required => 1, isa => 'Str');
has pass => (is => 'ro', required => 1, isa => 'Str');
Expand All @@ -11,4 +12,5 @@ has repository_management_exchange => (is => 'ro', required => 1, isa => 'Str');
has repository_deletion_exchange => (is => 'ro', required => 1, isa => 'Str');
has repository_key_registration_exchange => (is => 'ro', required => 1, isa => 'Str');

__PACKAGE__->meta->make_immutable;
1;
5 changes: 1 addition & 4 deletions lib/RSP/Config/Host.pm
Expand Up @@ -3,6 +3,7 @@ package RSP::Config::Host;
use feature qw(switch);

use Moose;
use namespace::autoclean;
use File::Spec;
use File::Path qw(make_path);
use Try::Tiny;
Expand Down Expand Up @@ -160,10 +161,6 @@ sub file {
return $path;
}


no Moose;
#__PACKAGE__->meta->make_immutable;

1;

__END__
Expand Down
2 changes: 2 additions & 0 deletions lib/RSP/Config/LocalStorage.pm
@@ -1,7 +1,9 @@
package RSP::Config::LocalStorage;

use Moose;
use namespace::autoclean;

has datadir => (is => 'ro', isa => 'Str', required => 1);

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Config/MogileFS.pm
@@ -1,6 +1,7 @@
package RSP::Config::MogileFS;

use Moose;
use namespace::autoclean;

has _trackers_string => (is => 'ro', isa => 'Str', required => 1, init_arg => 'trackers');
has trackers => (is => 'ro', isa => 'ArrayRef', lazy_build => 1);
Expand All @@ -9,4 +10,5 @@ sub _build_tackers {
return [ split(',', $self->_trackers_string) ];
}

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Config/MySQL.pm
@@ -1,10 +1,12 @@
package RSP::Config::MySQL;

use Moose;
use namespace::autoclean;

has user => (is => 'ro', required => 1, isa => 'Str');
has password => (is => 'ro', required => 1, isa => 'Str');
has host => (is => 'ro', isa => 'Str');
has port => (is => 'ro', isa => 'Int');

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Config/StorageGroup.pm
@@ -1,8 +1,10 @@
package RSP::Config::StorageGroup;

use Moose;
use namespace::autoclean;

has DataStore => (is => 'ro', isa => 'Str');
has MediaStore => (is => 'ro', isa => 'Str');

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Datastore/Base.pm
@@ -1,7 +1,7 @@
package RSP::Datastore::Base;

use Moose;

use namespace::autoclean;
use Digest::MD5 qw(md5_hex);
use SQL::Abstract;
use Scalar::Util::Numeric qw( isnum isint isfloat );
Expand Down Expand Up @@ -489,4 +489,5 @@ sub query_one_set {
return $set;
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Datastore/MySQL.pm
@@ -1,7 +1,7 @@
package RSP::Datastore::MySQL;

use Moose;

use namespace::autoclean;
use RSP::Transaction;

use DBI;
Expand Down Expand Up @@ -129,4 +129,5 @@ sub remove_namespace {
$self->conn->do("DROP DATABASE " . $self->namespace_sum);
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Datastore/SQLite.pm
@@ -1,7 +1,7 @@
package RSP::Datastore::SQLite;

use Moose;

use namespace::autoclean;
use DBI;
use File::Path;

Expand Down Expand Up @@ -89,4 +89,5 @@ sub remove_namespace {
unlink( $self->dbfile );
}

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Extension/Console.pm
@@ -1,6 +1,7 @@
package RSP::Extension::Console;

use Moose;
use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

sub bind {
Expand All @@ -15,4 +16,5 @@ sub console_log {
print STDERR $msg;
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 3 additions & 0 deletions lib/RSP/Extension/DataStore.pm
@@ -1,6 +1,7 @@
package RSP::Extension::DataStore;

use Moose;
use namespace::autoclean;
with qw(RSP::Role::AppMutation RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use RSP::Datastore::MySQL;
Expand Down Expand Up @@ -95,4 +96,6 @@ sub clear {
return $self->namespace->clear( lc($type), @args );
}


__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/Digest.pm
@@ -1,7 +1,7 @@
package RSP::Extension::Digest;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use Scalar::Util qw( blessed );
Expand Down Expand Up @@ -49,4 +49,5 @@ sub digest_md5_base64 {
return md5_base64( _js_data($data) );
}

__PACKAGE__->meta->make_immutable;
1;
5 changes: 2 additions & 3 deletions lib/RSP/Extension/FileSystem.pm
@@ -1,7 +1,7 @@
package RSP::Extension::FileSystem;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use RSP::JSObject::File;
Expand Down Expand Up @@ -61,6 +61,5 @@ sub get_file {
}
}



__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/Gitosis.pm
@@ -1,7 +1,7 @@
package RSP::Extension::Gitosis;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::AppMutation RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

sub can_apply_mutations {
Expand Down Expand Up @@ -117,4 +117,5 @@ sub _new_amqp_instance {
return $amqp;
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/HMAC.pm
@@ -1,7 +1,7 @@
package RSP::Extension::HMAC;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use Digest::HMAC_SHA1 qw( hmac_sha1 hmac_sha1_hex );
Expand Down Expand Up @@ -40,4 +40,5 @@ sub _js_data {
return blessed($data) ? $data->as_string : $data;
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/HTTP.pm
@@ -1,7 +1,7 @@
package RSP::Extension::HTTP;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use Encode;
Expand Down Expand Up @@ -67,4 +67,5 @@ sub response_to_object {
return $ro;
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/Image.pm
@@ -1,7 +1,7 @@
package RSP::Extension::Image;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use RSP::JSObject::Image;
Expand Down Expand Up @@ -51,4 +51,5 @@ sub DEMOLISH {
$self->js_instance->unbind_value( $self->jsclass );
}

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Extension/Import.pm
@@ -1,6 +1,7 @@
package RSP::Extension::Import;

use Moose;
use namespace::autoclean;
use Try::Tiny;
use File::Spec;

Expand Down Expand Up @@ -52,4 +53,5 @@ sub use {
}
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/JSONEncoder.pm
@@ -1,7 +1,7 @@
package RSP::Extension::JSONEncoder;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use Try::Tiny;
Expand Down Expand Up @@ -43,4 +43,5 @@ sub json_decode {
};
}

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Extension/MediaStore.pm
@@ -1,6 +1,7 @@
package RSP::Extension::MediaStore;

use Moose;
use namespace::autoclean;
with qw(RSP::Role::AppMutation RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

sub can_apply_mutations { 1 }
Expand Down Expand Up @@ -102,4 +103,5 @@ sub get {
$self->namespace->get(@args);
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/SendMail.pm
@@ -1,7 +1,7 @@
package RSP::Extension::SendMail;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use Email::Send;
Expand Down Expand Up @@ -44,4 +44,5 @@ sub email_send {
return 1;
}

__PACKAGE__->meta->make_immutable;
1;
3 changes: 2 additions & 1 deletion lib/RSP/Extension/Sprintf.pm
@@ -1,7 +1,7 @@
package RSP::Extension::Sprintf;

use Moose;

use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

sub bind {
Expand All @@ -17,4 +17,5 @@ sub sprintf {
return sprintf($format, @args);
}

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/Extension/UUID.pm
@@ -1,6 +1,7 @@
package RSP::Extension::UUID;

use Moose;
use namespace::autoclean;
with qw(RSP::Role::Extension RSP::Role::Extension::JSInstanceManipulation);

use Data::UUID::Base64URLSafe;
Expand All @@ -18,4 +19,5 @@ sub uuid {
return $ug->create_b64_urlsafe;
}

__PACKAGE__->meta->make_immutable;
1;
2 changes: 2 additions & 0 deletions lib/RSP/JS/Engine/SpiderMonkey.pm
@@ -1,6 +1,7 @@
package RSP::JS::Engine::SpiderMonkey;

use Moose;
use namespace::autoclean;
use Moose::Util;

use RSP::JS::Engine::SpiderMonkey::Instance;
Expand All @@ -22,4 +23,5 @@ sub applicable_host_config_roles {
qw(RSP::Role::Config::SpiderMonkey::Host);
}

__PACKAGE__->meta->make_immutable;
1;

0 comments on commit 4d3f9e7

Please sign in to comment.