From bfeb5aa13c8d855c98c29ce9f23d745182b6938e Mon Sep 17 00:00:00 2001 From: Chris White Date: Thu, 14 Feb 2019 11:49:00 -0500 Subject: [PATCH] Add Axk.pm, META_MERGE; move O::TinyDefaults->X::A - New package XML::Axk to meet CPAN requirements - Added META_MERGE and other information to Makefile.PL - Moved Object::TinyDefaults under the XML::Axk hierarchy since it will disappear in the future anyway. --- Changes | 2 +- MANIFEST | 3 +- Makefile.PL | 55 +++++++++++++++++++++--- lib/XML/Axk.pm | 39 +++++++++++++++++ lib/XML/Axk/App.pm | 3 +- lib/XML/Axk/Core.pm | 4 +- lib/XML/Axk/Matcher/Always.pm | 2 +- lib/XML/Axk/Matcher/XPath.pm | 2 +- lib/{ => XML/Axk}/Object/TinyDefaults.pm | 13 +++--- t/00-load.t | 12 +++--- t/tests/TinyDefaults.pm | 22 +++++----- 11 files changed, 124 insertions(+), 33 deletions(-) create mode 100755 lib/XML/Axk.pm rename lib/{ => XML/Axk}/Object/TinyDefaults.pm (89%) diff --git a/Changes b/Changes index b36bf87..a928f73 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,6 @@ Revision history for XML-Axk -0.001004 2019-02-14 +0.001006 2019-02-14 No substantive changes 0.001_003 2018-11-10 diff --git a/MANIFEST b/MANIFEST index 5a20eaf..4f5f626 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,6 +1,6 @@ bin/axk Changes -lib/Object/TinyDefaults.pm +lib/XML/Axk.pm lib/XML/Axk/App.pm lib/XML/Axk/Base.pm lib/XML/Axk/Core.pm @@ -11,6 +11,7 @@ lib/XML/Axk/L/LTEST.pm lib/XML/Axk/Language.pm lib/XML/Axk/Matcher/Always.pm lib/XML/Axk/Matcher/XPath.pm +lib/XML/Axk/Object/TinyDefaults.pm lib/XML/Axk/Preparse.pm lib/XML/Axk/Sandbox.pm lib/XML/Axk/SAX/BuildDOM2.pm diff --git a/Makefile.PL b/Makefile.PL index b7354ce..9044c2f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -3,8 +3,19 @@ use strict; use warnings; use Config; use ExtUtils::MakeMaker; +use File::Spec; -# Get the filename of the Perl interpreter running this. Modified from perlvar. +my $VERSION_FROM = File::Spec->catfile(qw(lib XML Axk.pm)); +# Module metadata {{{1 +my $provides; +eval { + require Module::Metadata; + $provides = Module::Metadata->provides(version => '2', dir => 'lib'); + # Thanks to https://stackoverflow.com/a/28928985/2877364 by LEONT +}; +# }}}1 +# Get the filename of the Perl interpreter running this. {{{1 +# Modified from perlvar. # The -x test is for cygwin or other systems where $Config{perlpath} has no # extension and $Config{_exe} is nonempty. E.g., symlink perl->perl5.10.1.exe. # There is no "perl.exe" on such a system. @@ -17,9 +28,11 @@ sub get_perl_filename { } return $secure_perl_path; } # get_perl_filename() +# }}}1 my $secure_perl_path = get_perl_filename(); +# Makefile customization {{{1 sub MY::postamble { # TODO also handle Windows nmake syntax (SET vs. export) return < 'XML::Axk', AUTHOR => q{Christopher White }, - VERSION_FROM => 'lib/XML/Axk/App.pm', + VERSION_FROM => $VERSION_FROM, ABSTRACT => 'awk-like XML processor', LICENSE => 'artistic_2', - EXE_FILES => [ 'bin/axk' ], + EXE_FILES => [ File::Spec->catfile(qw(bin axk)) ], MIN_PERL_VERSION => '5.020', CONFIGURE_REQUIRES => { 'Config' => '0', 'ExtUtils::MakeMaker' => '0', + 'File::Spec' => '0', 'strict' => '0', 'version' => '0.77', 'warnings' => '0', @@ -107,5 +123,34 @@ WriteMakefile( dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'XML-Axk-*' }, depend => { Makefile => '$(VERSION_FROM)' }, + + META_MERGE => { + 'meta-spec' => { version => 2 }, + + resources => { + bugtracker => { + web => 'https://github.com/interpreters/axk/issues', + }, + repository => { + type => 'git', + url => 'https://github.com/interpreters/axk.git', + web => 'https://github.com/interpreters/axk', + }, + }, + + prereqs => { + develop => { + requires => { + 'App::RewriteVersion' => '0', # for perl-bump-version + 'Module::Metadata' => '1.000016', + }, + }, + }, + + $provides ? (provides => $provides) : (), + + }, #META_MERGE ); -# vi: set ts=4 sts=4 sw=4 et ai: # + +WriteMakefile(%opts); +# vi: set ts=4 sts=4 sw=4 et ai fdm=marker: # diff --git a/lib/XML/Axk.pm b/lib/XML/Axk.pm new file mode 100755 index 0000000..d5b0975 --- /dev/null +++ b/lib/XML/Axk.pm @@ -0,0 +1,39 @@ +# XML::Axk - top-level module for XML::Axk distribution. +# This holds the main version, but doesn't do anything else at the moment. +package XML::Axk; +use strict; +use warnings; +use Data::Hopen; +use Data::Hopen::Base; + +our $VERSION = '0.001006'; + +#use parent 'Exporter'; +#our (@EXPORT, @EXPORT_OK, %EXPORT_TAGS); +#BEGIN { +# @EXPORT = qw(); +# @EXPORT_OK = qw(); +# %EXPORT_TAGS = ( +# default => [@EXPORT], +# all => [@EXPORT, @EXPORT_OK] +# ); +#} + +# Docs {{{1 + +=head1 NAME + +XML::Axk - tools for processing XML files with an awk-like model + +=head1 SYNOPSIS + +See L for command-line usage and L for +embedded usage in other Perl scripts. + +=cut + +# }}}1 + +1; +__END__ +# vi: set fdm=marker: # diff --git a/lib/XML/Axk/App.pm b/lib/XML/Axk/App.pm index 817bc9d..4d0b69b 100644 --- a/lib/XML/Axk/App.pm +++ b/lib/XML/Axk/App.pm @@ -1,3 +1,4 @@ +#!perl package XML::Axk::App; use XML::Axk::Base; use XML::Axk::Core; @@ -7,7 +8,7 @@ use XML::Axk::Core; # Semantic versioning, packed per Perl rules. Must always be at least one # digit left of the decimal, and six digits right of the decimal. For # prerelease versions, put an underscore before the last three digits. -our $VERSION = '0.001004'; +our $VERSION = '0.001006'; use Getopt::Long qw(GetOptionsFromArray :config gnu_getopt); diff --git a/lib/XML/Axk/Core.pm b/lib/XML/Axk/Core.pm index fda88ee..2ec4aa3 100644 --- a/lib/XML/Axk/Core.pm +++ b/lib/XML/Axk/Core.pm @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!perl # Copyright (c) 2018 cxw42. All rights reserved. Artistic 2. # Style note: Hungarian prefixes are used on scalars: @@ -11,6 +11,8 @@ use XML::Axk::Base qw(:all); use XML::Axk::Preparse; use Data::Dumper; +our $VERSION = '0.001006'; + =encoding UTF-8 =head1 NAME diff --git a/lib/XML/Axk/Matcher/Always.pm b/lib/XML/Axk/Matcher/Always.pm index c7d82f5..16ff022 100755 --- a/lib/XML/Axk/Matcher/Always.pm +++ b/lib/XML/Axk/Matcher/Always.pm @@ -5,7 +5,7 @@ package XML::Axk::Matcher::Always; use XML::Axk::Base; -use Object::TinyDefaults { always => true }; +use XML::Axk::Object::TinyDefaults { always => true }; sub test { my $self = shift; diff --git a/lib/XML/Axk/Matcher/XPath.pm b/lib/XML/Axk/Matcher/XPath.pm index e133d2a..cdeb525 100755 --- a/lib/XML/Axk/Matcher/XPath.pm +++ b/lib/XML/Axk/Matcher/XPath.pm @@ -9,7 +9,7 @@ use XML::Axk::DOM; our $VERBOSE = 0; -use Object::TinyDefaults +use XML::Axk::Object::TinyDefaults { kind => 'xpath', file => '(unknown source)', line => 0 diff --git a/lib/Object/TinyDefaults.pm b/lib/XML/Axk/Object/TinyDefaults.pm similarity index 89% rename from lib/Object/TinyDefaults.pm rename to lib/XML/Axk/Object/TinyDefaults.pm index 16539f3..a2323e2 100644 --- a/lib/Object/TinyDefaults.pm +++ b/lib/XML/Axk/Object/TinyDefaults.pm @@ -1,8 +1,8 @@ #!/usr/bin/env perl -# Object::TinyDefaults - Object::Tiny::XS, but with default values. +# XML::Axk::Object::TinyDefaults - Object::Tiny::XS, but with default values. # Copyright (c) 2018 cxw42. All rights reserved. Artistic 2. -package Object::TinyDefaults; +package XML::Axk::Object::TinyDefaults; use 5.004; use strict 'vars', 'subs'; @@ -11,8 +11,7 @@ use Data::Dumper; use Import::Into; our $ObjTiny; -our $VERSION; -$VERSION = '0.01'; +our $VERSION = '0.001006'; BEGIN { require parent; @@ -83,12 +82,12 @@ __END__ =head1 NAME -Object::TinyDefaults - Object::Tiny[::XS] wrapper that adds default values +XML::Axk::Object::TinyDefaults - Object::Tiny[::XS] wrapper that adds default values =head1 SYNOPSIS package MyClass; - use Object::TinyDefaults { foo => 42 } qw(bar bat); + use XML::Axk::Object::TinyDefaults { foo => 42 } qw(bar bat); package main; my $inst = MyClass->new(bar=>1); @@ -98,6 +97,8 @@ C and C. Requires L or L. XS will be used if available. +TODO replace this with L! + =head1 COPYRIGHT Copyright (c) 2018 Christopher White. All rights reserved. diff --git a/t/00-load.t b/t/00-load.t index fd1fb4a..3c49511 100644 --- a/t/00-load.t +++ b/t/00-load.t @@ -2,16 +2,18 @@ use 5.020; use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 6; use Module::Loaded; BEGIN { - use_ok( 'XML::Axk::App' ) || print "Could not load App\n"; - use_ok( 'XML::Axk::Core' ) || print "Could not load Core\n"; + use_ok( 'XML::Axk' ) || print "Could not load XML::Axk\n"; + use_ok( 'XML::Axk::App' ) || print "Could not load XML::Axk::App\n"; + use_ok( 'XML::Axk::Core' ) || print "Could not load XML::Axk::Core\n"; } diag( "Testing XML::Axk $XML::Axk::App::VERSION, Perl $], $^X" ); -ok(is_loaded("XML::Axk::App"), "App is loaded"); -ok(is_loaded("XML::Axk::Core"), "Core is loaded"); +ok(is_loaded("XML::Axk"), "XML::Axk is loaded"); +ok(is_loaded("XML::Axk::App"), "XML::Axk::App is loaded"); +ok(is_loaded("XML::Axk::Core"), "XML::Axk::Core is loaded"); # vi: set ts=4 sts=4 sw=4 et ai: # diff --git a/t/tests/TinyDefaults.pm b/t/tests/TinyDefaults.pm index 9eb1cd9..8730276 100755 --- a/t/tests/TinyDefaults.pm +++ b/t/tests/TinyDefaults.pm @@ -1,29 +1,29 @@ #!perl -T # Copyright (c) 2018 cxw42. All rights reserved. Artistic 2. -# Test Object::TinyDefaults +# Test XML::Axk::Object::TinyDefaults package TinyDefaults; use AxkTest; use parent 'Test::Class'; -sub class { "Object::TinyDefaults" }; +sub class { "XML::Axk::Object::TinyDefaults" }; sub startup :Tests(startup=>1) { my $test = shift; use_ok $test->class; - diag( "Testing Object::TinyDefaults $Object::TinyDefaults::VERSION, Perl $], $^X" ); + diag( "Testing XML::Axk::Object::TinyDefaults $XML::Axk::Object::TinyDefaults::VERSION, Perl $], $^X" ); } # No defaults ===================================================== {{{1 package NoDefaults { - use Object::TinyDefaults qw(foo bar); + use XML::Axk::Object::TinyDefaults qw(foo bar); } sub no_defaults :Tests { my $x = NoDefaults->new(); isa_ok($x, 'NoDefaults'); - isa_ok($x, 'Object::TinyDefaults'); + isa_ok($x, 'XML::Axk::Object::TinyDefaults'); ok(!$x->foo, 'No default => falsy (foo)'); ok(!$x->bar, 'No default => falsy (bar)'); $x->{foo} = 42; @@ -35,13 +35,13 @@ sub no_defaults :Tests { # }}}1 # Defaults and field names ======================================== {{{1 package DefaultsAndNames { - use Object::TinyDefaults { foo => 'default' }, qw(foo bar); + use XML::Axk::Object::TinyDefaults { foo => 'default' }, qw(foo bar); } sub defaults_and_names :Tests { my $x = DefaultsAndNames->new(); isa_ok($x, 'DefaultsAndNames'); - isa_ok($x, 'Object::TinyDefaults'); + isa_ok($x, 'XML::Axk::Object::TinyDefaults'); is($x->foo, 'default', 'default (foo)'); ok(!$x->bar, 'no default => falsy (bar)'); $x->{foo} = 42; @@ -53,13 +53,13 @@ sub defaults_and_names :Tests { # }}}1 # Defaults and field names; some names only in defaults =========== {{{1 package DefaultsWithNamesAndNames { - use Object::TinyDefaults { quux => 'default' }, qw(foo bar); + use XML::Axk::Object::TinyDefaults { quux => 'default' }, qw(foo bar); } sub defaults_with_names_and_names :Tests { my $x = DefaultsWithNamesAndNames->new(); isa_ok($x, 'DefaultsWithNamesAndNames'); - isa_ok($x, 'Object::TinyDefaults'); + isa_ok($x, 'XML::Axk::Object::TinyDefaults'); is($x->quux, 'default', 'default (quux)'); ok(!$x->foo, 'no default => falsy (foo)'); ok(!$x->bar, 'no default => falsy (bar)'); @@ -74,13 +74,13 @@ sub defaults_with_names_and_names :Tests { # }}}1 # Defaults only =================================================== {{{1 package DefaultsOnly { - use Object::TinyDefaults { quux => 'default', foo=>42 }; + use XML::Axk::Object::TinyDefaults { quux => 'default', foo=>42 }; } sub defaults_only :Tests { my $x = DefaultsOnly->new(); isa_ok($x, 'DefaultsOnly'); - isa_ok($x, 'Object::TinyDefaults'); + isa_ok($x, 'XML::Axk::Object::TinyDefaults'); is($x->quux, 'default', 'default (quux)'); is($x->foo, 42, 'default (foo)'); $x->{quux} = 'yes';