| 1 | package Software::Policies::AIDisclosure::Basic; | ||||||||||||
| 2 | ## no critic (ControlStructures::ProhibitPostfixControls) | ||||||||||||
| 3 | |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | # ABSTRACT: Create project policy file: AIDisclosure / Basic | ||||||||||||
| 9 | |||||||||||||
| 10 | 2 | our $VERSION = '0.006'; | |||||||||||
| 11 | |||||||||||||
| 12 | 2 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 2 | ▶ | use Data::Section -setup; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 2 | ▶ | use Text::Template (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 1 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 17 | 1 | my ($class) = @_; | |||||||||||
| 18 | 1 | return bless {}, $class; | |||||||||||
| 19 | } | ||||||||||||
| 20 | |||||||||||||
| 21 | 1 | ▶ | sub create { | ||||||||||
|
Subroutine
create: called CC=10 SCAR=24.5
Pod
documented
| |||||||||||||
| 22 | 1 | my ( $self, %args ) = @_; | |||||||||||
| 23 | 1 | ▶ | my $version = delete $args{'version'} // '1'; | ||||||||||
|
Condition50%1/2
delete $args{"version"} // 1
MC/DC0%0/1
delete $args{"version"} // 1
delete $args{"version"}
Truth table50%1/2
A
A= delete $args{"version"}
| |||||||||||||
| 24 | 1 | ▶ | my $format = delete $args{'format'} // 'markdown'; | ||||||||||
|
Condition50%1/2
delete $args{"format"} // "markdown"
MC/DC0%0/1
delete $args{"format"} // "markdown"
delete $args{"format"}
Truth table50%1/2
A
A= delete $args{"format"}
| |||||||||||||
| 25 | |||||||||||||
| 26 | 1 | my %attributes; | |||||||||||
| 27 | 1 | ▶ | my $attrs = delete $args{'attributes'} // {}; | ||||||||||
|
Condition50%1/2
delete $args{"attributes"} // {}
MC/DC0%0/1
delete $args{"attributes"} // {}
delete $args{"attributes"}
Truth table50%1/2
A
A= delete $args{"attributes"}
| |||||||||||||
| 28 | 1 | ▶ | $attributes{'contact'} = $attrs->{'authors'}->[0] if $attrs->{'authors'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 1 | ▶ | $attributes{'ai_tools'} = $attrs->{'ai_tools'} if $attrs->{'ai_tools'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 1 | ▶ | croak q{Missing attribute 'authors'} if ( !defined $attributes{'contact'} ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | 1 | ▶ | croak q{Missing attribute 'ai_tools'} if ( !defined $attributes{'ai_tools'} ); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | |||||||||||||
| 33 | 1 | ▶ | croak 'Unknown arguments: ', join q{,}, keys %args if (%args); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | |||||||||||||
| 35 | 1 | $attributes{'tools'} = delete $attributes{'ai_tools'}; | |||||||||||
| 36 | |||||||||||||
| 37 | 1 | my ($data_section) = __PACKAGE__ =~ m/.+::([^:]+)$/msx; | |||||||||||
| 38 | 1 | my $data_section_label = $data_section . q{_v} . $version . q{_} . $format; | |||||||||||
| 39 | 1 | my $template = $self->section_data($data_section_label); | |||||||||||
| 40 | 1 | ▶ | croak "Cannot find data section $data_section_label" | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | if ( !$template ); | ||||||||||||
| 42 | my $text = Text::Template->fill_this_in( | ||||||||||||
| 43 | 1 | ${$template}, | |||||||||||
| 44 | HASH => \%attributes, | ||||||||||||
| 45 | DELIMITERS => [qw/{{ }}/], | ||||||||||||
| 46 | ); | ||||||||||||
| 47 | return ( | ||||||||||||
| 48 | 1 | policy => 'AIDisclosure', | |||||||||||
| 49 | class => 'Basic', | ||||||||||||
| 50 | version => $version, | ||||||||||||
| 51 | text => $text, | ||||||||||||
| 52 | filename => _filename($format), | ||||||||||||
| 53 | format => $format, | ||||||||||||
| 54 | ); | ||||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 0 | ▶ | sub get_available_classes_and_versions { | ||||||||||
|
Subroutine
get_available_classes_and_versions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 58 | return { | ||||||||||||
| 59 | 0 | 'Basic' => { | |||||||||||
| 60 | versions => { | ||||||||||||
| 61 | '1' => 1, | ||||||||||||
| 62 | '1.1' => 1, | ||||||||||||
| 63 | }, | ||||||||||||
| 64 | formats => { | ||||||||||||
| 65 | 'markdown' => 1, | ||||||||||||
| 66 | }, | ||||||||||||
| 67 | }, | ||||||||||||
| 68 | }; | ||||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | 1 | ▶ | sub _filename { | ||||||||||
|
Subroutine
_filename: called CC=1 SCAR=0.0
| |||||||||||||
| 72 | 1 | my ($format) = @_; | |||||||||||
| 73 | 1 | my %formats = ( 'markdown' => 'AI_DISCLOSURE.md', ); | |||||||||||
| 74 | 1 | return $formats{$format}; | |||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | 2 | 1; | |||||||||||
| 78 | |||||||||||||
| 79 | # Removed the original text which mentioned the license. | ||||||||||||
| 80 | # ## Intellectual Property and Licensing | ||||||||||||
| 81 | # | ||||||||||||
| 82 | # This project is licensed under the Perl 5 License (Artistic License | ||||||||||||
| 83 | # 1.0 and/or GNU General Public License version 1 or later). The | ||||||||||||
| 84 | # copyright status of AI-generated code is legally unsettled in most | ||||||||||||
| 85 | # jurisdictions as of this writing. Users and distributors should be | ||||||||||||
| 86 | # aware of this uncertainty and assess their own risk accordingly. | ||||||||||||
| 87 | |||||||||||||
| 88 | =pod | ||||||||||||
| 89 | |||||||||||||
| 90 | =encoding UTF-8 | ||||||||||||
| 91 | |||||||||||||
| 92 | =head1 NAME | ||||||||||||
| 93 | |||||||||||||
| 94 | Software::Policies::AIDisclosure::Basic - Create project policy file: AIDisclosure / Basic | ||||||||||||
| 95 | |||||||||||||
| 96 | =head1 VERSION | ||||||||||||
| 97 | |||||||||||||
| 98 | version 0.006 | ||||||||||||
| 99 | |||||||||||||
| 100 | =for Pod::Coverage new create get_available_classes_and_versions | ||||||||||||
| 101 | |||||||||||||
| 102 | =begin stopwords | ||||||||||||
| 103 | |||||||||||||
| 104 | |||||||||||||
| 105 | |||||||||||||
| 106 | |||||||||||||
| 107 | =end stopwords | ||||||||||||
| 108 | |||||||||||||
| 109 | =head1 METHODS | ||||||||||||
| 110 | |||||||||||||
| 111 | =head2 new | ||||||||||||
| 112 | |||||||||||||
| 113 | =head2 create | ||||||||||||
| 114 | |||||||||||||
| 115 | Create the policy. | ||||||||||||
| 116 | |||||||||||||
| 117 | Options: | ||||||||||||
| 118 | |||||||||||||
| 119 | =over 8 | ||||||||||||
| 120 | |||||||||||||
| 121 | =item class | ||||||||||||
| 122 | |||||||||||||
| 123 | Available classes: B<Basic> (default). | ||||||||||||
| 124 | |||||||||||||
| 125 | =item version | ||||||||||||
| 126 | |||||||||||||
| 127 | Available versions: 1 (default), 1.1. | ||||||||||||
| 128 | |||||||||||||
| 129 | =item format | ||||||||||||
| 130 | |||||||||||||
| 131 | Available formats: markdown (default). | ||||||||||||
| 132 | |||||||||||||
| 133 | =item attributes | ||||||||||||
| 134 | |||||||||||||
| 135 | =over 8 | ||||||||||||
| 136 | |||||||||||||
| 137 | =item authors | ||||||||||||
| 138 | |||||||||||||
| 139 | Required attribute for contact information. | ||||||||||||
| 140 | |||||||||||||
| 141 | =item ai_tools | ||||||||||||
| 142 | |||||||||||||
| 143 | Required list of ai_tools used (a string). Example: 'Claude, Copilot and Gemini'. | ||||||||||||
| 144 | |||||||||||||
| 145 | =back | ||||||||||||
| 146 | |||||||||||||
| 147 | =back | ||||||||||||
| 148 | |||||||||||||
| 149 | =head1 AUTHOR | ||||||||||||
| 150 | |||||||||||||
| 151 | Mikko Koivunalho <mikkoi@cpan.org> | ||||||||||||
| 152 | |||||||||||||
| 153 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 154 | |||||||||||||
| 155 | This software is copyright (c) 2025 by Mikko Koivunalho. | ||||||||||||
| 156 | |||||||||||||
| 157 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 158 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 159 | |||||||||||||
| 160 | =cut | ||||||||||||
| 161 | |||||||||||||
| 162 | __DATA__ | ||||||||||||