[Bps-public-commit] Prophet branch, master, updated. 0.743-12-g29c15f9
Jesse Vincent
jesse at bestpractical.com
Tue Jul 6 03:18:52 EDT 2010
The branch, master has been updated
via 29c15f9c6a7e0c6cd76a48a482edd3e85af5b6d5 (commit)
via 66f7d1dc2d3051b37e3627c1c09f5832dfd71543 (commit)
via 2848d2536866d7951c11055aee2a23b5be479ed2 (commit)
from fac48c3e74caec92f3f30d229e3ebb38a5e80493 (commit)
Summary of changes:
lib/Prophet/CLI/Command/Show.pm | 16 +++++++++-------
lib/Prophet/ChangeSet.pm | 5 +++++
2 files changed, 14 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit 2848d2536866d7951c11055aee2a23b5be479ed2
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Sun Jul 4 17:58:55 2010 +0100
Allow custom change formatters when printing changsets
diff --git a/lib/Prophet/ChangeSet.pm b/lib/Prophet/ChangeSet.pm
index 1c29440..9485cd7 100644
--- a/lib/Prophet/ChangeSet.pm
+++ b/lib/Prophet/ChangeSet.pm
@@ -217,6 +217,7 @@ sub as_string {
@_,
{ change_filter => 0,
change_header => 0,
+ change_formatter => undef,
header_callback => 0,
skip_empty => 0
}
@@ -226,8 +227,12 @@ sub as_string {
for my $change ( $self->changes ) {
next if $args{change_filter} && !$args{change_filter}->($change);
+ if ($args{change_formatter} ) {
+ $body .= $args{change_formatter}->(change => $change, header_callback => $args{change_header});
+ } else {
$body .= $change->as_string( header_callback => $args{change_header} ) || next;
$body .= "\n";
+ }
}
return '' if !$body && $args{'skip_empty'};
commit 66f7d1dc2d3051b37e3627c1c09f5832dfd71543
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Sun Jul 4 19:19:33 2010 +0100
extract out prop formatting in "show" - kill the "max length" stuff in
favor of subclasses using sprintf
diff --git a/lib/Prophet/CLI/Command/Show.pm b/lib/Prophet/CLI/Command/Show.pm
index d471f5f..0b26705 100644
--- a/lib/Prophet/CLI/Command/Show.pm
+++ b/lib/Prophet/CLI/Command/Show.pm
@@ -67,7 +67,6 @@ sub stringify_props {
# kind of ugly but it simplifies the code
$props->{id} = $record->luid ." (" . $record->uuid . ")";
- my $max_length = 0;
my @fields;
for my $field (@show_props) {
@@ -78,21 +77,25 @@ sub stringify_props {
push @fields, [$field, $value];
- $max_length = length($field) if length($field) > $max_length;
}
- $max_length = 0 if $args{batch};
return join '',
map {
my ($field, $value) = @$_;
- $field .= ':';
- $field .= ' ' x ($max_length - length($field));
- "$field $value\n"
+ $self->format_prop($field,$value);
}
@fields;
}
+sub format_prop {
+ my $self = shift;
+ my $field = shift;
+ my $value = shift;
+ "$field: $value\n"
+
+}
+
__PACKAGE__->meta->make_immutable;
no Any::Moose;
commit 29c15f9c6a7e0c6cd76a48a482edd3e85af5b6d5
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Jul 6 09:18:11 2010 +0200
small fixes to prop formatting
diff --git a/lib/Prophet/CLI/Command/Show.pm b/lib/Prophet/CLI/Command/Show.pm
index 0b26705..99d839e 100644
--- a/lib/Prophet/CLI/Command/Show.pm
+++ b/lib/Prophet/CLI/Command/Show.pm
@@ -27,7 +27,7 @@ sub run {
record => $record,
batch => $self->has_arg('batch'),
verbose => $self->has_arg('verbose'),
- );
+ );
}
=head2 stringify_props
@@ -83,7 +83,7 @@ sub stringify_props {
return join '',
map {
my ($field, $value) = @$_;
- $self->format_prop($field,$value);
+ $self->format_prop(@$_);
}
@fields;
}
@@ -92,8 +92,7 @@ sub format_prop {
my $self = shift;
my $field = shift;
my $value = shift;
- "$field: $value\n"
-
+ return "$field: $value\n"
}
__PACKAGE__->meta->make_immutable;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list