-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This hook will allow us to attach listeners that can do things to the built pages. Refs #78
- Loading branch information
Showing
5 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package Statocles::Event; | ||
# ABSTRACT: Events objects for Statocles | ||
|
||
=head1 EVENTS | ||
=head2 Statocles::Event::Pages | ||
An event with L<page objects|Statocles::Page>. | ||
=cut | ||
|
||
package Statocles::Event::Pages; | ||
use Statocles::Base 'Class'; | ||
extends 'Beam::Event'; | ||
|
||
=attr pages | ||
An array of L<Statocles::Page> objects | ||
=cut | ||
|
||
has pages => ( | ||
is => 'ro', | ||
isa => ArrayRef[ConsumerOf['Statocles::Page']], | ||
required => 1, | ||
); | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
use Statocles::Base 'Test'; | ||
my $SHARE_DIR = path( __DIR__, '..', 'share' ); | ||
|
||
subtest 'build events' => sub { | ||
my ( $site, $build_dir, $deploy_dir ) = build_test_site_apps( $SHARE_DIR ); | ||
my ( $event ); | ||
$site->on( 'build', sub { | ||
pass "Build event fired during build"; | ||
( $event ) = @_; | ||
} ); | ||
|
||
$site->build; | ||
|
||
isa_ok $event, 'Statocles::Event::Pages'; | ||
ok scalar @{ $event->pages }, 'got some pages'; | ||
cmp_deeply $event->pages, | ||
array_each( | ||
methods( path => re( qr{^/} ) ) | ||
), | ||
'all pages are absolute'; | ||
|
||
cmp_deeply $event->pages, | ||
superbagof( | ||
methods( path => re( qr{^\Q/theme/site/layout.html.ep} ) ), | ||
methods( path => re( qr{^\Q/robots.txt} ) ), | ||
methods( path => re( qr{^\Q/sitemap.xml} ) ), | ||
), | ||
'page paths are correct'; | ||
|
||
}; | ||
|
||
done_testing; |