Test-CPAN-Meta-JSON-0.16/0000755000175000017500000000000012454446444013776 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/INSTALL0000644000175000017500000000573512412200611015013 0ustar barbiebarbieInstallation Instructions The instructions are basically as per any Perl module. INSTALLING AUTOMATICALLY ------------------------ The easiest way to install is via CPAN, CPANPLUS or cpanminus: CPAN: % perl -MCPAN -e shell [as root] > install Test::CPAN::Meta::JSON > quit CPANPLUS: % cpanp > i Test::CPAN::Meta::JSON > q cpanminus: % cpanm Test::CPAN::Meta::JSON See your local documentation ('perldoc CPAN', 'perldoc CPANPLUS' or 'perldoc cpanm') for further instructions on setting up and configuring your chosen installer. OBTAINING THE MODULE -------------------- The latest release version of Test-CPAN-Meta-JSON can be downloaded from any CPAN site: http://www.cpan.org/modules/by-authors/id/B/BA/BARBIE/ http://search.cpan.org/dist/Test-CPAN-Meta-JSON/ Phrasebook is distributed as a gzipped tar archive file: Test-CPAN-Meta-JSON-.tar.gz where represents the current version number, e.g. 0.10. To install the module, unpack the distribution archive to create an installation directory. Something like this: tar zxf Test-CPAN-Meta-JSON-0.10.tar.gz or gunzip Test-CPAN-Meta-JSON-0.10.tar.gz tar xf Test-CPAN-Meta-JSON-0.10.tar You can then 'cd' into the directory created, cd Test-CPAN-Meta-JSON-0.10 INSTALLING MANUALLY ------------------- The 'make install' (done later) will install the modules and scripts on your system. You may need administrator privileges to perform this task. Alternately you can install the module to a local directory (see ExtUtils::MakeMaker for full details), e.g. % perl Makefile.PL PREFIX=/home/me/ Don't forget to update your PERL5LIB environment variable if you do this, or add a line to your script to tell Perl where to find the files, e.g. use lib qw( /home/me/lib/perl5/site_perl/5.6.0 ); If you're not after a custom location, just do: % perl Makefile.PL If you are lacking any of the prerequisite modules, running that program will tell you. All prerequisites are available from CPAN. When you have them all: % make && make test If there are any failures, it's best if you contact me. It may help other people who have the same problem. I don't tend to read the Perl newsgroups or PerlMonks, so it's no use posting there. When you report your trouble, be sure to send me the following information; + result of `perl -V' + output from 'make test' - ideally do 'make test TEST_VERBOSE=1 >& errs' Send those to bug-Test-CPAN-Meta-JSON@rt.cpan.org and I'll get back to you as soon as I'm able. If it worked, then become root and type: # make install Congratulations. You've just installed Test::CPAN::Meta::JSON. If you have a copy of cpantest installed, type: % cpantest -g pass -nc -p `basename \`pwd\`` -auto Or: % cpantest -g pass -nc -p Test-CPAN-Meta-JSON-0.10 -auto That will tell both me and other potential users that the module built correctly on your machine. Cheers, Barbie. http://www.missbarbell.co.uk/ Test-CPAN-Meta-JSON-0.16/Changes0000644000175000017500000000522212454444506015267 0ustar barbiebarbieChanges log for Test-CPAN-Meta-JSON =================================== 0.16 2015-01-14 - fixed license fields in META.json to be lists. - extended META test suite. - added '2.0' as an alias to '2' version spec. - license MUST be a list of strings. 0.15 2013-07-21 - change file dates changed to meet W3CDTF standards. 0.14 2012-08-12 - added minimum perl version (5.006). - reworked Makefile.PL for clarity. - implemented Perl::Critic suggestions. - added meta_json_ok test and example. - several Version.pm updates. 0.13 2012-04-19 - further spelling fix. (Florian Schlichting). - removed DSLIP info. 0.12 2012-04-17 - spelling fix. (thanks to Florian Schlichting & Gregor Herrmann). 0.11 2012-04-13 - RT#74317: imported url validation from CPAN::Meta (Alex Hartmaier). - RT#66692: updated license type (Paul Howarth). - updates to examples. 0.10 2011-02-13 - Distribution name change: Test-JSON-Meta => Test-CPAN-Meta-JSON. 0.09 2010-07-15 - simplified spec def error message (backported from CPAN-Meta). - simplified spec using "value = \&anything", thus providing better structure (backported from CPAN-Meta). - made keyword validation a little more strict. 0.08 2010-07-14 - added missing tests and samples. - Test::More version downgraded to 0.62. - JSON version upgraded to 2.15. 0.07 2010-04-20 - added spec definition validation. - updated distribution META.json to version 2. 0.06 2010-04-20 - upgraded code to CPAN-Meta-Spec version 2. - default version (if not specified) to check is now version 2. - split spec version testing into individual test files. - added tests and samples for version 2 testing. 0.05 2010-04-12 - fixed qr// delimiters due to issues with the NOT SIGN symbol (suggested by Ricardo Signes & David Golden). 0.04 2009-12-18 - renamed word() to keyword(). - added identifier() validation. - changed optional_features key from a keyword to an identifier type, thus further clarifying RT#52685 (thanks Kevin). 0.03 2009-12-12 - clarified spec defined and user defined keys, as promoted by Kevin Ryde in RT#52685 (thanks Kevin). 0.02 2009-12-07 - RT#46473: license url with fragment part (Kevin Ryde) - RT#47393: "optional_features" as map rather than list (Kevin Ryde) - above applied to 1.4, 1.3 and 1.2 version of the meta-spec. 0.01 2009-07-15 - Initial release. Test-CPAN-Meta-JSON-0.16/README0000644000175000017500000000423712454443616014662 0ustar barbiebarbieTest::CPAN::Meta::JSON ====================== DESCRIPTION Validation of the META.json file in a CPAN distribution. This module was written to ensure that a META.json file, provided with a standard distribution uploaded to CPAN, meets the specifications that are slowly being introduced to module uploads, via the use of package makers and installers such as ExtUtils::MakeMaker, Module::Build and Module::Install. Current CPAN META Specification, 2.0, was finally approved in April 2010, which forms the basis for the contents of a META.json file. The full specification is now included with the CPAN-Meta distribution. http://search.cpan.org/perldoc?CPAN::Meta DEPENDENCIES The distribution requires the following modules: JSON >= 2.15 Test::Builder >= 0 For testing purposes, the following modules are required: Test::More >= 0.62 For testing purposes, the following modules are desireable, but not essential: Test::More >= 0.70 Test::Pod >= 1.00 Test::Pod::Coverage >= 0.08 Pod::Coverage INSTALLATION To install this module type the following: perl Makefile.PL make make test make install For more detailed installation instructions, see INSTALL. USAGE Read the pod documentation in the distribution files. CHANGES For a complete list of changes, see the Changes file. SUPPORT There are no known bugs at the time of this release. However, if you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please send an email to barbie@cpan.org or submit a bug to the RT system (http://rt.cpan.org/Public/Dist/Display.html?Name=Test-CPAN-Meta-JSON). However, it would help greatly if you are able to pinpoint problems or even supply a patch. Fixes are dependent upon their severity and my availability. Should a fix not be forthcoming, please feel free to (politely) remind me. AUTHOR Barbie for Miss Barbell Productions http://www.missbarbell.co.uk. COPYRIGHT AND LICENSE Copyright (C) 2009-2015 Barbie for Miss Barbell Productions This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. Test-CPAN-Meta-JSON-0.16/t/0000755000175000017500000000000012454446444014241 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/t/01use.t0000644000175000017500000000023112011437311015335 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 2; BEGIN { use_ok( 'Test::CPAN::Meta::JSON' ); use_ok( 'Test::CPAN::Meta::JSON::Version' ); } Test-CPAN-Meta-JSON-0.16/t/12metaversion.t0000644000175000017500000001207212130266506017115 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 104; use Test::CPAN::Meta::JSON::Version; my $spec = Test::CPAN::Meta::JSON::Version->new(spec => '1.2'); is($spec->url('url','http://module-build.sourceforge.net/META-spec-v1.2.html'),1,'valid URL'); is($spec->url('url','http://'),0); is($spec->url('url','://module-build.sourceforge.net/META-spec-v1.2.html'),0); is($spec->url('url','test://'),0); is($spec->url('url','test^example^com'),0); is($spec->url('url',''),0); is($spec->url('url',undef),0); is($spec->url('url','http://www.gnu.org/licenses/#GPL'),1,'valid URL: http://www.gnu.org/licenses/#GPL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.2.html'),1,'valid specification URL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.1.html'),0); is($spec->urlspec('spec','test.html'),0); is($spec->urlspec('spec',''),0); is($spec->urlspec('spec',undef),0); is($spec->string('string','string'),1,'valid string'); is($spec->string('string','0'),1); is($spec->string('string',''),0); is($spec->string('string',undef),0); is($spec->string_or_undef('string_or_undef','string'),1,'valid string or undef'); is($spec->string_or_undef('string_or_undef','0'),1); is($spec->string_or_undef('string_or_undef',''),0); is($spec->string_or_undef('string_or_undef',undef),1); is($spec->file('file','file'),1,'valid file'); is($spec->file('file',''),1); is($spec->file('file',undef),0); is($spec->exversion('exversion','0'),1,'valid extended version'); is($spec->exversion('exversion','<= 5, >=2, ==3, !=4, >1, <6'),1); is($spec->exversion('exversion','='),0); is($spec->exversion('exversion',''),0); is($spec->exversion('exversion',undef),0); is($spec->exversion('exversion'),0); is($spec->version('version','0'),1,'valid basic version'); is($spec->version('version','0.00'),1); is($spec->version('version','0.00_00'),1); is($spec->version('version','0.0.0'),1); is($spec->version('version','v0.0.0'),1); is($spec->version('version','<6'),1); is($spec->version('version','!4'),0); is($spec->version('version',''),0); is($spec->version('version',undef),0); is($spec->version('version'),0); is($spec->boolean('boolean','0'),1, 'boolean = 0'); is($spec->boolean('boolean','1'),1, 'boolean = 1'); is($spec->boolean('boolean','true'),1, 'boolean = true'); is($spec->boolean('boolean','false'),1, 'boolean = false'); is($spec->boolean('boolean','blah'),0, 'boolean = blah'); is($spec->boolean('boolean',''),0, 'boolean = (blank)'); is($spec->boolean('boolean',undef),0, 'boolean = (undef value)'); is($spec->boolean('boolean'),0, 'boolean = (undef)'); for my $value (qw( perl gpl apache artistic artistic2 artistic-2.0 lgpl bsd gpl mit mozilla open_source unrestricted restrictive unknown )) { is($spec->license('license',$value),1,'license test = ' . $value); } is($spec->license('license','blah'),2); is($spec->license('license',''),0); is($spec->license('license',undef),0); is($spec->resource('MailListing'),1,'valid resource - CamelCase'); is($spec->resource('MAILListing'),1,'valid resource - Caps start'); is($spec->resource('mailLISTing'),1,'valid resource - Caps middle'); is($spec->resource('mailListing'),1,'valid resource - 1 cap middle'); is($spec->resource('maillisting'),0); is($spec->resource(''),0); is($spec->resource(undef),0); is($spec->keyword($_),1,"valid keyword $_") for(qw(test X_TEST x_test test-test test_test)); is($spec->keyword($_),0,"invalid keyword $_") for(qw(X-TEST Test TEST test:)); is($spec->keyword(''),0,'invalid keyword '); is($spec->keyword(undef),0,'invalid keyword '); is($spec->identifier($_),1,"valid identifier $_") for(qw(test Test TEST X_TEST x_test test_test)); is($spec->identifier($_),0,"invalid identifier $_") for(qw(X-TEST test-test test:)); is($spec->identifier(''),0,'invalid identifier '); is($spec->identifier(undef),0,'invalid identifier '); is($spec->module('Test'),1,'valid module name'); is($spec->module('Test::CPAN::Meta::JSON'),1); is($spec->module('Test-JSON-Meta'),0); is($spec->module(''),0); is($spec->module(undef),0); my $hash_spec = { file => { list => { value => 'string' } }, directory => { list => { value => 'string' } }, 'package' => { list => { value => 'string' } }, namespace => { list => { value => 'string' } }, }; my $list_spec = { value => 'string' }; my $hash_test = { 'directory' => [ 't', 'examples' ] }; my $list_test = [ 't', 'examples' ]; my $this = scalar($spec->errors); eval { $spec->check_map($hash_spec,$hash_test); }; my $that = scalar($spec->errors); is($that-$this,0, 'valid map check - hash vs hash'); $this = $that; eval { $spec->check_list($list_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,0, 'valid list check - array vs array'); $this = $that; eval { $spec->check_map($hash_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid map check - hash vs array'); $this = $that; eval { $spec->check_list($list_spec,$hash_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid list check - array vs hash'); Test-CPAN-Meta-JSON-0.16/t/02metafiles.t0000644000175000017500000001017112412204572016525 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 116; use Test::CPAN::Meta::JSON::Version; use IO::File; use JSON; # Version 1.3 Tests my $vers = '1.3'; my @tests = ( { file => 't/samples/00-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/01-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/02-META.json', fail => 1, errors => 2, bad => 1, faults => 10 }, { file => 't/samples/03-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/04-META.json', fail => 1, errors => 1, bad => 1, faults => 1 }, { file => 't/samples/05-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/06-META.json', fail => 1, errors => 3, bad => 1, faults => 3 }, { file => 't/samples/07-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/08-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/09-META.json', fail => 1, errors => 1, bad => 1, faults => 1 }, { file => 't/samples/10-META.json', fail => 1, errors => 1, bad => 1, faults => 1 }, { file => 't/samples/11-META.json', fail => 1, errors => 2, bad => 1, faults => 1 }, { file => 't/samples/12-META.json', fail => 1, errors => 1, bad => 1, faults => 9 }, { file => 't/samples/13-META.json', fail => 1, errors => 1, bad => 0, faults => 0 }, { file => 't/samples/14-META.json', fail => 1, errors => 1, bad => 0, faults => 0 }, { file => 't/samples/15-META.json', fail => 1, errors => 1, bad => 0, faults => 0 }, { file => 't/samples/16-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/multibyte.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/Template-Provider-Unicode-Japanese.json', fail => 0, errors => 0, bad => 0, faults => 0 }, ); runtests($vers,\@tests); # Version 2 tests $vers = '2'; @tests = ( { file => 't/samples/20-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, { file => 't/samples/21-META.json', fail => 1, errors => 2, bad => 1, faults => 2 }, { file => 't/samples/22-META.json', fail => 1, errors => 1, bad => 1, faults => 1 }, { file => 't/samples/23-META.json', fail => 1, errors => 1, bad => 1, faults => 1 }, { file => 't/samples/24-META.json', fail => 0, errors => 0, bad => 0, faults => 0 }, ); runtests($vers,\@tests); # Version 2.0 tests $vers = '2.0'; runtests($vers,\@tests); sub runtests { my ($vers,$tests) = @_; my @tests = @$tests; for my $test (@tests) { my $meta = _readdata($test->{file}); unless($meta) { ok(0,"Cannot load file - $test->{file}"); ok(0,"Cannot load file - $test->{file}"); next; } my $spec = Test::CPAN::Meta::JSON::Version->new(spec => $vers, data => $meta); my $result = $spec->parse(); my @errors = $spec->errors(); is($result, $test->{fail}, "'fail' check for $test->{file}"); is(scalar(@errors), $test->{errors}, "'errors' check for $test->{file}"); if(scalar(@errors) != $test->{errors}) { diag("failed: $test->{file}"); diag("errors: " . join("\n",@errors)); } } for my $test (@tests) { my $meta = _readdata($test->{file}); unless($meta) { ok(0,"Cannot load file - $test->{file}"); ok(0,"Cannot load file - $test->{file}"); next; } my $spec = Test::CPAN::Meta::JSON::Version->new(data => $meta); my $result = $spec->parse(); my @errors = $spec->errors(); is($result, $test->{bad}, "'bad' check for $test->{file}"); is(scalar(@errors), $test->{faults}, "'faults' check for $test->{file}"); if(scalar(@errors) != $test->{faults}) { diag("failed: $test->{file}"); diag("errors: " . join("\n",@errors)); } } } sub _readdata { my $file = shift; my $data; my $fh = IO::File->new($file,'r') or die "Cannot open file [$file]: $!"; while(<$fh>) { $data .= $_ } $fh->close; return decode_json($data); } Test-CPAN-Meta-JSON-0.16/t/96metatest.t0000644000175000017500000000176212412201457016424 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta::JSON"; plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@; plan 'no_plan'; my $meta = meta_spec_ok(undef,undef,@_); use Test::CPAN::Meta::JSON; my $version = $Test::CPAN::Meta::JSON::VERSION; is($meta->{version},$version, 'META.json distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.json entry [$mod] version matches distribution version"); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.json entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Test-CPAN-Meta-JSON-0.16/t/04metatester.t0000644000175000017500000000354612130266506016745 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::CPAN::Meta::JSON; use Test::Builder::Tester tests => 7; my $testfile = 't/samples/00-META.json'; die unless(-f $testfile); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('ok 2 - t/samples/00-META.json meets the designated specification (1.3)'); meta_spec_ok($testfile,'1.3'); test_test("$testfile with version 1.3"); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('not ok 2 - t/samples/00-META.json meets the designated specification (1.2)'); test_fail(2); test_err('# ERR: META.yml specification URL does not match version (meta-spec -> url) [Validation: 1.2]'); meta_spec_ok($testfile,'1.2'); test_test("$testfile with version 1.2"); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('ok 2 - t/samples/00-META.json meets the designated specification (1.1)'); meta_spec_ok($testfile,'1.1'); test_test("$testfile with version 1.1"); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('ok 2 - t/samples/00-META.json meets the designated specification (1.0)'); meta_spec_ok($testfile,'1.0'); test_test("$testfile with version 1.0"); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('ok 2 - t/samples/00-META.json meets the designated specification'); meta_spec_ok($testfile); test_test("$testfile with assumed (1.3) version"); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('ok 2 - my own test'); meta_spec_ok($testfile,undef,'my own test'); test_test("$testfile with assumed (1.3) version"); test_out('ok 1 - t/samples/00-META.json contains valid JSON'); test_out('not ok 2 - bad spec version'); test_fail(2); test_err('# ERR: Unknown META.yml specification, cannot validate. [Validation: 0.99]'); meta_spec_ok($testfile,'0.99','bad spec version'); test_test("$testfile with bad spec version 0.99"); Test-CPAN-Meta-JSON-0.16/t/11metaversion.t0000644000175000017500000001207212130266506017114 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 104; use Test::CPAN::Meta::JSON::Version; my $spec = Test::CPAN::Meta::JSON::Version->new(spec => '1.1'); is($spec->url('url','http://module-build.sourceforge.net/META-spec-v1.1.html'),1,'valid URL'); is($spec->url('url','http://'),0); is($spec->url('url','://module-build.sourceforge.net/META-spec-v1.1.html'),0); is($spec->url('url','test://'),0); is($spec->url('url','test^example^com'),0); is($spec->url('url',''),0); is($spec->url('url',undef),0); is($spec->url('url','http://www.gnu.org/licenses/#GPL'),1,'valid URL: http://www.gnu.org/licenses/#GPL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.1.html'),1,'valid specification URL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.2.html'),0); is($spec->urlspec('spec','test.html'),0); is($spec->urlspec('spec',''),0); is($spec->urlspec('spec',undef),0); is($spec->string('string','string'),1,'valid string'); is($spec->string('string','0'),1); is($spec->string('string',''),0); is($spec->string('string',undef),0); is($spec->string_or_undef('string_or_undef','string'),1,'valid string or undef'); is($spec->string_or_undef('string_or_undef','0'),1); is($spec->string_or_undef('string_or_undef',''),0); is($spec->string_or_undef('string_or_undef',undef),1); is($spec->file('file','file'),1,'valid file'); is($spec->file('file',''),1); is($spec->file('file',undef),0); is($spec->exversion('exversion','0'),1,'valid extended version'); is($spec->exversion('exversion','<= 5, >=2, ==3, !=4, >1, <6'),1); is($spec->exversion('exversion','='),0); is($spec->exversion('exversion',''),0); is($spec->exversion('exversion',undef),0); is($spec->exversion('exversion'),0); is($spec->version('version','0'),1,'valid basic version'); is($spec->version('version','0.00'),1); is($spec->version('version','0.00_00'),1); is($spec->version('version','0.0.0'),1); is($spec->version('version','v0.0.0'),1); is($spec->version('version','<6'),1); is($spec->version('version','!4'),0); is($spec->version('version',''),0); is($spec->version('version',undef),0); is($spec->version('version'),0); is($spec->boolean('boolean','0'),1, 'boolean = 0'); is($spec->boolean('boolean','1'),1, 'boolean = 1'); is($spec->boolean('boolean','true'),1, 'boolean = true'); is($spec->boolean('boolean','false'),1, 'boolean = false'); is($spec->boolean('boolean','blah'),0, 'boolean = blah'); is($spec->boolean('boolean',''),0, 'boolean = (blank)'); is($spec->boolean('boolean',undef),0, 'boolean = (undef value)'); is($spec->boolean('boolean'),0, 'boolean = (undef)'); for my $value (qw( perl gpl apache artistic artistic2 artistic-2.0 lgpl bsd gpl mit mozilla open_source unrestricted restrictive unknown )) { is($spec->license('license',$value),1,'license test = ' . $value); } is($spec->license('license','blah'),2); is($spec->license('license',''),0); is($spec->license('license',undef),0); is($spec->resource('MailListing'),1,'valid resource - CamelCase'); is($spec->resource('MAILListing'),1,'valid resource - Caps start'); is($spec->resource('mailLISTing'),1,'valid resource - Caps middle'); is($spec->resource('mailListing'),1,'valid resource - 1 cap middle'); is($spec->resource('maillisting'),0); is($spec->resource(''),0); is($spec->resource(undef),0); is($spec->keyword($_),1,"valid keyword $_") for(qw(test X_TEST x_test test-test test_test)); is($spec->keyword($_),0,"invalid keyword $_") for(qw(X-TEST Test TEST test:)); is($spec->keyword(''),0,'invalid keyword '); is($spec->keyword(undef),0,'invalid keyword '); is($spec->identifier($_),1,"valid identifier $_") for(qw(test Test TEST X_TEST x_test test_test)); is($spec->identifier($_),0,"invalid identifier $_") for(qw(X-TEST test-test test:)); is($spec->identifier(''),0,'invalid identifier '); is($spec->identifier(undef),0,'invalid identifier '); is($spec->module('Test'),1,'valid module name'); is($spec->module('Test::CPAN::Meta::JSON'),1); is($spec->module('Test-JSON-Meta'),0); is($spec->module(''),0); is($spec->module(undef),0); my $hash_spec = { file => { list => { value => 'string' } }, directory => { list => { value => 'string' } }, 'package' => { list => { value => 'string' } }, namespace => { list => { value => 'string' } }, }; my $list_spec = { value => 'string' }; my $hash_test = { 'directory' => [ 't', 'examples' ] }; my $list_test = [ 't', 'examples' ]; my $this = scalar($spec->errors); eval { $spec->check_map($hash_spec,$hash_test); }; my $that = scalar($spec->errors); is($that-$this,0, 'valid map check - hash vs hash'); $this = $that; eval { $spec->check_list($list_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,0, 'valid list check - array vs array'); $this = $that; eval { $spec->check_map($hash_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid map check - hash vs array'); $this = $that; eval { $spec->check_list($list_spec,$hash_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid list check - array vs hash'); Test-CPAN-Meta-JSON-0.16/t/10metaversion.t0000644000175000017500000001207212130266506017113 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 104; use Test::CPAN::Meta::JSON::Version; my $spec = Test::CPAN::Meta::JSON::Version->new(spec => '1.0'); is($spec->url('url','http://module-build.sourceforge.net/META-spec-v1.0.html'),1,'valid URL'); is($spec->url('url','http://'),0); is($spec->url('url','://module-build.sourceforge.net/META-spec-v1.0.html'),0); is($spec->url('url','test://'),0); is($spec->url('url','test^example^com'),0); is($spec->url('url',''),0); is($spec->url('url',undef),0); is($spec->url('url','http://www.gnu.org/licenses/#GPL'),1,'valid URL: http://www.gnu.org/licenses/#GPL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.0.html'),1,'valid specification URL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.2.html'),0); is($spec->urlspec('spec','test.html'),0); is($spec->urlspec('spec',''),0); is($spec->urlspec('spec',undef),0); is($spec->string('string','string'),1,'valid string'); is($spec->string('string','0'),1); is($spec->string('string',''),0); is($spec->string('string',undef),0); is($spec->string_or_undef('string_or_undef','string'),1,'valid string or undef'); is($spec->string_or_undef('string_or_undef','0'),1); is($spec->string_or_undef('string_or_undef',''),0); is($spec->string_or_undef('string_or_undef',undef),1); is($spec->file('file','file'),1,'valid file'); is($spec->file('file',''),1); is($spec->file('file',undef),0); is($spec->exversion('exversion','0'),1,'valid extended version'); is($spec->exversion('exversion','<= 5, >=2, ==3, !=4, >1, <6'),1); is($spec->exversion('exversion','='),0); is($spec->exversion('exversion',''),0); is($spec->exversion('exversion',undef),0); is($spec->exversion('exversion'),0); is($spec->version('version','0'),1,'valid basic version'); is($spec->version('version','0.00'),1); is($spec->version('version','0.00_00'),1); is($spec->version('version','0.0.0'),1); is($spec->version('version','v0.0.0'),1); is($spec->version('version','<6'),1); is($spec->version('version','!4'),0); is($spec->version('version',''),0); is($spec->version('version',undef),0); is($spec->version('version'),0); is($spec->boolean('boolean','0'),1, 'boolean = 0'); is($spec->boolean('boolean','1'),1, 'boolean = 1'); is($spec->boolean('boolean','true'),1, 'boolean = true'); is($spec->boolean('boolean','false'),1, 'boolean = false'); is($spec->boolean('boolean','blah'),0, 'boolean = blah'); is($spec->boolean('boolean',''),0, 'boolean = (blank)'); is($spec->boolean('boolean',undef),0, 'boolean = (undef value)'); is($spec->boolean('boolean'),0, 'boolean = (undef)'); for my $value (qw( perl gpl apache artistic artistic2 artistic-2.0 lgpl bsd gpl mit mozilla open_source unrestricted restrictive unknown )) { is($spec->license('license',$value),1,'license test = ' . $value); } is($spec->license('license','blah'),2); is($spec->license('license',''),0); is($spec->license('license',undef),0); is($spec->resource('MailListing'),1,'valid resource - CamelCase'); is($spec->resource('MAILListing'),1,'valid resource - Caps start'); is($spec->resource('mailLISTing'),1,'valid resource - Caps middle'); is($spec->resource('mailListing'),1,'valid resource - 1 cap middle'); is($spec->resource('maillisting'),0); is($spec->resource(''),0); is($spec->resource(undef),0); is($spec->keyword($_),1,"valid keyword $_") for(qw(test X_TEST x_test test-test test_test)); is($spec->keyword($_),0,"invalid keyword $_") for(qw(X-TEST Test TEST test:)); is($spec->keyword(''),0,'invalid keyword '); is($spec->keyword(undef),0,'invalid keyword '); is($spec->identifier($_),1,"valid identifier $_") for(qw(test Test TEST X_TEST x_test test_test)); is($spec->identifier($_),0,"invalid identifier $_") for(qw(X-TEST test-test test:)); is($spec->identifier(''),0,'invalid identifier '); is($spec->identifier(undef),0,'invalid identifier '); is($spec->module('Test'),1,'valid module name'); is($spec->module('Test::CPAN::Meta::JSON'),1); is($spec->module('Test-JSON-Meta'),0); is($spec->module(''),0); is($spec->module(undef),0); my $hash_spec = { file => { list => { value => 'string' } }, directory => { list => { value => 'string' } }, 'package' => { list => { value => 'string' } }, namespace => { list => { value => 'string' } }, }; my $list_spec = { value => 'string' }; my $hash_test = { 'directory' => [ 't', 'examples' ] }; my $list_test = [ 't', 'examples' ]; my $this = scalar($spec->errors); eval { $spec->check_map($hash_spec,$hash_test); }; my $that = scalar($spec->errors); is($that-$this,0, 'valid map check - hash vs hash'); $this = $that; eval { $spec->check_list($list_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,0, 'valid list check - array vs array'); $this = $that; eval { $spec->check_map($hash_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid map check - hash vs array'); $this = $that; eval { $spec->check_list($list_spec,$hash_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid list check - array vs hash'); Test-CPAN-Meta-JSON-0.16/t/95changedate.t0000644000175000017500000000232712130266373016663 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use IO::File; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); my $fh = IO::File->new('Changes','r') or plan skip_all => "Cannot open Changes file"; plan 'no_plan'; use Test::CPAN::Meta::JSON; my $version = $Test::CPAN::Meta::JSON::VERSION; my $latest = 0; while(<$fh>) { next unless(m!^\d!); $latest = 1 if(m!^$version!); # 2012-08-26T01:02 or 2012-08-26T01:02:03 or 2012-08-26T01:02:03.04 or 2012-08-26T01:02+01:00 like($_, qr!^ \d[\d._]+\s+ # version ( \d{4}-\d{2}-\d{2} # 2012-08-26 - YYYY-MM-DD ( T\d{2}:\d{2} # T01:02 - Thh:mm ( :\d{2} # :02 - :ss ( \.\d+ # .2 - .ss (microseconds) )? )? ( (Z|[-+]\d+:\d+) # +01:00 - timezone )? )? ) \s*$!x,'... version has a date'); } is($latest,1,'... latest version not listed'); Test-CPAN-Meta-JSON-0.16/t/samples/0000755000175000017500000000000012454446444015705 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/t/samples/04-META.json0000644000175000017500000000171711525734760017554 0ustar barbiebarbie{ "name": "Test-YAML-Meta", "version": "0.01", "abstract": "A test module to validate a META.yml file.", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": "", "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/07-META.json0000644000175000017500000000270011525734760017550 0ustar barbiebarbie{ "name": "Test", "version": "0.01_01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0", "optional_features": {"foo": { "description": "test", "requires_packages": "test", "requires_os": "test", "excludes_os": "test", "requires": { "Test::More": "0.47" }, "recommends": { "Test::More": "0.47" }, "build_requires": { "Test::More": "0.47" }, "conflicts": { "Test::More": "0.47" } }} } Test-CPAN-Meta-JSON-0.16/t/samples/06-META.json0000644000175000017500000000156211525734760017554 0ustar barbiebarbie{ "name": "Test", "version": "0.01_01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test-More": "0.47" }, "recommends": { "Test-More": "0.47" }, "build_requires": { "Test-More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/21-META.json0000644000175000017500000000373411525734760017554 0ustar barbiebarbie{ "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "generated_by" : "Module::Build version 0.36", "meta-spec" : { "version" : "2", "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" }, "version" : "0.36", "name" : "Module-Build", "dynamic_config" : 1, "author" : [ "Ken Williams ", "Module-Build List " ], "release_status" : "stable", "license" : [ "perl_5" ], "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", "keywords" : [ "toolchain", "cpan", "dual-life" ], "prereqs" : { "runtime" : { "requires" : { "File::Copy" : "0", "IO::File" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "Config" : "0", "ExtUtils::Install" : "0", "perl" : "5.006", "File::Compare" : "0", "File::Find" : "0", "File::Path" : "0", "File::Basename" : "0", "Cwd" : "0" }, "illegal" : { "YAML" : "0.35", "ExtUtils::ParseXS" : "2.02", "Pod::Text" : "0", "ExtUtils::Install" : "0.3", "Archive::Tar" : "1.00" } }, "nonexistent" : { "requires" : { "Test::More" : "0" } } }, "optional_features" : { "domination" : { "prereqs" : { "develop" : { "requires" : { "Genius::Evil" : "1.234" } }, "runtime" : { "requires" : { "Machine::Weather" : "2.0" } } }, "description" : "Take over the world" } }, "abstract" : "Build and install Perl modules" } Test-CPAN-Meta-JSON-0.16/t/samples/24-META.json0000644000175000017500000000372012454445105017544 0ustar barbiebarbie{ "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "generated_by" : "Module::Build version 0.36", "meta-spec" : { "version" : "2", "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" }, "version" : "0.36", "name" : "Module-Build", "dynamic_config" : 1, "author" : [ "Ken Williams ", "Module-Build List " ], "release_status" : "stable", "license" : [ "perl_5" ], "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", "keywords" : [ "toolchain", "cpan", "dual-life" ], "prereqs" : { "runtime" : { "requires" : { "File::Copy" : "0", "IO::File" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "Config" : "0", "ExtUtils::Install" : "0", "perl" : "5.006", "File::Compare" : "0", "File::Find" : "0", "File::Path" : "0", "File::Basename" : "0", "Cwd" : "0" }, "recommends" : { "YAML" : "0.35", "ExtUtils::ParseXS" : "2.02", "Pod::Text" : "0", "ExtUtils::Install" : "0.3", "Archive::Tar" : "1.00" } }, "build" : { "requires" : { "Test::More" : "0" } } }, "optional_features" : { "domination" : { "prereqs" : { "develop" : { "requires" : { "Genius::Evil" : "1.234" } }, "runtime" : { "requires" : { "Machine::Weather" : "2.0" } } }, "description" : "Take over the world" } }, "abstract" : "Build and install Perl modules" } Test-CPAN-Meta-JSON-0.16/t/samples/02-META.json0000644000175000017500000000160011525734760017541 0ustar barbiebarbie{ "name": "Test-YAML-Meta", "version": "0.01", "abstract": "A test module to validate a META.yml file.", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] } }Test-CPAN-Meta-JSON-0.16/t/samples/23-META.json0000644000175000017500000000370212011437450017534 0ustar barbiebarbie{ "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "generated_by" : "Module::Build version 0.36", "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" }, "version" : "0.36", "name" : "Module-Build", "dynamic_config" : 1, "author" : [ "Ken Williams ", "Module-Build List " ], "release_status" : "stable", "license" : [ "perl_5" ], "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", "keywords" : [ "toolchain", "cpan", "dual-life" ], "prereqs" : { "runtime" : { "requires" : { "File::Copy" : "0", "IO::File" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "Config" : "0", "ExtUtils::Install" : "0", "perl" : "5.006", "File::Compare" : "0", "File::Find" : "0", "File::Path" : "0", "File::Basename" : "0", "Cwd" : "0" }, "recommends" : { "YAML" : "0.35", "ExtUtils::ParseXS" : "2.02", "Pod::Text" : "0", "ExtUtils::Install" : "0.3", "Archive::Tar" : "1.00" } }, "build" : { "requires" : { "Test::More" : "0" } } }, "optional_features" : { "domination" : { "prereqs" : { "develop" : { "requires" : { "Genius::Evil" : "1.234" } }, "runtime" : { "requires" : { "Machine::Weather" : "2.0" } } }, "description" : "Take over the world" } }, "abstract" : "Build and install Perl modules" } Test-CPAN-Meta-JSON-0.16/t/samples/09-META.json0000644000175000017500000000231111525734760017550 0ustar barbiebarbie{ "name": "Test", "version": "0.01_01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0", "resources": { "license": "test://", "homepage": "http://test.example.com", "bugtracker": "http://test.example.com", "repository": "http://test.example.com" } } Test-CPAN-Meta-JSON-0.16/t/samples/16-META.json0000644000175000017500000000177611525734760017564 0ustar barbiebarbie{ "name": "Test", "version": "0.01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/08-META.json0000644000175000017500000000233211525734760017552 0ustar barbiebarbie{ "name": "Test", "version": "0.01_01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0", "resources": { "license": "http://test.example.com", "homepage": "http://test.example.com", "bugtracker": "http://test.example.com", "repository": "http://test.example.com" } } Test-CPAN-Meta-JSON-0.16/t/samples/11-META.json0000644000175000017500000000131311525734760017542 0ustar barbiebarbie{ "name": "PerlPoint-Package", "version": "0.46", "abstract": "A framework to write PerlPoint converters.", "author": "Jochen Stenzel (perl@jochen-stenzel.de)", "license": "artistic", "distribution_type": "module", "requires": { "Digest::SHA1": "1", "File::Spec": "0.8", "File::Temp": "0.12", "Getopt::Long": "2.24", "IO::File": "1", "Pod::Simple": "3.02", "Storable": "1", "Test::Harness": "1.25", "Test::More": "0.11" }, "meta-spec": { "version": "1.2", "url": "http://module-build.sourceforge.net/META-spec-v1.2.html" }, "generated_by": "ExtUtils::MakeMaker version 6.32" } Test-CPAN-Meta-JSON-0.16/t/samples/15-META.json0000644000175000017500000000177611525734760017563 0ustar barbiebarbie{ "name": "Test", "version": "0.01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.2", "url": "http://module-build.sourceforge.net/META-spec-v1.2.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/00-META.json0000644000175000017500000000204211525734760017540 0ustar barbiebarbie{ "name": "Test-YAML-Meta", "version": "0.01", "abstract": "A test module to validate a META.yml file.", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/12-META.json0000644000175000017500000000164311525734760017551 0ustar barbiebarbie{ "name": "Test-YAML-Meta", "version": "0.01", "abstract": "A test module to validate a META.yml file.", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/05-META.json0000644000175000017500000000047211525734760017552 0ustar barbiebarbie{ "name": "Test", "version": "0.01_01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/multibyte.json0000644000175000017500000000122311525734760020613 0ustar barbiebarbie{ "abstract": "Perl-compatible regular expression engine", "author": ["Ævar Arnfjörð Bjarmason "], "build_requires": { "Config": "0", "Test::More": "0", "XSLoader": "0" }, "distribution_type": "module", "generated_by": "Module::Install version 0.65", "license": "perl", "meta-spec": { "url": "http://module-build.sourceforge.net/META-spec-v1.3.html", "version": "1.3" }, "name": "re-engine-PCRE", "no_index": { "directory": ["inc","t"] }, "requires": { "perl": "5.9.5" }, "tests": "t/*.t t/*/*.t", "version": "0.10" } Test-CPAN-Meta-JSON-0.16/t/samples/22-META.json0000644000175000017500000000364711525734760017560 0ustar barbiebarbie{ "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "meta-spec" : { "version" : "2", "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" }, "version" : "0.36", "name" : "Module-Build", "dynamic_config" : 1, "author" : [ "Ken Williams ", "Module-Build List " ], "release_status" : "stable", "license" : [ "perl_5" ], "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", "keywords" : [ "toolchain", "cpan", "dual-life" ], "prereqs" : { "runtime" : { "requires" : { "File::Copy" : "0", "IO::File" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "Config" : "0", "ExtUtils::Install" : "0", "perl" : "5.006", "File::Compare" : "0", "File::Find" : "0", "File::Path" : "0", "File::Basename" : "0", "Cwd" : "0" }, "recommends" : { "YAML" : "0.35", "ExtUtils::ParseXS" : "2.02", "Pod::Text" : "0", "ExtUtils::Install" : "0.3", "Archive::Tar" : "1.00" } }, "build" : { "requires" : { "Test::More" : "0" } } }, "optional_features" : { "domination" : { "prereqs" : { "develop" : { "requires" : { "Genius::Evil" : "1.234" } }, "runtime" : { "requires" : { "Machine::Weather" : "2.0" } } }, "description" : "Take over the world" } }, "abstract" : "Build and install Perl modules" } Test-CPAN-Meta-JSON-0.16/t/samples/Template-Provider-Unicode-Japanese.json0000644000175000017500000000117111525734760025252 0ustar barbiebarbie{ "abstract": "Decode all templates by Unicode::Japanese", "author": ["Hironori Yoshida C<< >>"], "distribution_type": "module", "generated_by": "Module::Install version 0.65", "license": "perl", "meta-spec": { "url": "http://module-build.sourceforge.net/META-spec-v1.3.html", "version": "1.3" }, "name": "Template-Provider-Unicode-Japanese", "no_index": { "directory": ["inc","t"] }, "requires": { "Template::Config": "0", "Unicode::Japanese": "0", "perl": "5.6.0", "version": "0" }, "version": "1.2.1" } Test-CPAN-Meta-JSON-0.16/t/samples/01-META.json0000644000175000017500000000225711525734760017551 0ustar barbiebarbie{ "name": "Test-YAML-Meta", "version": "0.01", "abstract": "A test module to validate a META.yml file.", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" }, "32Test::_YAML24::MetaVersion": { "file": "lib/32Test/_YAML24/MetaVersion.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/10-META.json0000644000175000017500000000177611525734760017556 0ustar barbiebarbie{ "name": "Test", "version": "test", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/03-META.json0000644000175000017500000000204111525734760017542 0ustar barbiebarbie{ "name": "Test-YAML-Meta", "version": "0.01", "abstract": "A test module to validate a META.yml file.", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "private": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.3", "url": "http://module-build.sourceforge.net/META-spec-v1.3.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/20-META.json0000644000175000017500000000373111525734760017550 0ustar barbiebarbie{ "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "generated_by" : "Module::Build version 0.36", "meta-spec" : { "version" : "2", "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" }, "version" : "0.36", "name" : "Module-Build", "dynamic_config" : 1, "author" : [ "Ken Williams ", "Module-Build List " ], "release_status" : "stable", "license" : [ "perl_5" ], "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", "keywords" : [ "toolchain", "cpan", "dual-life" ], "prereqs" : { "runtime" : { "requires" : { "File::Copy" : "0", "IO::File" : "0", "Data::Dumper" : "0", "File::Spec" : "0", "Config" : "0", "ExtUtils::Install" : "0", "perl" : "5.006", "File::Compare" : "0", "File::Find" : "0", "File::Path" : "0", "File::Basename" : "0", "Cwd" : "0" }, "recommends" : { "YAML" : "0.35", "ExtUtils::ParseXS" : "2.02", "Pod::Text" : "0", "ExtUtils::Install" : "0.3", "Archive::Tar" : "1.00" } }, "build" : { "requires" : { "Test::More" : "0" } } }, "optional_features" : { "domination" : { "prereqs" : { "develop" : { "requires" : { "Genius::Evil" : "1.234" } }, "runtime" : { "requires" : { "Machine::Weather" : "2.0" } } }, "description" : "Take over the world" } }, "abstract" : "Build and install Perl modules" } Test-CPAN-Meta-JSON-0.16/t/samples/14-META.json0000644000175000017500000000177611525734760017562 0ustar barbiebarbie{ "name": "Test", "version": "0.01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.1", "url": "http://module-build.sourceforge.net/META-spec-v1.1.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/samples/13-META.json0000644000175000017500000000177611525734760017561 0ustar barbiebarbie{ "name": "Test", "version": "0.01", "abstract": "brief test file", "author": ["Barbie "], "license": "perl", "distribution_type": "module", "installdirs": "site", "requires": { "Test::YAML::Valid": "0", "Test::More": "0.47" }, "recommends": { "Test::More": "0.47", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08", "Test::YAML::Valid": "0.03" }, "build_requires": { "Test::More": "0.47" }, "provides": { "Test::YAML::Meta": { "file": "lib/Test/YAML/Meta.pm", "version": "0.01" }, "Test::YAML::Meta::Version": { "file": "lib/Test/YAML/Meta/Version.pm", "version": "0.01" } }, "no_index": { "directory": ["t", "examples"] }, "meta-spec": { "version": "1.0", "url": "http://module-build.sourceforge.net/META-spec-v1.0.html" }, "generated_by": "Hand 1.0" } Test-CPAN-Meta-JSON-0.16/t/14metaversion.t0000644000175000017500000001207212130266506017117 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 104; use Test::CPAN::Meta::JSON::Version; my $spec = Test::CPAN::Meta::JSON::Version->new(spec => '1.4'); is($spec->url('url','http://module-build.sourceforge.net/META-spec-v1.4.html'),1,'valid URL'); is($spec->url('url','http://'),0); is($spec->url('url','://module-build.sourceforge.net/META-spec-v1.4.html'),0); is($spec->url('url','test://'),0); is($spec->url('url','test^example^com'),0); is($spec->url('url',''),0); is($spec->url('url',undef),0); is($spec->url('url','http://www.gnu.org/licenses/#GPL'),1,'valid URL: http://www.gnu.org/licenses/#GPL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.4.html'),1,'valid specification URL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.2.html'),0); is($spec->urlspec('spec','test.html'),0); is($spec->urlspec('spec',''),0); is($spec->urlspec('spec',undef),0); is($spec->string('string','string'),1,'valid string'); is($spec->string('string','0'),1); is($spec->string('string',''),0); is($spec->string('string',undef),0); is($spec->string_or_undef('string_or_undef','string'),1,'valid string or undef'); is($spec->string_or_undef('string_or_undef','0'),1); is($spec->string_or_undef('string_or_undef',''),0); is($spec->string_or_undef('string_or_undef',undef),1); is($spec->file('file','file'),1,'valid file'); is($spec->file('file',''),1); is($spec->file('file',undef),0); is($spec->exversion('exversion','0'),1,'valid extended version'); is($spec->exversion('exversion','<= 5, >=2, ==3, !=4, >1, <6'),1); is($spec->exversion('exversion','='),0); is($spec->exversion('exversion',''),0); is($spec->exversion('exversion',undef),0); is($spec->exversion('exversion'),0); is($spec->version('version','0'),1,'valid basic version'); is($spec->version('version','0.00'),1); is($spec->version('version','0.00_00'),1); is($spec->version('version','0.0.0'),1); is($spec->version('version','v0.0.0'),1); is($spec->version('version','<6'),1); is($spec->version('version','!4'),0); is($spec->version('version',''),0); is($spec->version('version',undef),0); is($spec->version('version'),0); is($spec->boolean('boolean','0'),1, 'boolean = 0'); is($spec->boolean('boolean','1'),1, 'boolean = 1'); is($spec->boolean('boolean','true'),1, 'boolean = true'); is($spec->boolean('boolean','false'),1, 'boolean = false'); is($spec->boolean('boolean','blah'),0, 'boolean = blah'); is($spec->boolean('boolean',''),0, 'boolean = (blank)'); is($spec->boolean('boolean',undef),0, 'boolean = (undef value)'); is($spec->boolean('boolean'),0, 'boolean = (undef)'); for my $value (qw( perl gpl apache artistic artistic2 artistic-2.0 lgpl bsd gpl mit mozilla open_source unrestricted restrictive unknown )) { is($spec->license('license',$value),1,'license test = ' . $value); } is($spec->license('license','blah'),2); is($spec->license('license',''),0); is($spec->license('license',undef),0); is($spec->resource('MailListing'),1,'valid resource - CamelCase'); is($spec->resource('MAILListing'),1,'valid resource - Caps start'); is($spec->resource('mailLISTing'),1,'valid resource - Caps middle'); is($spec->resource('mailListing'),1,'valid resource - 1 cap middle'); is($spec->resource('maillisting'),0); is($spec->resource(''),0); is($spec->resource(undef),0); is($spec->keyword($_),1,"valid keyword $_") for(qw(test X_TEST x_test test-test test_test)); is($spec->keyword($_),0,"invalid keyword $_") for(qw(X-TEST Test TEST test:)); is($spec->keyword(''),0,'invalid keyword '); is($spec->keyword(undef),0,'invalid keyword '); is($spec->identifier($_),1,"valid identifier $_") for(qw(test Test TEST X_TEST x_test test_test)); is($spec->identifier($_),0,"invalid identifier $_") for(qw(X-TEST test-test test:)); is($spec->identifier(''),0,'invalid identifier '); is($spec->identifier(undef),0,'invalid identifier '); is($spec->module('Test'),1,'valid module name'); is($spec->module('Test::CPAN::Meta::JSON'),1); is($spec->module('Test-JSON-Meta'),0); is($spec->module(''),0); is($spec->module(undef),0); my $hash_spec = { file => { list => { value => 'string' } }, directory => { list => { value => 'string' } }, 'package' => { list => { value => 'string' } }, namespace => { list => { value => 'string' } }, }; my $list_spec = { value => 'string' }; my $hash_test = { 'directory' => [ 't', 'examples' ] }; my $list_test = [ 't', 'examples' ]; my $this = scalar($spec->errors); eval { $spec->check_map($hash_spec,$hash_test); }; my $that = scalar($spec->errors); is($that-$this,0, 'valid map check - hash vs hash'); $this = $that; eval { $spec->check_list($list_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,0, 'valid list check - array vs array'); $this = $that; eval { $spec->check_map($hash_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid map check - hash vs array'); $this = $that; eval { $spec->check_list($list_spec,$hash_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid list check - array vs hash'); Test-CPAN-Meta-JSON-0.16/t/91podcover.t0000644000175000017500000000051312011435337016404 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::Pod::Coverage 0.08"; plan skip_all => "Test::Pod::Coverage 0.08 required for testing POD coverage" if $@; all_pod_coverage_ok(); Test-CPAN-Meta-JSON-0.16/t/13metaversion.t0000644000175000017500000001207212130266506017116 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 104; use Test::CPAN::Meta::JSON::Version; my $spec = Test::CPAN::Meta::JSON::Version->new(spec => '1.3'); is($spec->url('url','http://module-build.sourceforge.net/META-spec-v1.3.html'),1,'valid URL'); is($spec->url('url','http://'),0); is($spec->url('url','://module-build.sourceforge.net/META-spec-v1.3.html'),0); is($spec->url('url','test://'),0); is($spec->url('url','test^example^com'),0); is($spec->url('url',''),0); is($spec->url('url',undef),0); is($spec->url('url','http://www.gnu.org/licenses/#GPL'),1,'valid URL: http://www.gnu.org/licenses/#GPL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.3.html'),1,'valid specification URL'); is($spec->urlspec('spec','http://module-build.sourceforge.net/META-spec-v1.2.html'),0); is($spec->urlspec('spec','test.html'),0); is($spec->urlspec('spec',''),0); is($spec->urlspec('spec',undef),0); is($spec->string('string','string'),1,'valid string'); is($spec->string('string','0'),1); is($spec->string('string',''),0); is($spec->string('string',undef),0); is($spec->string_or_undef('string_or_undef','string'),1,'valid string or undef'); is($spec->string_or_undef('string_or_undef','0'),1); is($spec->string_or_undef('string_or_undef',''),0); is($spec->string_or_undef('string_or_undef',undef),1); is($spec->file('file','file'),1,'valid file'); is($spec->file('file',''),1); is($spec->file('file',undef),0); is($spec->exversion('exversion','0'),1,'valid extended version'); is($spec->exversion('exversion','<= 5, >=2, ==3, !=4, >1, <6'),1); is($spec->exversion('exversion','='),0); is($spec->exversion('exversion',''),0); is($spec->exversion('exversion',undef),0); is($spec->exversion('exversion'),0); is($spec->version('version','0'),1,'valid basic version'); is($spec->version('version','0.00'),1); is($spec->version('version','0.00_00'),1); is($spec->version('version','0.0.0'),1); is($spec->version('version','v0.0.0'),1); is($spec->version('version','<6'),1); is($spec->version('version','!4'),0); is($spec->version('version',''),0); is($spec->version('version',undef),0); is($spec->version('version'),0); is($spec->boolean('boolean','0'),1, 'boolean = 0'); is($spec->boolean('boolean','1'),1, 'boolean = 1'); is($spec->boolean('boolean','true'),1, 'boolean = true'); is($spec->boolean('boolean','false'),1, 'boolean = false'); is($spec->boolean('boolean','blah'),0, 'boolean = blah'); is($spec->boolean('boolean',''),0, 'boolean = (blank)'); is($spec->boolean('boolean',undef),0, 'boolean = (undef value)'); is($spec->boolean('boolean'),0, 'boolean = (undef)'); for my $value (qw( perl gpl apache artistic artistic2 artistic-2.0 lgpl bsd gpl mit mozilla open_source unrestricted restrictive unknown )) { is($spec->license('license',$value),1,'license test = ' . $value); } is($spec->license('license','blah'),2); is($spec->license('license',''),0); is($spec->license('license',undef),0); is($spec->resource('MailListing'),1,'valid resource - CamelCase'); is($spec->resource('MAILListing'),1,'valid resource - Caps start'); is($spec->resource('mailLISTing'),1,'valid resource - Caps middle'); is($spec->resource('mailListing'),1,'valid resource - 1 cap middle'); is($spec->resource('maillisting'),0); is($spec->resource(''),0); is($spec->resource(undef),0); is($spec->keyword($_),1,"valid keyword $_") for(qw(test X_TEST x_test test-test test_test)); is($spec->keyword($_),0,"invalid keyword $_") for(qw(X-TEST Test TEST test:)); is($spec->keyword(''),0,'invalid keyword '); is($spec->keyword(undef),0,'invalid keyword '); is($spec->identifier($_),1,"valid identifier $_") for(qw(test Test TEST X_TEST x_test test_test)); is($spec->identifier($_),0,"invalid identifier $_") for(qw(X-TEST test-test test:)); is($spec->identifier(''),0,'invalid identifier '); is($spec->identifier(undef),0,'invalid identifier '); is($spec->module('Test'),1,'valid module name'); is($spec->module('Test::CPAN::Meta::JSON'),1); is($spec->module('Test-JSON-Meta'),0); is($spec->module(''),0); is($spec->module(undef),0); my $hash_spec = { file => { list => { value => 'string' } }, directory => { list => { value => 'string' } }, 'package' => { list => { value => 'string' } }, namespace => { list => { value => 'string' } }, }; my $list_spec = { value => 'string' }; my $hash_test = { 'directory' => [ 't', 'examples' ] }; my $list_test = [ 't', 'examples' ]; my $this = scalar($spec->errors); eval { $spec->check_map($hash_spec,$hash_test); }; my $that = scalar($spec->errors); is($that-$this,0, 'valid map check - hash vs hash'); $this = $that; eval { $spec->check_list($list_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,0, 'valid list check - array vs array'); $this = $that; eval { $spec->check_map($hash_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid map check - hash vs array'); $this = $that; eval { $spec->check_list($list_spec,$hash_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid list check - array vs hash'); Test-CPAN-Meta-JSON-0.16/t/97metatest.t0000644000175000017500000000050412011436515016416 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta::JSON"; plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@; meta_json_ok(); Test-CPAN-Meta-JSON-0.16/t/05metaspec.t0000644000175000017500000000044212011465143016356 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 3; use Test::CPAN::Meta::JSON; my $vers = '1.3'; my $test = 't/samples/00-META.json'; my $meta = meta_spec_ok($test,$vers); #use Data::Dumper; #diag(Dumper($meta)); is($meta->{license}, 'perl', 'hash value for license matches'); Test-CPAN-Meta-JSON-0.16/t/20metaversion.t0000644000175000017500000001626612130266506017125 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More tests => 167; use Test::CPAN::Meta::JSON::Version; my $spec = Test::CPAN::Meta::JSON::Version->new(spec => '2'); is($spec->url('url','http://search.cpan.org/dist/CPAN-Meta/lib/CPAN/Meta/Spec.pm'),1,'valid URL'); is($spec->url('url','http://'),0); is($spec->url('url','://search.cpan.org/dist/CPAN-Meta/lib/CPAN/Meta/Spec.pm'),0); is($spec->url('url','test://'),0); is($spec->url('url','test^example^com'),0); is($spec->url('url',''),0); is($spec->url('url'),0); is($spec->url('url','http://www.gnu.org/licenses/#GPL'),1,'valid URL: http://www.gnu.org/licenses/#GPL'); is($spec->string('string','string'),1,'valid string'); is($spec->string('string','0'),1); is($spec->string('string',''),0); is($spec->string('string',undef),0); is($spec->string_or_undef('string_or_undef','string'),1,'valid string or undef'); is($spec->string_or_undef('string_or_undef','0'),1); is($spec->string_or_undef('string_or_undef',''),0); is($spec->string_or_undef('string_or_undef',undef),1); is($spec->file('file','file'),1,'valid file'); is($spec->file('file',''),1); is($spec->file('file',undef),0); is($spec->exversion('exversion','0'),1,'valid extended version'); is($spec->exversion('exversion','<= 5, >=2, ==3, !=4, >1, <6'),1); is($spec->exversion('exversion','='),0); is($spec->exversion('exversion',''),0); is($spec->exversion('exversion',undef),0); is($spec->exversion('exversion'),0); is($spec->version('version','0'),1,'valid basic version'); is($spec->version('version','0.00'),1); is($spec->version('version','0.00_00'),1); is($spec->version('version','0.0.0'),1); is($spec->version('version','v0.0.0'),1); is($spec->version('version','<6'),1); is($spec->version('version','!4'),0); is($spec->version('version',''),0); is($spec->version('version',undef),0); is($spec->version('version'),0); is($spec->boolean('boolean','0'),1, 'boolean = 0'); is($spec->boolean('boolean','1'),1, 'boolean = 1'); is($spec->boolean('boolean','true'),1, 'boolean = true'); is($spec->boolean('boolean','false'),1, 'boolean = false'); is($spec->boolean('boolean','blah'),0, 'boolean = blah'); is($spec->boolean('boolean',''),0, 'boolean = (blank)'); is($spec->boolean('boolean',undef),0, 'boolean = (undef value)'); is($spec->boolean('boolean'),0, 'boolean = (undef)'); for my $value (qw( agpl_3 apache_1_1 apache_2_0 artistic_1 artistic_2 bsd freebsd gfdl_1_2 gfdl_1_3 gpl_1 gpl_2 gpl_3 lgpl_2_1 lgpl_3_0 mit mozilla_1_0 mozilla_1_1 openssl perl_5 qpl_1_0 ssleay sun zlib open_source restricted unrestricted unknown )) { is($spec->license('license',$value),1,'license test = ' . $value); } is($spec->license('license','perl'),0); # no longer valid is($spec->license('license','blah'),0); is($spec->license('license',''),0); is($spec->license('license',undef),0); is($spec->resource('MailListing'),1,'valid resource - CamelCase'); is($spec->resource('MAILListing'),1,'valid resource - Caps start'); is($spec->resource('mailLISTing'),1,'valid resource - Caps middle'); is($spec->resource('mailListing'),1,'valid resource - 1 cap middle'); is($spec->resource('maillisting'),0); is($spec->resource('1234567890'),0); is($spec->resource(''),0); is($spec->resource(undef),0); is($spec->keyword($_),1,"valid keyword $_") for(qw(test X_TEST x_test test-test test_test)); is($spec->keyword($_),0,"invalid keyword $_") for(qw(X-TEST Test TEST test:)); is($spec->keyword(''),0,'invalid keyword '); is($spec->keyword(undef),0,'invalid keyword '); is($spec->identifier($_),1,"valid identifier $_") for(qw(test Test TEST X_TEST x_test test_test)); is($spec->identifier($_),0,"invalid identifier $_") for(qw(X-TEST test-test test:)); is($spec->identifier(''),0,'invalid identifier '); is($spec->identifier(undef),0,'invalid identifier '); is($spec->module('Test'),1,'valid module name'); is($spec->module('Test::CPAN::Meta::JSON'),1); is($spec->module('Test-JSON-Meta'),0); is($spec->module(''),0); is($spec->module(undef),0); $spec->{data}{version} = undef; is($spec->release_status('release_status',$_),1,"valid release_status $_") for(qw(stable testing unstable)); $spec->{data}{version} = '0.01'; is($spec->release_status('release_status',$_),1,"valid release_status $_") for(qw(stable testing unstable)); is($spec->release_status('release_status',$_),0,"invalid release_status $_") for(qw(X-TEST test-test test:)); is($spec->release_status('release_status',''),0,'invalid release_status '); is($spec->release_status('release_status',undef),0,'invalid irelease_statusdentifier '); $spec->{data}{version} = '0.01_01'; is($spec->release_status('release_status',$_),1,"valid development release_status $_") for(qw(testing unstable)); is($spec->release_status('release_status',$_),0,"invalid development release_status $_") for(qw(stable)); is($spec->custom_1($_),1,"valid custom_1 $_") for(qw(Test TEST)); is($spec->custom_1($_),0,"invalid custom_1 $_") for(qw(test X_TEST x_test test_test X-TEST test-test test:)); is($spec->custom_1(''),0,'invalid custom_1 '); is($spec->custom_1(undef),0,'invalid custom_1 '); is($spec->custom_2($_),1,"valid custom_2 $_") for(qw(X_TEST x_test)); is($spec->custom_2($_),0,"invalid custom_2 $_") for(qw(Test TEST X-TEST test_test test-test test:)); is($spec->custom_2(''),0,'invalid custom_2 '); is($spec->custom_2(undef),0,'invalid custom_2 '); is($spec->phase($_),1,"valid phase $_") for(qw(configure build test runtime develop)); is($spec->phase($_),0,"invalid phase $_") for(qw(X-TEST test-test test:)); is($spec->phase(''),0,'invalid phase '); is($spec->phase(undef),0,'invalid phase '); is($spec->relation($_),1,"valid relation $_") for(qw(requires recommends suggests conflicts)); is($spec->relation($_),0,"invalid relation $_") for(qw(X-TEST test-test test:)); is($spec->relation(''),0,'invalid relation '); is($spec->relation(undef),0,'invalid relation '); my $hash_spec = { file => { list => { value => 'string' } }, directory => { list => { value => 'string' } }, 'package' => { list => { value => 'string' } }, namespace => { list => { value => 'string' } }, }; my $list_spec = { value => 'string' }; my $hash_test = { 'directory' => [ 't', 'examples' ] }; my $list_test = [ 't', 'examples' ]; my $this = scalar($spec->errors); eval { $spec->check_map($hash_spec,$hash_test); }; my $that = scalar($spec->errors); is($that-$this,0, 'valid map check - hash vs hash'); $this = $that; eval { $spec->check_list($list_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,0, 'valid list check - array vs array'); $this = $that; eval { $spec->check_map($hash_spec,$list_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid map check - hash vs array'); $this = $that; eval { $spec->check_list($list_spec,$hash_test); }; $that = scalar($spec->errors); is($that-$this,1, 'invalid list check - array vs hash'); Test-CPAN-Meta-JSON-0.16/t/94metatest.t0000644000175000017500000000173412454444271016432 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; plan 'no_plan'; my $meta = meta_spec_ok(undef,undef,@_); use Test::CPAN::Meta::JSON; my $version = $Test::CPAN::Meta::JSON::VERSION; is($meta->{version},$version, 'META.yml distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.yml entry [$mod] version matches distribution version"); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.yml entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Test-CPAN-Meta-JSON-0.16/t/90podtest.t0000644000175000017500000000045312011544466016253 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Test-CPAN-Meta-JSON-0.16/lib/0000755000175000017500000000000012454446444014544 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/lib/Test/0000755000175000017500000000000012454446444015463 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/lib/Test/CPAN/0000755000175000017500000000000012454446444016204 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/lib/Test/CPAN/Meta/0000755000175000017500000000000012454446444017072 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/lib/Test/CPAN/Meta/JSON/0000755000175000017500000000000012454446444017643 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/lib/Test/CPAN/Meta/JSON/Version.pm0000644000175000017500000007650112454444506021634 0ustar barbiebarbiepackage Test::CPAN::Meta::JSON::Version; use warnings; use strict; use vars qw($VERSION); $VERSION = '0.16'; #---------------------------------------------------------------------------- =head1 NAME Test::CPAN::Meta::JSON::Version - Validate CPAN META data against the specification =head1 SYNOPSIS use Test::CPAN::Meta::JSON::Version; =head1 DESCRIPTION This module was written to ensure that a META.json file, provided with a standard distribution uploaded to CPAN, meets the specifications that are slowly being introduced to module uploads, via the use of L, L and L. This module is meant to be used together with L, however the code is self contained enough that you can access it directly. See L for further details of the CPAN Meta Specification. =head1 ABSTRACT Validation of META.json data against the CPAN Meta Specification. =cut #---------------------------------------------------------------------------- ############################################################################# #Specification Definitions # ############################################################################# my $spec_error = "Missing validation action in specification. " . "Must be one of 'map', 'list', 'lazylist' or 'value'"; my %known_specs = ( '1.4' => 'http://module-build.sourceforge.net/META-spec-v1.4.html', '1.3' => 'http://module-build.sourceforge.net/META-spec-v1.3.html', '1.2' => 'http://module-build.sourceforge.net/META-spec-v1.2.html', '1.1' => 'http://module-build.sourceforge.net/META-spec-v1.1.html', '1.0' => 'http://module-build.sourceforge.net/META-spec-v1.0.html' ); my %known_urls = map {$known_specs{$_} => $_} keys %known_specs; my $module_map1 = { 'map' => { ':key' => { name => \&module, value => \&exversion } } }; my $module_map2 = { 'map' => { ':key' => { name => \&module, value => \&version } } }; my $no_index_1_3 = { 'map' => { file => { list => { value => \&string } }, directory => { list => { value => \&string } }, 'package' => { list => { value => \&string } }, namespace => { list => { value => \&string } }, } }; my $no_index_1_2 = { 'map' => { file => { list => { value => \&string } }, dir => { list => { value => \&string } }, 'package' => { list => { value => \&string } }, namespace => { list => { value => \&string } }, } }; my $no_index_1_1 = { 'map' => { ':key' => { name => \&keyword, list => { value => \&string } }, } }; my $prereq_map = { 'map' => { ':key' => { name => \&phase, 'map' => { ':key' => { name => \&relation, %$module_map1 } } } } }; my %definitions = ( '2' => { # REQUIRED 'abstract' => { mandatory => 1, value => \&string }, 'author' => { mandatory => 1, lazylist => { value => \&string } }, 'dynamic_config' => { mandatory => 1, value => \&boolean }, 'generated_by' => { mandatory => 1, value => \&string }, 'license' => { mandatory => 1, list => { value => \&license } }, 'meta-spec' => { mandatory => 1, 'map' => { version => { mandatory => 1, value => \&version}, url => { value => \&url } } }, 'name' => { mandatory => 1, value => \&string }, 'release_status' => { mandatory => 1, value => \&release_status }, 'version' => { mandatory => 1, value => \&version }, # OPTIONAL 'description' => { value => \&string }, 'keywords' => { lazylist => { value => \&string } }, 'no_index' => $no_index_1_3, 'optional_features' => { 'map' => { ':key' => { name => \&identifier, 'map' => { description => { value => \&string }, prereqs => $prereq_map, } } } }, 'prereqs' => $prereq_map, 'provides' => { 'map' => { ':key' => { name => \&module, 'map' => { file => { mandatory => 1, value => \&file }, version => { value => \&version } } } } }, 'resources' => { 'map' => { license => { list => { value => \&url } }, homepage => { value => \&url }, bugtracker => { 'map' => { web => { value => \&url }, mailto => { value => \&string}, }}, repository => { 'map' => { web => { value => \&url }, url => { value => \&url }, type => { value => \&string }, }}, ':key' => { value => \&string, name => \&custom_2 }, } }, # CUSTOM -- additional user defined key/value pairs # note we can only validate the key name, as the structure is user defined ':key' => { name => \&custom_2, value => \&anything }, }, '1.4' => { 'meta-spec' => { mandatory => 1, 'map' => { version => { mandatory => 1, value => \&version}, url => { mandatory => 1, value => \&urlspec } } }, 'name' => { mandatory => 1, value => \&string }, 'version' => { mandatory => 1, value => \&version }, 'abstract' => { mandatory => 1, value => \&string }, 'author' => { mandatory => 1, list => { value => \&string } }, 'license' => { mandatory => 1, value => \&license }, 'generated_by' => { mandatory => 1, value => \&string }, 'distribution_type' => { value => \&string }, 'dynamic_config' => { value => \&boolean }, 'requires' => $module_map1, 'recommends' => $module_map1, 'build_requires' => $module_map1, 'configure_requires' => $module_map1, 'conflicts' => $module_map2, 'optional_features' => { 'map' => { ':key' => { name => \&identifier, 'map' => { description => { value => \&string }, requires_packages => { value => \&string }, requires_os => { value => \&string }, excludes_os => { value => \&string }, requires => $module_map1, recommends => $module_map1, build_requires => $module_map1, conflicts => $module_map2, } } } }, 'provides' => { 'map' => { ':key' => { name => \&module, 'map' => { file => { mandatory => 1, value => \&file }, version => { value => \&version } } } } }, 'no_index' => $no_index_1_3, 'private' => $no_index_1_3, 'keywords' => { list => { value => \&string } }, 'resources' => { 'map' => { license => { value => \&url }, homepage => { value => \&url }, bugtracker => { value => \&url }, repository => { value => \&url }, ':key' => { value => \&string, name => \&resource }, } }, # additional user defined key/value pairs # note we can only validate the key name, as the structure is user defined ':key' => { name => \&keyword, value => \&anything }, }, '1.3' => { 'meta-spec' => { mandatory => 1, 'map' => { version => { mandatory => 1, value => \&version}, url => { mandatory => 1, value => \&urlspec } } }, 'name' => { mandatory => 1, value => \&string }, 'version' => { mandatory => 1, value => \&version }, 'abstract' => { mandatory => 1, value => \&string }, 'author' => { mandatory => 1, list => { value => \&string } }, 'license' => { mandatory => 1, value => \&license }, 'generated_by' => { mandatory => 1, value => \&string }, 'distribution_type' => { value => \&string }, 'dynamic_config' => { value => \&boolean }, 'requires' => $module_map1, 'recommends' => $module_map1, 'build_requires' => $module_map1, 'conflicts' => $module_map2, 'optional_features' => { 'map' => { ':key' => { name => \&identifier, 'map' => { description => { value => \&string }, requires_packages => { value => \&string }, requires_os => { value => \&string }, excludes_os => { value => \&string }, requires => $module_map1, recommends => $module_map1, build_requires => $module_map1, conflicts => $module_map2, } } } }, 'provides' => { 'map' => { ':key' => { name => \&module, 'map' => { file => { mandatory => 1, value => \&file }, version => { value => \&version } } } } }, 'no_index' => $no_index_1_3, 'private' => $no_index_1_3, 'keywords' => { list => { value => \&string } }, 'resources' => { 'map' => { license => { value => \&url }, homepage => { value => \&url }, bugtracker => { value => \&url }, repository => { value => \&url }, ':key' => { value => \&string, name => \&resource }, } }, # additional user defined key/value pairs # note we can only validate the key name, as the structure is user defined ':key' => { name => \&keyword, value => \&anything }, }, # v1.2 is misleading, it seems to assume that a number of fields where created # within v1.1, when they were created within v1.2. This may have been an # original mistake, and that a v1.1 was retro fitted into the timeline, when # v1.2 was originally slated as v1.1. But I could be wrong ;) '1.2' => { 'meta-spec' => { mandatory => 1, 'map' => { version => { mandatory => 1, value => \&version}, url => { mandatory => 1, value => \&urlspec } } }, 'name' => { mandatory => 1, value => \&string }, 'version' => { mandatory => 1, value => \&version }, 'license' => { mandatory => 1, value => \&license }, 'generated_by' => { mandatory => 1, value => \&string }, 'author' => { mandatory => 1, list => { value => \&string } }, 'abstract' => { mandatory => 1, value => \&string }, 'distribution_type' => { value => \&string }, 'dynamic_config' => { value => \&boolean }, 'keywords' => { list => { value => \&string } }, 'private' => $no_index_1_2, '$no_index' => $no_index_1_2, 'requires' => $module_map1, 'recommends' => $module_map1, 'build_requires' => $module_map1, 'conflicts' => $module_map2, 'optional_features' => { 'map' => { ':key' => { name => \&identifier, 'map' => { description => { value => \&string }, requires_packages => { value => \&string }, requires_os => { value => \&string }, excludes_os => { value => \&string }, requires => $module_map1, recommends => $module_map1, build_requires => $module_map1, conflicts => $module_map2, } } } }, 'provides' => { 'map' => { ':key' => { name => \&module, 'map' => { file => { mandatory => 1, value => \&file }, version => { value => \&version } } } } }, 'resources' => { 'map' => { license => { value => \&url }, homepage => { value => \&url }, bugtracker => { value => \&url }, repository => { value => \&url }, ':key' => { value => \&string, name => \&resource }, } }, # additional user defined key/value pairs # note we can only validate the key name, as the structure is user defined ':key' => { name => \&keyword, value => \&anything }, }, # note that the 1.1 spec doesn't specify optional or mandatory fields, what # appears below is assumed from later specifications. '1.1' => { 'name' => { mandatory => 1, value => \&string }, 'version' => { mandatory => 1, value => \&version }, 'license' => { mandatory => 1, value => \&license }, 'license_uri' => { mandatory => 0, value => \&url }, 'generated_by' => { mandatory => 1, value => \&string }, 'distribution_type' => { value => \&string }, 'dynamic_config' => { value => \&boolean }, 'private' => $no_index_1_1, 'requires' => $module_map1, 'recommends' => $module_map1, 'build_requires' => $module_map1, 'conflicts' => $module_map2, # additional user defined key/value pairs # note we can only validate the key name, as the structure is user defined ':key' => { name => \&keyword, value => \&anything }, }, # note that the 1.0 spec doesn't specify optional or mandatory fields, what # appears below is assumed from later specifications. '1.0' => { 'name' => { mandatory => 1, value => \&string }, 'version' => { mandatory => 1, value => \&version }, 'license' => { mandatory => 1, value => \&license }, 'generated_by' => { mandatory => 1, value => \&string }, 'distribution_type' => { value => \&string }, 'dynamic_config' => { value => \&boolean }, 'requires' => $module_map1, 'recommends' => $module_map1, 'build_requires' => $module_map1, 'conflicts' => $module_map2, # additional user defined key/value pairs # note we can only validate the key name, as the structure is user defined ':key' => { name => \&keyword, value => \&anything }, }, ); # aliases $definitions{'2.0'} = $definitions{'2'}; ############################################################################# #Code # ############################################################################# =head1 CLASS CONSTRUCTOR =over =item * new( data => $data [, spec => $version] ) The constructor must be passed a valid data structure. Optionally you may also provide a specification version. This version is then use to ensure that the given data structure meets the respective specification definition. If no version is provided the module will attempt to deduce the appropriate specification version from the data structure itself. =back =cut sub new { my ($class,%hash) = @_; # create an attributes hash my $atts = { 'spec' => $hash{spec}, 'data' => $hash{data}, }; # create the object my $self = bless $atts, $class; } =head1 METHODS =head2 Main Methods =over =item * parse() Using the given data structure provided with the constructor, attempts to parse and validate according to the appropriate specification definition. Returns 1 if any errors found, otherwise returns 0. =item * errors() Returns a list of the errors found during parsing. =back =cut sub parse { my $self = shift; my $data = $self->{data}; unless($self->{spec}) { $self->{spec} = $data->{'meta-spec'} && $data->{'meta-spec'}{'version'} ? $data->{'meta-spec'}{'version'} : '2'; } $self->check_map($definitions{$self->{spec}},$data); return defined $self->{errors} ? 1 : 0; } sub errors { my $self = shift; return () unless($self->{errors}); return @{$self->{errors}}; } =head2 Check Methods =over =item * check_map($spec,$data) Checks whether a map (or hash) part of the data structure conforms to the appropriate specification definition. =item * check_lazylist($spec,$data) If it's a string, make it into a list and check the list =item * check_list($spec,$data) Checks whether a list (or array) part of the data structure conforms to the appropriate specification definition. =back =cut sub check_map { my ($self,$spec,$data) = @_; if(ref($spec) ne 'HASH') { $self->_error( "Unknown META.yml specification, cannot validate." ); return; } if(ref($data) ne 'HASH') { $self->_error( "Expected a map structure from data string or file." ); return; } for my $key (keys %$spec) { next unless($spec->{$key}->{mandatory}); next if(defined $data->{$key}); push @{$self->{stack}}, $key; $self->_error( "Missing mandatory field, '$key'" ); pop @{$self->{stack}}; } for my $key (keys %$data) { push @{$self->{stack}}, $key; if($spec->{$key}) { if($spec->{$key}{value}) { $spec->{$key}{value}->($self,$key,$data->{$key}); } elsif($spec->{$key}{'map'}) { $self->check_map($spec->{$key}{'map'},$data->{$key}); } elsif($spec->{$key}{'list'}) { $self->check_list($spec->{$key}{'list'},$data->{$key}); } elsif($spec->{$key}{'lazylist'}) { $self->check_lazylist($spec->{$key}{'lazylist'},$data->{$key}); } else { $self->_error( "$spec_error for '$key'" ); } } elsif ($spec->{':key'}) { $spec->{':key'}{name}->($self,$key,$key); if($spec->{':key'}{value}) { $spec->{':key'}{value}->($self,$key,$data->{$key}); } elsif($spec->{':key'}{'map'}) { $self->check_map($spec->{':key'}{'map'},$data->{$key}); } elsif($spec->{':key'}{'list'}) { $self->check_list($spec->{':key'}{'list'},$data->{$key}); } elsif($spec->{':key'}{'lazylist'}) { $self->check_list($spec->{':key'}{'lazylist'},$data->{$key}); } elsif(!$spec->{':key'}{name}) { $self->_error( "$spec_error for ':key'" ); } } else { $self->_error( "Unknown key, '$key', found in map structure" ); } pop @{$self->{stack}}; } } sub check_lazylist { my ($self,$spec,$data) = @_; if ( defined $data && ! ref($data) ) { $data = [ $data ]; } $self->check_list($spec,$data); } sub check_list { my ($self,$spec,$data) = @_; if(ref($data) ne 'ARRAY') { $self->_error( "Expected a list structure" ); return; } if(defined $spec->{mandatory}) { if(!defined $data->[0]) { $self->_error( "Missing entries from mandatory list" ); } } for my $value (@$data) { push @{$self->{stack}}, $value; if(defined $spec->{value}) { $spec->{value}->($self,'list',$value); } elsif(defined $spec->{'map'}) { $self->check_map($spec->{'map'},$value); } elsif(defined $spec->{'list'}) { $self->check_list($spec->{'list'},$value); } elsif(defined $spec->{'lazylist'}) { $self->check_lazylist($spec->{'lazylist'},$value); } elsif ($spec->{':key'}) { $self->check_map($spec,$value); } else { $self->_error( "$spec_error associated with '$self->{stack}[-2]'" ); } pop @{$self->{stack}}; } } =head2 Validator Methods =over =item * url($self,$key,$value) Validates that a given value is in an acceptable URL format =item * urlspec($self,$key,$value) Validates that the URL to a META.yml specification is a known one. =item * string_or_undef($self,$key,$value) Validates that the value is either a string or an undef value. Bit of a catchall function for parts of the data structure that are completely user defined. =item * string($self,$key,$value) Validates that a string exists for the given key. =item * file($self,$key,$value) Validate that a file is passed for the given key. This may be made more thorough in the future. For now it acts like \&string. =item * exversion($self,$key,$value) Validates a list of versions, e.g. '<= 5, >=2, ==3, !=4, >1, <6, 0'. =item * version($self,$key,$value) Validates a single version string. Versions of the type '5.8.8' and '0.00_00' are both valid. A leading 'v' like 'v1.2.3' is also valid. =item * boolean($self,$key,$value) Validates for a boolean value. Currently these values are '1', '0', 'true', 'false', however the latter 2 may be removed. =item * license($self,$key,$value) Validates that a value is given for the license. Returns 1 if an known license type, or 2 if a value is given but the license type is not a recommended one. =item * resource($self,$key,$value) Validates that the given key is in CamelCase, to indicate a user defined keyword. =item * keyword($self,$key,$value) Validates that key is in an acceptable format for the META.yml specification, i.e. any in the character class [-_a-z]. For user defined keys, although not explicitly stated in the specifications (v1.0 - v1.4), the convention is to precede the key with a pattern matching qr{\Ax_}i. Following this any character from the character class [-_a-zA-Z] can be used. This clarification has been added to v2.0 of the specification. =item * identifier($self,$key,$value) Validates that key is in an acceptable format for the META.yml specification, for an identifier, i.e. any that matches the regular expression qr/[a-z][a-z_]/i. =item * module($self,$key,$value) Validates that a given key is in an acceptable module name format, e.g. 'Test::CPAN::Meta::JSON::Version'. =item * release_status($self,$key,$value) Validates that the value for 'release_status' is set appropriately for one of 'stable', 'testing' or 'unstable'. =item * custom_1($self,$key,$value) Validates custom keys based on camelcase only. =item * custom_2($self,$key,$value) Validates custom keys based on user defined (i.e. /^[xX]_/) only. =item * phase($self,$key,$value) Validates for a legal phase of a pre-requisite map. =item * relation($self,$key,$value) Validates for a legal relation, within a phase, of a pre-requisite map. =item * anything($self,$key,$value) Usually reserved for user defined structures, allowing them to be considered valid without a need for a specification definition for the structure. =back =cut sub _uri_split { return $_[0] =~ m,(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?,; } sub url { my ($self,$key,$value) = @_; if($value) { my ($scheme, $auth, $path, $query, $frag) = _uri_split($value); unless ( $scheme ) { $self->_error( "'$value' for '$key' does not have a URL scheme" ); return 0; } unless ( $auth ) { $self->_error( "'$value' for '$key' does not have a URL authority" ); return 0; } return 1; } else { $value = ''; } $self->_error( "'$value' for '$key' is not a valid URL." ); return 0; } sub urlspec { my ($self,$key,$value) = @_; if(defined $value) { return 1 if($value && $known_specs{$self->{spec}} eq $value); if($value && $known_urls{$value}) { $self->_error( 'META.yml specification URL does not match version' ); return 0; } } $self->_error( 'Unknown META.yml specification' ); return 0; } sub string { my ($self,$key,$value) = @_; if(defined $value) { return 1 if($value || $value =~ /^0$/); } $self->_error( "value is an undefined string" ); return 0; } sub string_or_undef { my ($self,$key,$value) = @_; return 1 unless(defined $value); return 1 if($value || $value =~ /^0$/); $self->_error( "No string defined for '$key'" ); return 0; } sub file { my ($self,$key,$value) = @_; return 1 if(defined $value); $self->_error( "No file defined for '$key'" ); return 0; } sub exversion { my ($self,$key,$value) = @_; if(defined $value && ($value || $value =~ /0/)) { my $pass = 1; for(split(",",$value)) { $self->version($key,$_) or ($pass = 0); } return $pass; } $value = '' unless(defined $value); $self->_error( "'$value' for '$key' is not a valid version." ); return 0; } sub version { my ($self,$key,$value) = @_; if(defined $value) { return 0 unless($value || $value =~ /0/); return 1 if($value =~ /^\s*((<|<=|>=|>|!=|==)\s*)?v?\d+((\.\d+((_|\.)\d+)?)?)/); } else { $value = ''; } $self->_error( "'$value' for '$key' is not a valid version." ); return 0; } sub boolean { my ($self,$key,$value) = @_; if(defined $value) { return 1 if($value =~ /^(0|1|true|false)$/); } else { $value = ''; } $self->_error( "'$value' for '$key' is not a boolean value." ); return 0; } my %v1_licenses = ( 'perl' => 'http://dev.perl.org/licenses/', 'gpl' => 'http://www.opensource.org/licenses/gpl-license.php', 'apache' => 'http://apache.org/licenses/LICENSE-2.0', 'artistic' => 'http://opensource.org/licenses/artistic-license.php', 'artistic2' => 'http://opensource.org/licenses/artistic-license-2.0.php', 'artistic-2.0' => 'http://opensource.org/licenses/artistic-license-2.0.php', 'lgpl' => 'http://www.opensource.org/licenses/lgpl-license.phpt', 'bsd' => 'http://www.opensource.org/licenses/bsd-license.php', 'gpl' => 'http://www.opensource.org/licenses/gpl-license.php', 'mit' => 'http://opensource.org/licenses/mit-license.php', 'mozilla' => 'http://opensource.org/licenses/mozilla1.1.php', 'open_source' => undef, 'unrestricted' => undef, 'restrictive' => undef, 'unknown' => undef, ); my %v2_licenses = map { $_ => 1 } qw( agpl_3 apache_1_1 apache_2_0 artistic_1 artistic_2 bsd freebsd gfdl_1_2 gfdl_1_3 gpl_1 gpl_2 gpl_3 lgpl_2_1 lgpl_3_0 mit mozilla_1_0 mozilla_1_1 openssl perl_5 qpl_1_0 ssleay sun zlib open_source restricted unrestricted unknown ); sub license { my ($self,$key,$value) = @_; my $licenses = $self->{spec} < 2 ? \%v1_licenses : \%v2_licenses; if(defined $value) { return 1 if($value && exists $licenses->{$value}); # v1 specs caused problems for some with this field, # so this test is relaxed for v1 tests only. return 2 if($value && $self->{spec} < 2); } else { $value = ''; } $self->_error( "License '$value' is invalid" ); return 0; } sub resource { my ($self,$key) = @_; if(defined $key) { # a valid user defined key should be alphabetic # and contain at least one capital case letter. return 1 if($key && $key =~ /^[a-z]+$/i && $key =~ /[A-Z]/); } else { $key = ''; } $self->_error( "Resource '$key' must be in CamelCase." ); return 0; } sub keyword { my ($self,$key) = @_; if(defined $key) { return 1 if($key && $key =~ /^([a-z][-_a-z]*)$/); # spec defined return 1 if($key && $key =~ /^x_([a-z][-_a-z]*)$/i); # user defined } else { $key = ''; } $self->_error( "Key '$key' is not a legal keyword." ); return 0; } sub identifier { my ($self,$key) = @_; if(defined $key) { return 1 if($key && $key =~ /^([a-z][_a-z]+)$/i); # spec 2.0 defined } else { $key = ''; } $self->_error( "Key '$key' is not a legal identifier." ); return 0; } sub module { my ($self,$key) = @_; if(defined $key) { return 1 if($key && $key =~ /^[A-Za-z0-9_]+(::[A-Za-z0-9_]+)*$/); } else { $key = ''; } $self->_error( "Key '$key' is not a legal module name." ); return 0; } sub release_status { my ($self,$key,$value) = @_; if(defined $value) { my $version = $self->{data}{version} || ''; if ( $version =~ /_/ ) { return 1 if ( $value =~ /\A(?:testing|unstable)\z/ ); $self->_error( "'$value' for '$key' is invalid for version '$version'" ); } else { return 1 if ( $value =~ /\A(?:stable|testing|unstable)\z/ ); $self->_error( "'$value' for '$key' is invalid" ); } } else { $self->_error( "'$key' is not defined" ); } return 0; } sub custom_1 { my ($self,$key) = @_; if(defined $key) { # a valid user defined key should be alphabetic # and contain at least one capital case letter. return 1 if($key && $key =~ /^[a-z]+$/i && $key =~ /[A-Z]/); } else { $key = ''; } $self->_error( "Custom resource '$key' must be in CamelCase." ); return 0; } sub custom_2 { my ($self,$key) = @_; if(defined $key) { # a valid user defined key should be alphabetic # and begin with x_ or X_ return 1 if($key && $key =~ /^x_([a-z][-_a-z]*)$/i); # user defined } else { $key = ''; } $self->_error( "Custom resource '$key' must begin with 'x_' or 'X_'." ); return 0; } my @valid_phases = qw/ configure build test runtime develop /; sub phase { my ($self,$key) = @_; if(defined $key) { return 1 if( length $key && grep { $key eq $_ } @valid_phases ); } else { $key = ''; } $self->_error( "Key '$key' is not a legal phase." ); return 0; } my @valid_relations = qw/ requires recommends suggests conflicts /; sub relation { my ($self,$key) = @_; if(defined $key) { return 1 if( length $key && grep { $key eq $_ } @valid_relations ); } else { $key = ''; } $self->_error( "Key '$key' is not a legal prereq relationship." ); return 0; } sub anything { return 1 } sub _error { my $self = shift; my $mess = shift; $mess .= ' ('.join(' -> ',@{$self->{stack}}).')' if($self->{stack}); $mess .= " [Validation: $self->{spec}]"; push @{$self->{errors}}, $mess; } q( Currently Listening To: Rainbow - "I Surrender" from 'Outrage - Live in London 1981'); __END__ #---------------------------------------------------------------------------- =head1 BUGS, PATCHES & FIXES There are no known bugs at the time of this release. However, if you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please send an email to barbie@cpan.org or submit a bug to the RT system (http://rt.cpan.org/Public/Dist/Display.html?Name=Test-CPAN-Meta-JSON). However, it would help greatly if you are able to pinpoint problems or even supply a patch. Fixes are dependent upon their severity and my availability. Should a fix not be forthcoming, please feel free to (politely) remind me. =head1 AUTHOR Barbie, for Miss Barbell Productions, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2009-2015 Barbie for Miss Barbell Productions This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. =cut Test-CPAN-Meta-JSON-0.16/lib/Test/CPAN/Meta/JSON.pm0000644000175000017500000001457712454444506020214 0ustar barbiebarbiepackage Test::CPAN::Meta::JSON; use warnings; use strict; use vars qw($VERSION); $VERSION = '0.16'; #---------------------------------------------------------------------------- =head1 NAME Test::CPAN::Meta::JSON - Validate a META.json file within a CPAN distribution. =head1 SYNOPSIS There are two forms this module can be used. The first is a standalone test of your distribution's META.json file: use Test::More; eval "use Test::CPAN::Meta::JSON"; plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json" if $@; meta_json_ok(); Note that you may provide an optional label/comment/message/etc to the function, or one will be created automatically. The second form allows you to test other META.json files, or specify a specific version you wish to test against: use Test::More test => 6; use Test::CPAN::Meta::JSON; # specify a file and specification version meta_spec_ok('META.json','1.3',$msg); # specify the specification version to validate the local META.json meta_spec_ok(undef,'1.3',$msg); # specify a file, where the specification version is deduced # from the file itself meta_spec_ok('META.json',undef,$msg); Note that this form requires you to specify the number of tests you will be running in your test script. Also note that each 'meta_spec_ok' is actually 2 tests under the hood. Also note that the version you are testing against, is the version of the META.yml specification, which forms the basis for the contents of a META.json file. L =head1 DESCRIPTION This module was written to ensure that a META.json file, provided with a standard distribution uploaded to CPAN, meets the specifications that are slowly being introduced to module uploads, via the use of package makers and installers such as L, L and L. See L for further details of the CPAN Meta Specification. =head1 ABSTRACT A test module to validate a CPAN META.json file. =cut #---------------------------------------------------------------------------- ############################################################################# #Library Modules # ############################################################################# use IO::File; use JSON; use Test::Builder; use Test::CPAN::Meta::JSON::Version; #---------------------------------------------------------------------------- my $Test = Test::Builder->new(); sub import { my $self = shift; my $caller = caller; no strict 'refs'; *{$caller.'::meta_json_ok'} = \&meta_json_ok; *{$caller.'::meta_spec_ok'} = \&meta_spec_ok; $Test->exported_to($caller); $Test->plan(@_); } ############################################################################# #Interface Functions # ############################################################################# =head1 FUNCTIONS =over =item * meta_json_ok([$msg]) Basic META.json wrapper around meta_spec_ok. Returns a hash reference to the contents of the parsed META.json =cut sub meta_json_ok { $Test->plan( tests => 2 ); return meta_spec_ok(undef,undef,@_); } =item * meta_spec_ok($file, $version [,$msg]) Validates the named file against the given specification version. Both $file and $version can be undefined. Returns a hash reference to the contents of the given file, after it has been parsed. =back =cut sub meta_spec_ok { my ($file, $vers, $msg) = @_; $file ||= 'META.json'; unless($msg) { $msg = "$file meets the designated specification"; $msg .= " ($vers)" if($vers); } my $data = _readdata($file); unless($data) { $Test->ok(0,"$file contains valid JSON"); $Test->ok(0,$msg); return; } else { $Test->ok(1,"$file contains valid JSON"); } my %hash; $hash{spec} = $vers if($vers); $hash{data} = $data; my $spec = Test::CPAN::Meta::JSON::Version->new(%hash); if(my $result = $spec->parse()) { $Test->ok(0,$msg); $Test->diag(" ERR: $_") for($spec->errors); } else { $Test->ok(1,$msg); } return $data; } sub _readdata { my $file = shift; my $data; my $fh = IO::File->new($file,'r') or die "Cannot open file [$file]: $!"; while(<$fh>) { $data .= $_ } $fh->close; return decode_json($data); } q( Currently Listening To: Paul Menel - "Little Gorgeous Fool" from 'Three Sides To Every Story'); __END__ #---------------------------------------------------------------------------- =head1 TESTING META FILES There are currently 3 distributions to test META files: Test-CPAN-Meta Test-CPAN-Meta-JSON Test-CPAN-Meta-YAML All three have slightly different requirements and are intended to be used in slightly different environments. Test-CPAN-Meta-YAML requires a YAML parser, and currently looks for the YAML or YAML::Syck modules. This is the original variant of the 3 and was intended to provide a more complete YAML validation of a META.yml. Test-CPAN-Meta requires the Parse::CPAN::Meta module, which is now part of Perl Core as of perl-5.10.1. This version is intended to be used by those only wishing to rely on core modules to test their META.yml files. Test-CPAN-Meta-JSON is the most recent addition to the family, and is specifically aimed at those distributions that use a META.json Meta file. The distribution requires the JSON module to parse the Meta file. =head1 BUGS, PATCHES & FIXES There are no known bugs at the time of this release. However, if you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please send an email to barbie@cpan.org or submit a bug to the RT system (http://rt.cpan.org/Public/Dist/Display.html?Name=Test-CPAN-Meta-JSON). However, it would help greatly if you are able to pinpoint problems or even supply a patch. Fixes are dependent upon their severity and my availability. Should a fix not be forthcoming, please feel free to (politely) remind me. =head1 SEE ALSO JSON =head1 AUTHOR Barbie, for Miss Barbell Productions, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2009-2015 Barbie for Miss Barbell Productions This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. =cut Test-CPAN-Meta-JSON-0.16/LICENSE0000644000175000017500000000033212454443616014777 0ustar barbiebarbieLICENSE FOR Test-CPAN-Meta-JSON This software is copyright © 2009-2015 Barbie for Miss Barbell Productions. This distribution is free software; you can redistribute it and/or modify it under the Artistic Licence v2. Test-CPAN-Meta-JSON-0.16/examples/0000755000175000017500000000000012454446444015614 5ustar barbiebarbieTest-CPAN-Meta-JSON-0.16/examples/examples.txt0000644000175000017500000000075511525734760020201 0ustar barbiebarbieTo see examples for this distribution, it is recommended you read the test scripts included under ./t, which cover the basic usage of the modules. I may add further examples should the need ever arise. If you have any example scripts that use the distribution in an unusual way or make good use of all the features available, please feel free to submit one. If submitting an example script, please sure to include the following in your POD: * Author * License * Copyright Thanks, Barbie. Test-CPAN-Meta-JSON-0.16/examples/96metatest.t0000644000175000017500000000206212412201504017762 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta::JSON"; plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@; plan 'no_plan'; my $meta = meta_spec_ok(undef,undef,@_); use MyDistro; # enter your module name here my $version = $MyDistro::VERSION; # enter your module name here is($meta->{version},$version, 'META.json distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.json entry [$mod] version matches distribution version"); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.json entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Test-CPAN-Meta-JSON-0.16/examples/97metatest.t0000644000175000017500000000050412011436575017777 0ustar barbiebarbie#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta::JSON"; plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@; meta_json_ok(); Test-CPAN-Meta-JSON-0.16/MANIFEST0000644000175000017500000000201512011541311015077 0ustar barbiebarbieChanges examples/examples.txt examples/96metatest.t examples/97metatest.t INSTALL LICENSE lib/Test/CPAN/Meta/JSON.pm lib/Test/CPAN/Meta/JSON/Version.pm Makefile.PL MANIFEST META.json META.yml README t/01use.t t/02metafiles.t t/04metatester.t t/05metaspec.t t/10metaversion.t t/11metaversion.t t/12metaversion.t t/13metaversion.t t/14metaversion.t t/20metaversion.t t/90podtest.t t/91podcover.t t/94metatest.t t/95changedate.t t/96metatest.t t/97metatest.t t/samples/00-META.json t/samples/01-META.json t/samples/02-META.json t/samples/03-META.json t/samples/04-META.json t/samples/05-META.json t/samples/06-META.json t/samples/07-META.json t/samples/08-META.json t/samples/09-META.json t/samples/10-META.json t/samples/11-META.json t/samples/12-META.json t/samples/13-META.json t/samples/14-META.json t/samples/15-META.json t/samples/16-META.json t/samples/20-META.json t/samples/21-META.json t/samples/22-META.json t/samples/23-META.json t/samples/24-META.json t/samples/multibyte.json t/samples/Template-Provider-Unicode-Japanese.json Test-CPAN-Meta-JSON-0.16/META.json0000644000175000017500000000360112454444506015414 0ustar barbiebarbie{ "name": "Test-CPAN-Meta-JSON", "version": "0.16", "abstract": "Validate your CPAN META.json files", "author": ["Barbie "], "license": [ "artistic_2" ], "dynamic_config" : 0, "release_status" : "stable", "meta-spec": { "version": "2", "url": "http://search.cpan.org/dist/CPAN-Meta/lib/CPAN/Meta/Spec.pm" }, "generated_by": "The Hand of Barbie 1.0", "keywords" : [ "qa", "cpan", "testing", "meta", "json" ], "prereqs" : { "runtime" : { "requires" : { "perl": "5.006", "IO::File": "0", "JSON": "2.15", "Test::More": "0.62", "Test::Builder": "0" } }, "test" : { "requires": { "Test::More": "0.62", "Test::Builder": "0" }, "recommends": { "Test::CPAN::Meta": "0.13", "Test::More": "0.70", "Test::Pod": "1.00", "Test::Pod::Coverage": "0.08" } } }, "provides": { "Test::CPAN::Meta::JSON": { "file": "lib/Test/CPAN/Meta/JSON.pm", "version": "0.16" }, "Test::CPAN::Meta::JSON::Version": { "file": "lib/Test/CPAN/Meta/JSON/Version.pm", "version": "0.16" } }, "no_index": { "directory": ["t","examples"] }, "resources": { "license": [ "http://www.perlfoundation.org/artistic_license_2_0" ], "bugtracker": { "web": "http://rt.cpan.org/Public/Dist/Display.html?Name=Test-CPAN-Meta-JSON" }, "repository": { "url": "git://github.com/barbie/Test-CPAN-Meta-JSON.git", "web": "http://github.com/barbie/Test-CPAN-Meta-JSON", "type": "git" } } } Test-CPAN-Meta-JSON-0.16/META.yml0000644000175000017500000000232212454444506015243 0ustar barbiebarbie--- #YAML:1.0 name: Test-CPAN-Meta-JSON version: 0.16 abstract: Validate your CPAN META.json files author: - Barbie license: artistic_2 distribution_type: module installdirs: site requires: perl: 5.006 IO::File: 0 JSON: 2.15 Test::More: 0.62 Test::Builder: 0 recommends: Test::CPAN::Meta: 0.13 Test::Pod: 1.00 Test::Pod::Coverage: 0.08 build_requires: Test::More: 0.70 Test::Builder::Tester: 0 provides: Test::CPAN::Meta::JSON: file: lib/Test/CPAN/Meta/JSON.pm version: 0.16 Test::CPAN::Meta::JSON::Version: file: lib/Test/CPAN/Meta/JSON/Version.pm version: 0.16 no_index: directory: - t - examples resources: license: http://www.perlfoundation.org/artistic_license_2_0 bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Test-CPAN-Meta-JSON repository: http://github.com/barbie/Test-CPAN-Meta-JSON meta-spec: version: 1.4 url: http://module-build.sourceforge.net/META-spec-v1.4.html generated_by: The Hand of Barbie 1.0 Test-CPAN-Meta-JSON-0.16/Makefile.PL0000644000175000017500000000117612011434701015733 0ustar barbiebarbie#!/usr/bin/perl use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; WriteMakefile( AUTHOR => 'Barbie ', NAME => 'Test::CPAN::Meta::JSON', VERSION_FROM => 'lib/Test/CPAN/Meta/JSON.pm', ABSTRACT => 'Validate your CPAN META.json files', NO_META => 1, PREREQ_PM => { # runtime prereqs 'IO::File' => '0', 'JSON' => '2.15', 'Test::Builder' => '0', # build/test prereqs 'Test::Builder::Tester' => '0', 'Test::More' => '0.70' } );