Skip to content

Commit

Permalink
Add Axk.pm, META_MERGE; move O::TinyDefaults->X::A
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Chris White committed Feb 14, 2019
1 parent 43645d6 commit bfeb5aa
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
55 changes: 50 additions & 5 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <<EOT;
Expand Down Expand Up @@ -52,18 +65,21 @@ testhere: actually_uninstall
EOT

} #postamble
# }}}1

WriteMakefile(
# Main options for EUMM
my %opts = (
NAME => 'XML::Axk',
AUTHOR => q{Christopher White <[email protected]>},
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',
Expand Down Expand Up @@ -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: #
39 changes: 39 additions & 0 deletions lib/XML/Axk.pm
Original file line number Diff line number Diff line change
@@ -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<XML::Axk::App> for command-line usage and L<XML::Axk::Core> for
embedded usage in other Perl scripts.
=cut

# }}}1

1;
__END__
# vi: set fdm=marker: #
3 changes: 2 additions & 1 deletion lib/XML/Axk/App.pm
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!perl
package XML::Axk::App;
use XML::Axk::Base;
use XML::Axk::Core;
Expand All @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion lib/XML/Axk/Core.pm
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/XML/Axk/Matcher/Always.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/XML/Axk/Matcher/XPath.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -11,8 +11,7 @@ use Data::Dumper;
use Import::Into;

our $ObjTiny;
our $VERSION;
$VERSION = '0.01';
our $VERSION = '0.001006';

BEGIN {
require parent;
Expand Down Expand Up @@ -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);
Expand All @@ -98,6 +97,8 @@ C<foo=42> and C<bar=1>.
Requires L<Object::Tiny> or L<Object::Tiny::XS>. XS will be used if available.
TODO replace this with L<Class::Tiny>!
=head1 COPYRIGHT
Copyright (c) 2018 Christopher White. All rights reserved.
Expand Down
12 changes: 7 additions & 5 deletions t/00-load.t
Original file line number Diff line number Diff line change
Expand Up @@ -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: #
22 changes: 11 additions & 11 deletions t/tests/TinyDefaults.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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)');
Expand All @@ -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';
Expand Down

0 comments on commit bfeb5aa

Please sign in to comment.