diff --git a/Changes b/Changes index e6cbea6..9ee8778 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for {{$dist->name}} {{$NEXT}} - Don't write file if __DATA__ hasn't changed (gh#2) - Add ->unchanged method (gh#2) + - Add integration tests and documentation re: Data::Section::Pluggable (gh#3) 0.01 2024-12-03 17:15:21 -0700 - initial version diff --git a/README.md b/README.md index a551dba..9f1d6d8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ hello world This class is an interface for updating the `__DATA__` section of your Perl module or script programmatically for it to work with one of the many modules that allows for multiple files in a `__DATA__` section, such as -[Data::Section](https://metacpan.org/pod/Data::Section), [Data::Section::Simple](https://metacpan.org/pod/Data::Section::Simple) or [Mojo::Loader](https://metacpan.org/pod/Mojo::Loader). +[Data::Section](https://metacpan.org/pod/Data::Section), [Data::Section::Simple](https://metacpan.org/pod/Data::Section::Simple), [Data::Section::Pluggable](https://metacpan.org/pod/Data::Section::Pluggable) or [Mojo::Loader](https://metacpan.org/pod/Mojo::Loader). [Data::Section](https://metacpan.org/pod/Data::Section) uses a different header format by default, but you can still use this module with it if you set `header_re` to `qr/^@@ (.*)$/`. @@ -114,6 +114,10 @@ be identical. Not tested, and probably not working for Windows formatted text files, though patches for this are welcome. +# SEE ALSO + +- [Data::Section::Pluggable](https://metacpan.org/pod/Data::Section::Pluggable) + # AUTHOR Graham Ollis diff --git a/dist.ini b/dist.ini index 33df05c..a7fb188 100644 --- a/dist.ini +++ b/dist.ini @@ -20,6 +20,7 @@ version_plugin = PkgVersion::Block diag = +Mojolicious diag = +Data::Section::Simple +diag = +Data::Section::Pluggable diag = +Data::Section [Author::Plicease::Core] @@ -30,6 +31,7 @@ cpan = 1 [RemovePrereqs] remove = Mojo::Loader remove = Data::Section::Simple +remove = Data::Section::Pluggable remove = Data::Section [InsertExample] diff --git a/lib/Data/Section/Writer.pm b/lib/Data/Section/Writer.pm index 64d4a48..3369f2c 100644 --- a/lib/Data/Section/Writer.pm +++ b/lib/Data/Section/Writer.pm @@ -23,7 +23,7 @@ Will add this to the bottom of C This class is an interface for updating the C<__DATA__> section of your Perl module or script programmatically for it to work with one of the many modules that allows for multiple files in a C<__DATA__> section, such as -L, L or L. +L, L, L or L. L uses a different header format by default, but you can still use this module with it if you set C to C. @@ -202,4 +202,12 @@ be identical. Not tested, and probably not working for Windows formatted text files, though patches for this are welcome. +=head1 SEE ALSO + +=over 4 + +=item L + +=back + =cut diff --git a/t/00_diag.t b/t/00_diag.t index c4162c6..27863c2 100644 --- a/t/00_diag.t +++ b/t/00_diag.t @@ -14,6 +14,7 @@ $modules{$_} = $_ for qw( Capture::Tiny Class::Tiny Data::Section + Data::Section::Pluggable Data::Section::Simple EV ExtUtils::MakeMaker diff --git a/t/integration_data_section_pluggable.t b/t/integration_data_section_pluggable.t new file mode 100644 index 0000000..ecd7471 --- /dev/null +++ b/t/integration_data_section_pluggable.t @@ -0,0 +1,35 @@ +use Test2::V0 -no_srand => 1; +use Test2::Require::Module 'Data::Section::Pluggable'; +use lib 't/lib'; +use MyIntegration qw( run ); +use Data::Section::Pluggable qw( get_data_section ); +use Path::Tiny (); +use Data::Section::Writer; + +my $script = Path::Tiny->tempfile; +$script->spew_utf8(get_data_section 'example.pl'); +Data::Section::Writer + ->new( perl_filename => $script ) + ->add_file( 'a.txt', "Foo Bar Baz\n" ) + ->add_file( 'b.txt', "Foo Bar Baz\n" ) + ->add_file( 'c.txt', "Frooble Bits", 'base64' ) + ->update_file; + +note $script->slurp_utf8; + +run $script, 'a.txt', "Foo Bar Baz\n", 'text'; +run $script, 'b.txt', "Foo Bar Baz\n", 'at EOF'; +run $script, 'c.txt', 'Frooble Bits', 'binary'; + +done_testing; + +__DATA__ + +@@ example.pl +#!/usr/bin/perl + +use strict; +use warnings; +use Data::Section::Pluggable qw( get_data_section ); + +print get_data_section($ARGV[0]);