[Bps-public-commit] Prophet branch, master, updated. 4078e13ebdbedca8fad3321f31346d7482d1de4a

jesse jesse at bestpractical.com
Mon Aug 10 18:06:47 EDT 2009


The branch, master has been updated
       via  4078e13ebdbedca8fad3321f31346d7482d1de4a (commit)
       via  7281d585eb2491af05525d800e5b8743ca27a876 (commit)
      from  04b1091155b1c26e438519cd2d8b9ecc92fa35f4 (commit)

Summary of changes:
 Makefile.PL                     |    3 +-
 lib/Prophet/App.pm              |    2 +-
 lib/Prophet/CLI/Command/Push.pm |    4 +-
 lib/Prophet/ForeignReplica.pm   |    1 -
 lib/Prophet/UUIDGenerator.pm    |   46 +++++++++++++++++++-------------------
 5 files changed, 27 insertions(+), 29 deletions(-)

- Log -----------------------------------------------------------------
commit 7281d585eb2491af05525d800e5b8743ca27a876
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Aug 10 19:03:34 2009 +0100

    Data::UUID is out. UUID::Simple is in. Also, groundwork for switching to v4/v5 instead of v1/v3

diff --git a/Makefile.PL b/Makefile.PL
index 6992289..e51671a 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -7,8 +7,7 @@ license('Perl');
 requires('Exporter::Lite');
 requires('Params::Validate');
 requires('IPC::Run3');
-requires('Data::UUID');
-requires('Data::UUID::Base64URLSafe');
+requires('UUID::Tiny');
 requires('Digest::SHA');
 requires('LWP::UserAgent');     #  LWP::ConnCache too
 requires('URI');
diff --git a/lib/Prophet/App.pm b/lib/Prophet/App.pm
index 7247911..b572361 100644
--- a/lib/Prophet/App.pm
+++ b/lib/Prophet/App.pm
@@ -40,7 +40,7 @@ has config => (
 has uuid_generator => (
     is => 'rw',
     isa => 'Prophet::UUIDGenerator',
-    default => sub { Prophet::UUIDGenerator->new}
+    default => sub { Prophet::UUIDGenerator->new( uuid_scheme => 1) }
 );
 
 
diff --git a/lib/Prophet/ForeignReplica.pm b/lib/Prophet/ForeignReplica.pm
index ee2287d..6276b1b 100644
--- a/lib/Prophet/ForeignReplica.pm
+++ b/lib/Prophet/ForeignReplica.pm
@@ -1,7 +1,6 @@
 package Prophet::ForeignReplica;
 use Any::Moose;
 use Params::Validate qw(:all);
-use Data::UUID 'NameSpace_DNS';
 extends 'Prophet::Replica';
 
 =head1 NAME
diff --git a/lib/Prophet/UUIDGenerator.pm b/lib/Prophet/UUIDGenerator.pm
index 21b9394..4c03d63 100644
--- a/lib/Prophet/UUIDGenerator.pm
+++ b/lib/Prophet/UUIDGenerator.pm
@@ -1,50 +1,50 @@
 package Prophet::UUIDGenerator;
-use Data::UUID qw'NameSpace_DNS';
 use Any::Moose;
 use MIME::Base64::URLSafe;
 
-our $UUIDGEN;
+use UUID::Tiny;
 
-sub _uuid_generator {
+# uuid_scheme: 1 - v1 and v3 uuids.
+#			   2 - v4 and v5 uuids.
+
+has uuid_scheme => (
+	isa => 'Int',
+	is  => 'rw'
+);
 
-        return $UUIDGEN ||= Data::UUID->new();
-}
 
 sub create_str {
     my $self = shift;
-    return $self->_uuid_generator->create_str();
+	if ($self->uuid_scheme == 1 ){
+		return create_UUID_as_string(UUID_V1);
+	} elsif ($self->uuid_scheme == 2) {
+		return create_UUID_as_string(UUID_V4);
+	}
 }
 
 sub create_string_from_url {
     my $self = shift;
     my $url = shift;
     local $!;
-    $self->_uuid_generator->create_from_name_str(NameSpace_DNS, $url )
+	if ($self->uuid_scheme == 1 ){
+		# Yes, DNS, not URL. We screwed up when we first defined it
+		# and it can't be safely changed once defined.
+		create_UUID_as_string(UUID_V3, UUID_NS_DNS, $url);
+	} elsif ($self->uuid_scheme == 2) {
+		create_UUID_as_string(UUID_V5, UUID_NS_URL, $url);
+	}
 }
 
 sub from_string {
     my $self = shift;
     my $str = shift;
-    $self->_uuid_generator->from_string($str);
+    return string_to_UUID($str);
 }
  
 sub to_string {
     my $self = shift;
     my $uuid = shift;
-    $self->_uuid_generator->to_string($uuid);
-}
-
-sub create_safe_b64 {
-    my $self = shift;
-   $self->to_safe_b64($self->_uuid_generator->create); 
-}
-
-    sub create_safe_b64_from_url {
-    my $self = shift;
-    my $url = shift;
-    local $!;
-    $self->to_safe_b64($self->_uuid_generator->create_from_name(NameSpace_DNS, $url ));
-
+    return UUID_to_string($uuid);
 }
 
 sub from_safe_b64 {
@@ -56,7 +56,7 @@ sub from_safe_b64 {
 sub to_safe_b64 {
     my $self = shift;
     my $uuid = shift;
-    return urlsafe_b64encode($uuid);
+    return urlsafe_b64encode($self->from_string($uuid));
 }
 
 

commit 4078e13ebdbedca8fad3321f31346d7482d1de4a
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Mon Aug 10 23:06:03 2009 +0100

    cleaned up the push command's --force logic

diff --git a/lib/Prophet/CLI/Command/Push.pm b/lib/Prophet/CLI/Command/Push.pm
index c224377..775ccd3 100644
--- a/lib/Prophet/CLI/Command/Push.pm
+++ b/lib/Prophet/CLI/Command/Push.pm
@@ -49,9 +49,9 @@ sub run {
     die "Can't push to foreign replica that's never been pulled from! (Override with --force.)\n"
         unless
             $class->isa('Prophet::ForeignReplica') &&
-            ! $self->has_arg('force') &&
+            ( $self->has_arg('force')  ||
             ( exists $seen_replicas_by_url{$self->arg('to')} ||
-              exists $seen_replicas_by_pull_url{$self->arg('to')} );
+              exists $seen_replicas_by_pull_url{$self->arg('to')} ));
 
     # prepare to run merge command (superclass)
     $self->set_arg( from =>  $self->handle->url );

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



More information about the Bps-public-commit mailing list