[Bps-public-commit] Prophet branch, master, updated. 80b9f5037a47b27a70305e7a44197ad4ec3b280b

jesse jesse at bestpractical.com
Thu Jun 11 10:21:08 EDT 2009


The branch, master has been updated
       via  80b9f5037a47b27a70305e7a44197ad4ec3b280b (commit)
       via  32fa5b0b97805e1d86a483ec229bc83d7787ab6a (commit)
       via  d5f1fad60054d13a10f822bf9adc04dc8109359d (commit)
       via  8001060b295f6da0f32e33fbbc3662ecaf08251b (commit)
      from  5a3cb57fea40543549e12b4b59f287dfd6285964 (commit)

Summary of changes:
 lib/Prophet/CLI/Command/Show.pm |   29 +++++---------------------
 lib/Prophet/CLI/Dispatcher.pm   |    2 +-
 lib/Prophet/CLIContext.pm       |    2 +-
 lib/Prophet/Record.pm           |   41 ---------------------------------------
 lib/Prophet/Replica/prophet.pm  |    2 +-
 lib/Prophet/UUIDGenerator.pm    |   26 ++++++++++++++++++++++-
 6 files changed, 33 insertions(+), 69 deletions(-)

- Log -----------------------------------------------------------------
commit 8001060b295f6da0f32e33fbbc3662ecaf08251b
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 00:29:04 2009 -0400

    Added URLSafe Base64 uuid generation

diff --git a/lib/Prophet/UUIDGenerator.pm b/lib/Prophet/UUIDGenerator.pm
index e3894c4..21b9394 100644
--- a/lib/Prophet/UUIDGenerator.pm
+++ b/lib/Prophet/UUIDGenerator.pm
@@ -1,6 +1,7 @@
 package Prophet::UUIDGenerator;
 use Data::UUID qw'NameSpace_DNS';
 use Any::Moose;
+use MIME::Base64::URLSafe;
 
 our $UUIDGEN;
 
@@ -33,9 +34,30 @@ sub to_string {
     $self->_uuid_generator->to_string($uuid);
 }
 
-sub from_safe_b64 {}
+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 ));
+
+}
 
-sub to_safe_b64 {}
+sub from_safe_b64 {
+    my $self = shift;
+    my $uuid = shift;
+    return urlsafe_b64decode($uuid);
+}
+
+sub to_safe_b64 {
+    my $self = shift;
+    my $uuid = shift;
+    return urlsafe_b64encode($uuid);
+}
 
 
 =head1 NAME

commit d5f1fad60054d13a10f822bf9adc04dc8109359d
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 00:32:07 2009 -0400

    doc fix

diff --git a/lib/Prophet/Replica/prophet.pm b/lib/Prophet/Replica/prophet.pm
index 72b8107..dc7041c 100644
--- a/lib/Prophet/Replica/prophet.pm
+++ b/lib/Prophet/Replica/prophet.pm
@@ -358,7 +358,7 @@ sub _increment_sequence_no {
 
 =head2 uuid
 
-Return the replica SVN repository's UUID
+Return the replica's UUID
 
 =cut
 

commit 32fa5b0b97805e1d86a483ec229bc83d7787ab6a
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 00:33:11 2009 -0400

    Recognize Base64 record UUIDs

diff --git a/lib/Prophet/CLI/Dispatcher.pm b/lib/Prophet/CLI/Dispatcher.pm
index d779008..8c81586 100644
--- a/lib/Prophet/CLI/Dispatcher.pm
+++ b/lib/Prophet/CLI/Dispatcher.pm
@@ -8,7 +8,7 @@ our @PREFIXES = qw(Prophet::CLI::Command);
 sub add_command_prefix { unshift @PREFIXES, @_ }
 
 # "ticket display $ID" -> "ticket display --id=$ID"
-on qr{^ (.*) \s+ ( \d+ | [A-Z0-9]{36} ) $ }x => sub {
+on qr{^ (.*) \s+ ( \d+ | [0-9a-zA-Z\-\_]{22} | [A-Z0-9]{36} ) $ }x => sub {
     my $self = shift;
     $self->context->set_arg(id => $2);
     run($1, $self, @_);
diff --git a/lib/Prophet/CLIContext.pm b/lib/Prophet/CLIContext.pm
index e0768fe..0b4d8d9 100644
--- a/lib/Prophet/CLIContext.pm
+++ b/lib/Prophet/CLIContext.pm
@@ -143,7 +143,7 @@ The regex to use for matching the id argument (luid / uuid).
 
 =cut
 
-our $ID_REGEX = '^(?:\d+|[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12})$';
+our $ID_REGEX = '^(?:\d+|[A-Za-z0-9\-\_]{22}|[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12})$';
 
 =head2 setup_from_args
 

commit 80b9f5037a47b27a70305e7a44197ad4ec3b280b
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Thu Jun 11 10:20:39 2009 -0400

    remove outdated early implementation attempt at 'colored output'

diff --git a/lib/Prophet/CLI/Command/Show.pm b/lib/Prophet/CLI/Command/Show.pm
index 18bc6db..9cef523 100644
--- a/lib/Prophet/CLI/Command/Show.pm
+++ b/lib/Prophet/CLI/Command/Show.pm
@@ -24,12 +24,6 @@ sub run {
 Returns a stringified form of the properties suitable for displaying directly
 to the user. Also includes luid and uuid.
 
-You may define a "color_prop" method which transforms a property name and value
-(by adding color).
-
-You may also define a "color_prop_foo" method which transforms values of
-property "foo" (by adding color).
-
 =cut
 
 sub stringify_props {
@@ -41,7 +35,6 @@ sub stringify_props {
     my $record = $args{'record'};
     my $props = $record->get_props;
 
-    my $colorize = $args{'batch'} ? 0 : 1;
 
     # which props are we going to display?
     my @show_props;
@@ -72,29 +65,19 @@ sub stringify_props {
         # don't bother displaying unset fields
         next if !defined($value);
 
-        # color if we can (and should)
-        my ($colorized_field, $colorized_value);
-        if ($colorize) {
-            ($colorized_field,$colorized_value) = $record->colorize($field => $value);
-
-    }
-        push @fields, [$field, ($colorized_field|| $field), ($colorized_value ||$value)];
+        push @fields, [$field, $value];
 
-        # don't check length($field) here, since coloring will increase the
-        # length but we only care about display length
-        $max_length = length($field)
-            if length($field) > $max_length;
+        $max_length = length($field) if length($field) > $max_length;
     }
 
     $max_length = 0 if $args{batch};
 
-    # this code is kind of ugly. we need to format based on uncolored length
     return join '',
            map {
-               my ($field, $colorized_field, $colorized_value) = @$_;
-               $colorized_field .= ':';
-               $colorized_field .= ' ' x ($max_length - length($field));
-               "$colorized_field $colorized_value\n"
+               my ($field, $value) = @$_;
+               $field .= ':';
+               $field .= ' ' x ($max_length - length($field));
+               "$field $value\n"
            }
            @fields;
 }
diff --git a/lib/Prophet/Record.pm b/lib/Prophet/Record.pm
index 0958f0d..9ef1d6e 100644
--- a/lib/Prophet/Record.pm
+++ b/lib/Prophet/Record.pm
@@ -826,47 +826,6 @@ sub find_or_create_luid {
     return $luid;
 }
 
-=head2 colorize $field, $value
-
-Colorizes the given property / value pair according to the field's
-own C<color_prop_$field> routine, or else the generic L<color_prop> routine
-if a specific routine does not exist.
-
-=cut
-
-sub colorize {
-        my $self = shift;
-        my ($field, $value) = @_;
-        my $colorized_field;
-        my $colorized_value;
-
-            if (my $method = $self->can("color_prop_$field")) {
-                $colorized_value = $self->$method($value);
-            }
-            else {
-                ($colorized_field, $colorized_value) = $self->color_prop($field, $value);
-            }
-            return ($colorized_field, $colorized_value)
-        }
-
-
-=head2 color_prop property, value
-
-Colorize the given property and/or value. Return the (property, value) pair.
-
-You should not alter the length of the property/value display. This will mess
-up the table display. You should only use coloring escape codes.
-
-=cut
-
-sub color_prop {
-    my $self     = shift;
-    my $property = shift;
-    my $value    = shift;
-
-    return ($property, $value);
-}
-
 =head2 history_as_string
 
 Returns this record's changesets as a single string.

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



More information about the Bps-public-commit mailing list