Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/^@@ (.*)$/`.
Expand Down Expand Up @@ -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 <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ version_plugin = PkgVersion::Block

diag = +Mojolicious
diag = +Data::Section::Simple
diag = +Data::Section::Pluggable
diag = +Data::Section

[Author::Plicease::Core]
Expand All @@ -30,6 +31,7 @@ cpan = 1
[RemovePrereqs]
remove = Mojo::Loader
remove = Data::Section::Simple
remove = Data::Section::Pluggable
remove = Data::Section

[InsertExample]
10 changes: 9 additions & 1 deletion lib/Data/Section/Writer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Will add this to the bottom of C<foo.pl>

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<Data::Section>, L<Data::Section::Simple> or L<Mojo::Loader>.
L<Data::Section>, L<Data::Section::Simple>, L<Data::Section::Pluggable> or L<Mojo::Loader>.

L<Data::Section> uses a different header format by default, but you can still use this module with it
if you set C<header_re> to C<qr/^@@ (.*)$/>.
Expand Down Expand Up @@ -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<Data::Section::Pluggable>

=back

=cut
1 change: 1 addition & 0 deletions t/00_diag.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $modules{$_} = $_ for qw(
Capture::Tiny
Class::Tiny
Data::Section
Data::Section::Pluggable
Data::Section::Simple
EV
ExtUtils::MakeMaker
Expand Down
35 changes: 35 additions & 0 deletions t/integration_data_section_pluggable.t
Original file line number Diff line number Diff line change
@@ -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]);
Loading