File Coverage

lib/Net/API/CPAN/Diff.pm
Criterion Covered Total %
statement 34 35 97.1
branch 5 10 50.0
condition n/a
subroutine 12 13 92.3
pod 6 6 100.0
total 57 64 89.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Meta CPAN API - ~/lib/Net/API/CPAN/Diff.pm
3             ## Version v0.1.0
4             ## Copyright(c) 2023 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2023/07/25
7             ## Modified 2023/09/25
8             ## All rights reserved
9             ##
10             ##
11             ## This program is free software; you can redistribute it and/or modify it
12             ## under the same terms as Perl itself.
13             ##----------------------------------------------------------------------------
14             # This module file has been automatically generated. Any change made here will be lost.
15             # Edit the script in ./build/build_modules.pl instead
16             package Net::API::CPAN::Diff;
17             BEGIN
18             {
19 2     2   230623 use strict;
  2         10  
  2         55  
20 2     2   14 use warnings;
  2         6  
  2         52  
21 2     2   8 use parent qw( Net::API::CPAN::Generic );
  2         3  
  2         22  
22 2     2   110 use vars qw( $VERSION );
  2         6  
  2         71  
23 2     2   31 our $VERSION = 'v0.1.0';
24             };
25              
26 2     2   9 use strict;
  2         3  
  2         29  
27 2     2   9 use warnings;
  2         4  
  2         547  
28              
29             sub init
30             {
31 1     1 1 9963 my $self = shift( @_ );
32 1 50       61 $self->{diff} = undef unless( CORE::exists( $self->{diff} ) );
33 1         3 $self->{object} = 'diff';
34 1 50       4 $self->{source} = undef unless( CORE::exists( $self->{source} ) );
35 1 50       4 $self->{statistics} = [] unless( CORE::exists( $self->{statistics} ) );
36 1 50       5 $self->{target} = undef unless( CORE::exists( $self->{target} ) );
37 1         2 $self->{_init_strict_use_sub} = 1;
38 1         1 $self->{_exception_class} = 'Net::API::CPAN::Exception';
39 1 50       7 $self->SUPER::init( @_ ) || return( $self->pass_error );
40 1         6 $self->{fields} = [qw( diff source statistics target )];
41 1         3 return( $self );
42             }
43              
44 1     1 1 3671 sub diff { return( shift->_set_get_scalar_as_object( 'diff', @_ ) ); }
45              
46 0     0 1 0 sub object { return( shift->_set_get_scalar_as_object( 'object', @_ ) ); }
47              
48 2     2 1 2022 sub source { return( shift->_set_get_scalar_as_object( 'source', @_ ) ); }
49              
50 2     2 1 1845 sub statistics { return( shift->_set_get_class_array_object( 'statistics', {
51             deletions => "integer",
52             diff => "scalar_as_object",
53             insertions => "integer",
54             source => "scalar_as_object",
55             target => "scalar_as_object",
56             }, @_ ) ); }
57              
58 2     2 1 616761 sub target { return( shift->_set_get_scalar_as_object( 'target', @_ ) ); }
59              
60             1;
61             # NOTE: POD
62             __END__
63              
64             =encoding utf-8
65              
66             =head1 NAME
67              
68             Net::API::CPAN::Diff - Meta CPAN API Diff Class
69              
70             =head1 SYNOPSIS
71              
72             use Net::API::CPAN::Diff;
73             my $obj = Net::API::CPAN::Diff->new( {
74             source => "MOMOTARO/Folklore-Japan-v1.2.2",
75             statistics => [
76             {
77             deletions => 0,
78             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n\@\@ -2,5 +3,5 \@\@\n v0.1.1 2023-08-19T13:10:37+0900\n - Updated name returned\n",
79             insertions => 1,
80             source => "MOMOTARO/Folklore-Japan-v1.2.2/CHANGES",
81             target => "MOMOTARO/Folklore-Japan-v1.2.3/CHANGES",
82             },
83             {
84             deletions => 1,
85             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md\n\@\@ -32 +32 \@\@\n - The versioning style used is dotted decimal, such as `v0.1.0`\n + The versioning style used is dotted decimal, such as `v0.1.1`\n",
86             insertions => 1,
87             source => "MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md",
88             target => "MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md",
89             },
90             {
91             deletions => 5,
92             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm\n\@\@ -3 +3 \@\@\n - ## Version v0.1.0\n + Version v0.1.1\n\@\@ -7 +7 \@\@\n - ## Modified 2023/08/15\n + ## Modified 2023/08/19\n\@\@ -19 +19 \@\@\n - \$VERSION = 'v0.1.0';\n + \$VERSION = 'v0.1.1';\n\@\@ -29 +29 \@\@\n - sub name { return( \"John Doe\" ); }\n + sub name { return( \"Urashima Taro\" ); }\n\@\@ -48 + 48 \@\@\n - v0.1.0\n + v0.1.1",
93             insertions => 5,
94             source => "MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm",
95             target => "MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm",
96             },
97             {
98             deletions => 1,
99             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.json b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.json\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.json\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.json\n\@\@ -60 +60 \@\@\n - \"version\" : \"v0.1.0\",\n + \"version\" : \"v0.1.1\",\n",
100             insertions => 1,
101             source => "MOMOTARO/Folklore-Japan-v1.2.2/META.json",
102             target => "MOMOTARO/Folklore-Japan-v1.2.3/META.json",
103             },
104             {
105             deletions => 1,
106             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.yml b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.yml\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.yml\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.yml\n\@\@ -32 +32 \@\@\n - version: v0.1.0\n + version: v0.1.1\n",
107             insertions => 1,
108             source => "MOMOTARO/Folklore-Japan-v1.2.2/META.yml",
109             target => "MOMOTARO/Folklore-Japan-v1.2.3/META.yml",
110             },
111             ],
112             target => "MOMOTARO/Folklore-Japan-v1.2.3",
113             } ) || die( Net::API::CPAN::Diff->error );
114            
115             my $string = $obj->diff;
116             my $str = $obj->object;
117             my $string = $obj->source;
118             my $array = $obj->statistics;
119             foreach my $this ( @$array )
120             {
121             my $integer = $this->deletions;
122             my $scalar = $this->diff;
123             my $integer = $this->insertions;
124             my $scalar = $this->source;
125             my $scalar = $this->target;
126             }
127             my $string = $obj->target;
128              
129             =head1 VERSION
130              
131             v0.1.0
132              
133             =head1 DESCRIPTION
134              
135             This class serves to retrieve and manipulate diffs.
136              
137             It inherits from L<Net::API::CPAN::Generic>
138              
139             =head1 CONSTRUCTOR
140              
141             =head2 new
142              
143             Provided with an hash or hash reference of parameters, and this instantiates a new C<Net::API::CPAN::Diff> object.
144              
145             The parameters that can be provided bear the same name and supports the same values as the methods below.
146              
147             =head1 METHODS
148              
149             =head2 diff
150              
151             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
152              
153             =head2 object
154              
155             Returns the object type for this class, which is C<diff>
156              
157             =head2 source
158              
159             $obj->source( "MOMOTARO/Folklore-Japan-v1.2.2" );
160             my $string = $obj->source;
161              
162             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
163              
164             =head2 statistics
165              
166             $obj->statistics( [
167             {
168             deletions => 0,
169             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n\@\@ -2,5 +3,5 \@\@\n v0.1.1 2023-08-19T13:10:37+0900\n - Updated name returned\n",
170             insertions => 1,
171             source => "MOMOTARO/Folklore-Japan-v1.2.2/CHANGES",
172             target => "MOMOTARO/Folklore-Japan-v1.2.3/CHANGES",
173             },
174             {
175             deletions => 1,
176             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md\n\@\@ -32 +32 \@\@\n - The versioning style used is dotted decimal, such as `v0.1.0`\n + The versioning style used is dotted decimal, such as `v0.1.1`\n",
177             insertions => 1,
178             source => "MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md",
179             target => "MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md",
180             },
181             {
182             deletions => 5,
183             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm\n\@\@ -3 +3 \@\@\n - ## Version v0.1.0\n + Version v0.1.1\n\@\@ -7 +7 \@\@\n - ## Modified 2023/08/15\n + ## Modified 2023/08/19\n\@\@ -19 +19 \@\@\n - \$VERSION = 'v0.1.0';\n + \$VERSION = 'v0.1.1';\n\@\@ -29 +29 \@\@\n - sub name { return( \"John Doe\" ); }\n + sub name { return( \"Urashima Taro\" ); }\n\@\@ -48 + 48 \@\@\n - v0.1.0\n + v0.1.1",
184             insertions => 5,
185             source => "MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm",
186             target => "MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm",
187             },
188             {
189             deletions => 1,
190             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.json b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.json\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.json\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.json\n\@\@ -60 +60 \@\@\n - \"version\" : \"v0.1.0\",\n + \"version\" : \"v0.1.1\",\n",
191             insertions => 1,
192             source => "MOMOTARO/Folklore-Japan-v1.2.2/META.json",
193             target => "MOMOTARO/Folklore-Japan-v1.2.3/META.json",
194             },
195             {
196             deletions => 1,
197             diff => "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.yml b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.yml\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.yml\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.yml\n\@\@ -32 +32 \@\@\n - version: v0.1.0\n + version: v0.1.1\n",
198             insertions => 1,
199             source => "MOMOTARO/Folklore-Japan-v1.2.2/META.yml",
200             target => "MOMOTARO/Folklore-Japan-v1.2.3/META.yml",
201             },
202             ] );
203             my $array = $obj->statistics;
204             foreach my $this ( @$array )
205             {
206             $this->deletions( 0 );
207             my $integer = $this->deletions;
208             $this->diff( "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n\@\@ -2,5 +3,5 \@\@\n v0.1.1 2023-08-19T13:10:37+0900\n - Updated name returned\n" );
209             my $scalar = $this->diff;
210             $this->insertions( 1 );
211             my $integer = $this->insertions;
212             $this->source( "MOMOTARO/Folklore-Japan-v1.2.2/CHANGES" );
213             my $scalar = $this->source;
214             $this->target( "MOMOTARO/Folklore-Japan-v1.2.3/CHANGES" );
215             my $scalar = $this->target;
216             }
217              
218             Sets or gets an array of dynamic class objects with class name C<Net::API::CPAN::Diff::Statistics> and having the folowing properties also accessible as methods, and returns an L<array object|Module::Generic::Array> even if there is no value.
219              
220             A C<Net::API::CPAN::Diff::Statistics> object will be instantiated with each value from the array provided and replace said value.
221              
222             =over 4
223              
224             =item * C<deletions> integer (L<number object|Module::Generic::Number>)
225              
226             =item * C<diff> scalar_as_object
227              
228             =item * C<insertions> integer (L<number object|Module::Generic::Number>)
229              
230             =item * C<source> scalar_as_object
231              
232             =item * C<target> scalar_as_object
233              
234             =back
235              
236             =head2 target
237              
238             $obj->target( "MOMOTARO/Folklore-Japan-v1.2.3" );
239             my $string = $obj->target;
240              
241             Sets or gets a string and returns a L<scalar object|Module::Generic::Scalar>, even if there is no value.
242              
243             =head1 API SAMPLE
244              
245             {
246             "source" : "MOMOTARO/Folklore-Japan-v1.2.2",
247             "statistics" : [
248             {
249             "deletions" : 0,
250             "diff" : "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CHANGES\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CHANGES\n@@ -2,5 +3,5 @@\n v0.1.1 2023-08-19T13:10:37+0900\n - Updated name returned\n",
251             "insertions" : 1,
252             "source" : "MOMOTARO/Folklore-Japan-v1.2.2/CHANGES",
253             "target" : "MOMOTARO/Folklore-Japan-v1.2.3/CHANGES"
254             },
255             {
256             "deletions" : 1,
257             "diff" : "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md\n@@ -32 +32 @@\n - The versioning style used is dotted decimal, such as `v0.1.0`\n + The versioning style used is dotted decimal, such as `v0.1.1`\n",
258             "insertions" : 1,
259             "source" : "MOMOTARO/Folklore-Japan-v1.2.2/CONTRIBUTING.md",
260             "target" : "MOMOTARO/Folklore-Japan-v1.2.3/CONTRIBUTING.md"
261             },
262             {
263             "deletions" : 5,
264             "diff" : "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm\n@@ -3 +3 @@\n - ## Version v0.1.0\n + Version v0.1.1\n@@ -7 +7 @@\n - ## Modified 2023/08/15\n + ## Modified 2023/08/19\n@@ -19 +19 @@\n - $VERSION = 'v0.1.0';\n + $VERSION = 'v0.1.1';\n@@ -29 +29 @@\n - sub name { return( \"John Doe\" ); }\n + sub name { return( \"Urashima Taro\" ); }\n@@ -48 + 48 @@\n - v0.1.0\n + v0.1.1",
265             "insertions" : 5,
266             "source" : "MOMOTARO/Folklore-Japan-v1.2.2/lib/Foo/Bar.pm",
267             "target" : "MOMOTARO/Folklore-Japan-v1.2.3/lib/Foo/Bar.pm"
268             },
269             {
270             "deletions" : 1,
271             "diff" : "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.json b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.json\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.json\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.json\n@@ -60 +60 @@\n - \"version\" : \"v0.1.0\",\n + \"version\" : \"v0.1.1\",\n",
272             "insertions" : 1,
273             "source" : "MOMOTARO/Folklore-Japan-v1.2.2/META.json",
274             "target" : "MOMOTARO/Folklore-Japan-v1.2.3/META.json"
275             },
276             {
277             "deletions" : 1,
278             "diff" : "diff --git a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.yml b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.yml\n--- a/var/tmp/source/MOMOTARO/Folklore-Japan-v1.2.2/META.yml\n+++ b/var/tmp/target/MOMOTARO/Folklore-Japan-v1.2.3/META.yml\n@@ -32 +32 @@\n - version: v0.1.0\n + version: v0.1.1\n",
279             "insertions" : 1,
280             "source" : "MOMOTARO/Folklore-Japan-v1.2.2/META.yml",
281             "target" : "MOMOTARO/Folklore-Japan-v1.2.3/META.yml"
282             }
283             ],
284             "target" : "MOMOTARO/Folklore-Japan-v1.2.3"
285             }
286              
287             =head1 AUTHOR
288              
289             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
290              
291             =head1 SEE ALSO
292              
293             L<Net::API::CPAN>, L<Net::API::CPAN::Activity>, L<Net::API::CPAN::Author>, L<Net::API::CPAN::Changes>, L<Net::API::CPAN::Changes::Release>, L<Net::API::CPAN::Contributor>, L<Net::API::CPAN::Cover>, L<Net::API::CPAN::Diff>, L<Net::API::CPAN::Distribution>, L<Net::API::CPAN::DownloadUrl>, L<Net::API::CPAN::Favorite>, L<Net::API::CPAN::File>, L<Net::API::CPAN::Module>, L<Net::API::CPAN::Package>, L<Net::API::CPAN::Permission>, L<Net::API::CPAN::Rating>, L<Net::API::CPAN::Release>
294              
295             L<MetaCPAN::API>, L<MetaCPAN::Client>
296              
297             L<https://github.com/metacpan/metacpan-api/blob/master/docs/API-docs.md>
298              
299             =head1 COPYRIGHT & LICENSE
300              
301             Copyright(c) 2023 DEGUEST Pte. Ltd.
302              
303             All rights reserved
304              
305             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
306              
307             =cut
308