File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 73 9.5
branch 0 48 0.0
condition 0 12 0.0
subroutine 3 8 37.5
pod n/a
total 10 141 7.0


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   255923 use strict;
  1         1  
  1         39  
4 1     1   787 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         126706  
  1         1901  
5             # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6             # the contents of the Makefile that is written.
7              
8             # Normalize version strings like 6.30_02 to 6.3002,
9             # so that we can do numerical comparisons on it.
10             my $eumm_version = $ExtUtils::MakeMaker::VERSION;
11             $eumm_version =~ s/_//;
12              
13             my $module = 'AI::Ollama::Client';
14             (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
15             (my $distbase = $module) =~ s!::!-!g;
16             my $distlink = $distbase;
17              
18             my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
19              
20             my %module = (
21             NAME => $module,
22             AUTHOR => q{Max Maischein },
23             VERSION_FROM => $main_file,
24             ABSTRACT_FROM => $main_file,
25             META_MERGE => {
26             "meta-spec" => { version => 2 },
27             resources => {
28             repository => {
29             web => "https://github.com/Corion/$distlink",
30             url => "git://github.com/Corion/$distlink.git",
31             type => 'git',
32             },
33             bugtracker => {
34             web => "https://github.com/Corion/$distbase/issues",
35             # mailto => 'meta-bugs@example.com',
36             },
37             license => "https://dev.perl.org/licenses/",
38             },
39             dynamic_config => 0, # we promise to keep META.* up-to-date
40             x_static_install => 1, # we are pure Perl and don't do anything fancy
41             },
42              
43             MIN_PERL_VERSION => '5.020', # I use signatures
44              
45             'LICENSE'=> 'artistic_2',
46              
47             PL_FILES => {},
48              
49             CONFIGURE_REQUIRES => {
50             'ExtUtils::MakeMaker' => 0,
51             'File::ShareDir::Install' => 0,
52             },
53              
54             BUILD_REQUIRES => {
55             'strict' => 0,
56             },
57              
58             PREREQ_PM => {
59             'stable' => '0.031',
60             'experimental' => '0.031',
61             'Carp' => 0,
62             'File::ShareDir' => 0,
63             'Future' => 0,
64             'Future::Mojo' => 0,
65             'Future::Utils' => 0,
66             'Future::Queue' => 0,
67             'Moo' => 2,
68             'Mojolicious' => 9,
69             'Mojo::JSON' => 0,
70             'Mojo::URL' => 0,
71             'Mojo::UserAgent' => 0,
72             'OpenAPI::Modern' => 0,
73             'PerlX::Maybe' => 0,
74             'Role::EventEmitter' => 0,
75             'URI::Template' => 0,
76             'YAML::PP' => 0,
77             },
78             TEST_REQUIRES => {
79             'Test2::V0' => 0,
80             },
81              
82             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
83             clean => { FILES => "$distbase-*" },
84              
85             test => { TESTS => join( ' ', @tests ) },
86             );
87              
88             # This is so that we can do
89             # require 'Makefile.PL'
90             # and then call get_module_info
91              
92 1     1   54 sub get_module_info { %module }
93              
94             if( ! caller ) {
95             require File::ShareDir::Install;
96             File::ShareDir::Install::install_share( module => "$module\::Impl" => 'ollama');
97              
98             {
99             package MY;
100             require File::ShareDir::Install;
101             File::ShareDir::Install->import( qw( postamble ));
102             }
103              
104             # I should maybe use something like Shipwright...
105             my $mm = WriteMakefile1(get_module_info);
106             my $version = $mm->parse_version($main_file);
107             regen_README($main_file, $version);
108             regen_EXAMPLES() if -d 'examples';
109             };
110              
111             1;
112              
113             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
114 0     0     my %params=@_;
115 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
116 0           $eumm_version=eval $eumm_version;
117 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
118 0 0         die "License not specified" if not exists $params{LICENSE};
119 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
120             #EUMM 6.5502 has problems with BUILD_REQUIRES
121 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
122 0           delete $params{BUILD_REQUIRES};
123             }
124 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
125 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
126 0           delete $params{TEST_REQUIRES};
127             }
128 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
129 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
130 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
131 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
132 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
133 0 0         delete $params{AUTHOR} if $] < 5.005;
134 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
135 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
136              
137 0           WriteMakefile(%params);
138             }
139              
140             sub regen_README {
141             # README is the short version that just tells people what this is
142             # and how to install it
143 0     0     my( $file, $version ) = @_;
144 0           eval {
145             # Get description
146 0           my $readme = join "\n",
147             pod_section($file, 'NAME', 'no heading' ),
148             pod_section($file, 'DESCRIPTION' ),
149             <
150             This document describes version $version.
151             VERSION
152             <
153              
154             INSTALLATION
155              
156             This is a Perl module distribution. It should be installed with whichever
157             tool you use to manage your installation of Perl, e.g. any of
158              
159             cpanm .
160             cpan .
161             cpanp -i .
162              
163             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
164             Should you wish to install this module manually, the procedure is
165              
166             perl Makefile.PL
167             make
168             make test
169             make install
170              
171             INSTALL
172             pod_section($file, 'REPOSITORY'),
173             pod_section($file, 'SUPPORT'),
174             pod_section($file, 'TALKS'),
175             pod_section($file, 'KNOWN ISSUES'),
176             pod_section($file, 'BUG TRACKER'),
177             pod_section($file, 'CONTRIBUTING'),
178             pod_section($file, 'SEE ALSO'),
179             pod_section($file, 'AUTHOR'),
180             pod_section($file, 'LICENSE' ),
181             pod_section($file, 'COPYRIGHT' ),
182             ;
183 0           update_file( 'README', $readme );
184             };
185             # README.mkdn is the documentation that will be shown as the main
186             # page of the repository on Github. Hence we recreate the POD here
187             # as Markdown
188 0           eval {
189 0           require Pod::Markdown;
190              
191 0           my $parser = Pod::Markdown->new();
192              
193             # Read POD from Module.pm and write to README
194 0           $parser->parse_from_file($_[0]);
195 0           my $readme_mkdn = <as_markdown;
196              
197             [![Windows](https://github.com/Corion/$distbase/workflows/windows/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Awindows)
198             [![MacOS](https://github.com/Corion/$distbase/workflows/macos/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Amacos)
199             [![Linux](https://github.com/Corion/$distbase/workflows/linux/badge.svg)](https://github.com/Corion/$distbase/actions?query=workflow%3Alinux)
200              
201             STATUS
202 0           update_file( 'README.mkdn', $readme_mkdn );
203             };
204             }
205              
206             sub pod_section {
207 0     0     my( $filename, $section, $remove_heading ) = @_;
208 0 0         open my $fh, '<', $filename
209             or die "Couldn't read '$filename': $!";
210              
211             my @section =
212 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
213              
214             # Trim the section
215 0 0         if( @section ) {
216 0 0         pop @section if $section[-1] =~ /^=/;
217 0 0         shift @section if $remove_heading;
218              
219             pop @section
220 0   0       while @section and $section[-1] =~ /^\s*$/;
221             shift @section
222 0   0       while @section and $section[0] =~ /^\s*$/;
223             };
224              
225 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
226 0           return join "", @section;
227             }
228              
229             sub regen_EXAMPLES {
230 0     0     my $perl = $^X;
231 0 0         if ($perl =~/\s/) {
232 0           $perl = qq{"$perl"};
233             };
234 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
235 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
236 0 0         if ($examples) {
237 0           warn "(Re)Creating $example_file\n";
238 0           $examples =~ s/\r\n/\n/g;
239 0           update_file( $example_file, $examples );
240             };
241             };
242              
243             sub update_file {
244 0     0     my( $filename, $new_content ) = @_;
245 0           my $content;
246 0 0         if( -f $filename ) {
247 0 0         open my $fh, '<:raw:encoding(UTF-8)', $filename
248             or die "Couldn't read '$filename': $!";
249 0           local $/;
250 0           $content = <$fh>;
251             };
252              
253 0 0         if( $content ne $new_content ) {
254 0 0         if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
255 0           print $fh $new_content;
256             } else {
257 0           warn "Couldn't (re)write '$filename': $!";
258             };
259             };
260             }