Skip to content

Commit

Permalink
Rewrite to use of Mo::utils and Mo::utils::CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-josef-spacek committed Jun 9, 2024
1 parent 85c34d8 commit cedeb96
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 13 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.03
- Rewrite to use of Mo::utils and Mo::utils::CSS.

0.02 2024-05-11T00:43:23+02:00
- Add DESCRIPTION section to doc.
Expand Down
16 changes: 13 additions & 3 deletions Grid.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use warnings;

use Class::Utils qw(set_params split_params);
use Error::Pure qw(err);
use Mo::utils 0.01 qw(check_required);
use Mo::utils::CSS 0.02 qw(check_css_class);
use Scalar::Util qw(blessed);

our $VERSION = 0.03;
Expand All @@ -25,9 +27,8 @@ sub new {
# Process params.
set_params($self, @{$object_params_ar});

if (! defined $self->{'css_class'}) {
err "Parameter 'css_class' is required.";
}
check_required($self, 'css_class');
check_css_class($self, 'css_class');

# Object.
return $self;
Expand Down Expand Up @@ -272,6 +273,13 @@ Returns undef.
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
From Mo::utils::check_required():
Parameter 'css_class' is required.
From Mo::utils::CSS::check_css_class():
Parameter 'css_class' has bad CSS class name.
Value: %s
Parameter 'css_class' has bad CSS class name (number on begin).
Value: %s
From Tags::HTML::new():
Parameter 'css' must be a 'CSS::Struct::Output::*' class.
Parameter 'tags' must be a 'Tags::Output::*' class.
Expand Down Expand Up @@ -503,6 +511,8 @@ Returns undef.
L<Class::Utils>,
L<Error::Pure>,
L<Mo::utils>,
L<Mo::utils::CSS>,
L<Scalar::Util>,
L<Tags::HTML>.
Expand Down
2 changes: 2 additions & 0 deletions META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ no_index:
requires:
Class::Utils: 0
Error::Pure: 0
Mo::utils: 0.01
Mo::utils::CSS: 0.02
Scalar::Util: 0
Tags::HTML: 0.08
perl: 5.8.0
Expand Down
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ readme_from 'Grid.pm';
recursive_author_tests('xt');
requires 'Class::Utils' => 0;
requires 'Error::Pure' => 0;
requires 'Mo::utils' => 0.01;
requires 'Mo::utils::CSS' => 0.02;
requires 'Tags::HTML' => 0.08;
requires 'Scalar::Util' => 0;
requires 'perl' => '5.8.0';
Expand Down
10 changes: 9 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
From Mo::utils::check_required():
Parameter 'css_class' is required.
From Mo::utils::CSS::check_css_class():
Parameter 'css_class' has bad CSS class name.
Value: %s
Parameter 'css_class' has bad CSS class name (number on begin).
Value: %s
From Tags::HTML::new():
Parameter 'css' must be a 'CSS::Struct::Output::*' class.
Parameter 'tags' must be a 'Tags::Output::*' class.
Expand Down Expand Up @@ -299,7 +306,8 @@ EXAMPLE2
# Output screenshot is in images/ directory.

DEPENDENCIES
Class::Utils, Error::Pure, Scalar::Util, Tags::HTML.
Class::Utils, Error::Pure, Mo::utils, Mo::utils::CSS, Scalar::Util,
Tags::HTML.

SEE ALSO
Tags::HTML::Login::Access
Expand Down
44 changes: 35 additions & 9 deletions t/Tags-HTML-Navigation-Grid/03-new.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Error::Pure::Utils qw(clean);
use Tags::HTML::Navigation::Grid;
use Tags::Output::Structure;
use Test::MockObject;
use Test::More 'tests' => 8;
use Test::More 'tests' => 10;
use Test::NoWarnings;

# Test.
Expand Down Expand Up @@ -50,38 +50,64 @@ clean();
# Test.
eval {
Tags::HTML::Navigation::Grid->new(
'tags' => 'foo',
'css_class' => undef,
);
};
is(
$EVAL_ERROR,
"Parameter 'tags' must be a 'Tags::Output::*' class.\n",
"Parameter 'tags' must be a 'Tags::Output::*' class (foo).",
"Parameter 'css_class' is required.\n",
"Parameter 'css_class' is required.",
);
clean();

# Test.
eval {
Tags::HTML::Navigation::Grid->new(
'tags' => Test::MockObject->new,
'css_class' => '1foo',
);
};
is(
$EVAL_ERROR,
"Parameter 'css_class' has bad CSS class name (number on begin).\n",
"Parameter 'css_class' has bad CSS class name (number on begin) (1foo).",
);
clean();

# Test.
eval {
Tags::HTML::Navigation::Grid->new(
'css_class' => '@foo',
);
};
is(
$EVAL_ERROR,
"Parameter 'css_class' has bad CSS class name.\n",
"Parameter 'css_class' has bad CSS class name (\@foo).",
);
clean();

# Test.
eval {
Tags::HTML::Navigation::Grid->new(
'tags' => 'foo',
);
};
is(
$EVAL_ERROR,
"Parameter 'tags' must be a 'Tags::Output::*' class.\n",
"Parameter 'tags' must be a 'Tags::Output::*' class (bad instance).",
"Parameter 'tags' must be a 'Tags::Output::*' class (foo).",
);
clean();

# Test.
eval {
Tags::HTML::Navigation::Grid->new(
'css_class' => undef,
'tags' => Test::MockObject->new,
);
};
is(
$EVAL_ERROR,
"Parameter 'css_class' is required.\n",
"Parameter 'css_class' is required.",
"Parameter 'tags' must be a 'Tags::Output::*' class.\n",
"Parameter 'tags' must be a 'Tags::Output::*' class (bad instance).",
);
clean();

0 comments on commit cedeb96

Please sign in to comment.