Permalink
Browse files

More spelling consistencey, and a few missing RETURN and other moosisms

  • Loading branch information...
kentfredric committed Sep 10, 2009
1 parent 1dca506 commit b645107659a7b99ad1338beff110ab0eb00bc327
@@ -1,6 +1,6 @@
package Spark::Form::Field::Role::Printable::HTML;
-# ABSTRACT: a html4-printable form field role
+# ABSTRACT: a HTML4-printable form field role
use Moose::Role;
with "Spark::Form::Field::Role::Printable";
@@ -28,7 +28,7 @@ __END__
=head2 to_html :: Undef => Str
-This function should return a html string representing your control
+This function should return a HTML string representing your control
=head1 SEE ALSO
@@ -1,6 +1,6 @@
package Spark::Form::Field::Role::Printable::XHTML;
-# ABSTRACT: a xhtml1-printable form field role
+# ABSTRACT: a XHTML1-printable form field role
use Moose::Role;
with "Spark::Form::Field::Role::Printable";
@@ -28,7 +28,7 @@ __END__
=head2 to_xhtml :: Undef => Str
-This function should return a html string representing your control
+This function should return a XHTML string representing your control
=head1 SEE ALSO
@@ -3,8 +3,9 @@ package Spark::Form::Field::Role::Validateable;
# ABSTRACT: Fields that can be validated
use Moose::Role;
+use Carp ();
-warn "Spark::Form::Field::Role::Validateable is a no-op. Please remove it from your code";
+Carp::cluck('Spark::Form::Field::Role::Validateable is a no-op. Please remove it from your code');
1;
__END__
@@ -9,7 +9,7 @@ has confirm => (
is => 'rw',
required => 0,
lazy => 1,
- default => sub { undef },
+ default => undef,
);
has errmsg_confirm => (
@@ -19,22 +19,22 @@ has errmsg_confirm => (
lazy => 1,
default => sub {
my $self = shift;
- $self->human_name .
- " must match " .
+ return $self->human_name .
+ ' must match ' .
$self->_confirm_human_name
},
);
sub _confirm_field {
my ($self) = @_;
- $self->form->get($self->confirm);
+ return $self->form->get($self->confirm);
}
sub _confirm_human_name {
my ($self) = @_;
- $self->_confirm_field->human_name;
+ return $self->_confirm_field->human_name;
}
sub _confirm {
@@ -45,16 +45,18 @@ sub _confirm {
if ($self->value ne $self->_confirm_field->value) {
$self->error($self->errmsg_confirm);
}
+ return $self;
}
-after '_validate' => sub { shift->_confirm };
+after '_validate' => sub { return shift->_confirm };
+
1;
__END__
=head1 DESCRIPTION
-A confirmation comparison mixin. Adds two fields plus action.
+A confirmation comparison mix-in. Adds two fields plus action.
Makes sure that the selected C<confirm> field matches this one.
=head1 ACCESSORS
@@ -18,10 +18,10 @@ has errmsg_too_long => (
lazy => 1,
default => sub {
my $self = shift;
- $self->human_name .
- " must be no more than " .
+ return $self->human_name .
+ ' must be no more than ' .
$self->max_length .
- " characters long";
+ ' characters long';
},
);
@@ -33,16 +33,17 @@ sub _max_length {
if (length $self->value > $self->max_length) {
$self->error($self->errmsg_too_long);
}
+ return $self;
}
-after '_validate' => sub { shift->_max_length };
+after '_validate' => sub { return shift->_max_length };
1;
__END__
=head1 DESCRIPTION
-A maximum length enforcement mixin. Adds two fields plus action.
+A maximum length enforcement mix-in. Adds two fields plus action.
Makes sure that C<value> is at most C<max_length> characters long.
=head1 ACCESSORS
@@ -18,10 +18,10 @@ has errmsg_too_short => (
lazy => 1,
default => sub {
my $self = shift;
- $self->human_name .
- " must be at least " .
+ return $self->human_name .
+ ' must be at least ' .
$self->min_length .
- " characters long";
+ ' characters long';
},
);
@@ -33,16 +33,17 @@ sub _min_length {
if (length $self->value < $self->min_length) {
$self->error($self->errmsg_too_short);
}
+ return $self;
}
-after '_validate' => sub { shift->_min_length };
+after '_validate' => sub { return shift->_min_length };
1;
__END__
=head1 DESCRIPTION
-A minimum length enforcement mixin. Adds two fields plus action.
+A minimum length enforcement mix-in. Adds two fields plus action.
Makes sure that C<value> is at least C<min_length> characters long.
=head1 ACCESSORS
@@ -10,8 +10,8 @@ has errmsg_empty => (
required => 0,
default => sub {
my $self = shift;
- $self->human_name .
- " must be provided."
+ return $self->human_name .
+ ' must be provided.'
},
);
@@ -21,16 +21,17 @@ sub _not_empty {
unless ($self->value) {
$self->error($self->errmsg_empty);
}
+ return $self;
}
-after '_validate' => sub { shift->_not_empty };
+after '_validate' => sub { return shift->_not_empty };
1;
__END__
=head1 DESCRIPTION
-A not empty enforcement mixin. Adds one field plus action.
+A not empty enforcement mix-in. Adds one field plus action.
Makes sure that C<value> is not empty.
=head1 ACCESSORS
@@ -8,7 +8,7 @@ has regex => (
isa => 'Maybe[RegexpRef]',
is => 'rw',
required => 0,
- default => sub { undef },
+ default => undef,
);
has errmsg_regex => (
@@ -18,7 +18,7 @@ has errmsg_regex => (
lazy => 1,
default => sub {
my $self = shift;
- $self->human_name . " failed the regex."
+ $self->human_name . ' failed the regex.'
},
);
@@ -30,17 +30,18 @@ sub _regex {
if ($self->value !~ $self->regex) {
$self->error($self->errmsg_regex);
}
+ return $self;
}
-after '_validate' => sub { shift->_regex };
+after '_validate' => sub { return shift->_regex };
1;
__END__
=head1 DESCRIPTION
-A regex validation mixin. Adds two fields plus action.
-Makes sure that C<value> matches the regex.
+A regular expression validation mix-in. Adds two fields plus action.
+Makes sure that C<value> matches the expression.
=head1 ACCESSORS
@@ -8,23 +8,26 @@ with 'Spark::Form::Printer';
use HTML::Tiny;
sub to_xhtml {
- shift->_render('to_xhtml', HTML::Tiny->new(mode => 'xml'), @_);
+ my ($self, @args) = @_;
+ return $self->_render('to_xhtml', HTML::Tiny->new(mode => 'xml'), @args);
}
sub to_html {
- shift->_render('to_html', HTML::Tiny->new(mode => 'html'), @_);
+ my ($self, @args) = @_;
+ return $self->_render('to_html', HTML::Tiny->new(mode => 'html'), @args);
}
sub _render {
my ($self, $func, $html, @params) = @_;
- $html->ul(join(' ', $self->_get_lis($func, $html)));
+ return $html->ul(
+ join q{ }, $self->_get_lis($func, $html)
+ );
}
sub _get_lis {
my ($self, $func, $html) = @_;
- map {
- $html->li($html->label($_->human_name)) =>
- $html->li($_->$func)
+ return map {
+ $html->li($html->label($_->human_name)) => $html->li($_->$func)
} $self->fields;
}
@@ -40,11 +43,11 @@ if you don't export anything, such as for a purely object-oriented module.
=head2 to_html
-Prints the form to html
+Prints the form to HTML
=head2 to_xhtml
-Prints the form to xhtml
+Prints the form to XHTML
=head1 ACKNOWLEDGEMENTS
View
@@ -13,7 +13,7 @@ allow_includes = 1
[CodeLayout::ProhibitTrailingWhitespace]
[Documentation::PodSpelling]
-stop_words = CPAN Str TODO rw HashRef ArrayRef HTML XHTML Bool API CGI basename plugins MyApp plugin Laver Django YAML Jifty validators Superclass superclass accessors pre checkbox textarea
+stop_words = CPAN Str TODO rw HashRef ArrayRef HTML XHTML Bool API CGI basename plugins MyApp plugin Laver Django YAML Jifty validators Superclass superclass accessors pre checkbox textarea Printability RegexRef Undef
[NamingConventions::ProhibitAmbiguousNames]
forbid = abstract bases close contract last left no record right second

0 comments on commit b645107

Please sign in to comment.