[Bps-public-commit] net-lighthouse branch, master, updated. 84e809f4ee9627101a33c7e1249553ff05550df8

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Sep 7 03:55:11 EDT 2009


The branch, master has been updated
       via  84e809f4ee9627101a33c7e1249553ff05550df8 (commit)
      from  8e1ea6bd07b9fcda15facfcc35e8f1e5128cc2c8 (commit)

Summary of changes:
 lib/Net/{Lighthouse.pm => Lighthouse/Base.pm} |   35 +++++--------------------
 1 files changed, 7 insertions(+), 28 deletions(-)
 copy lib/Net/{Lighthouse.pm => Lighthouse/Base.pm} (75%)

- Log -----------------------------------------------------------------
commit 84e809f4ee9627101a33c7e1249553ff05550df8
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Sep 7 15:55:06 2009 +0800

    move base part to Net/Lighthouse/Base.pm

diff --git a/lib/Net/Lighthouse/Base.pm b/lib/Net/Lighthouse/Base.pm
new file mode 100644
index 0000000..6d877fd
--- /dev/null
+++ b/lib/Net/Lighthouse/Base.pm
@@ -0,0 +1,74 @@
+package Net::Lighthouse::Base;
+
+use Any::Moose;
+use MIME::Base64;
+use LWP::UserAgent;
+
+has 'account' => (
+    isa => 'Str',
+    is  => 'ro',
+);
+
+has [ 'email', 'password', 'token' ] => (
+    isa => 'Str',
+    is  => 'rw',
+);
+
+no Any::Moose;
+__PACKAGE__->meta->make_immutable;
+
+sub base_url {
+    my $self = shift;
+    return 'http://' . $self->account . '.lighthouseapp.com';
+}
+
+sub ua {
+    my $self = shift;
+    require Net::Lighthouse;
+    my $ua =
+      LWP::UserAgent->new(
+        agent => 'net-lighthouse/' . $Net::Lighthouse::VERSION );
+    $ua->default_header( 'Content-Type' => 'application/xml' );
+    # email and password have high priority
+    if ( $self->email && $self->password ) {
+        my $base64 = encode_base64( $self->email . ':' . $self->password );
+        chomp $base64;
+        $ua->default_header( Authorization => 'Basic ' . $base64 );
+    }
+    elsif ( $self->token ) {
+        $ua->default_header( 'X-LighthouseToken', $self->token );
+    }
+
+    return $ua;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Net::Lighthouse::Base - Base class
+
+=head1 SYNOPSIS
+
+    use Net::Lighthouse::Base;
+
+=head1 DESCRIPTION
+
+
+=head1 INTERFACE
+
+
+=head1 AUTHOR
+
+sunnavy  C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2009 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list