view release on metacpan or search on metacpan
Rename all .tt files to tt2.
Read files encoded rather than binmode() so I can specify :crlf on
Windows machines.
Go from linux.die.net to man7.org for man links because the latter
does not block Perl and therefore foil Test::Pod::LinkCheck::Lite.
Do not trim object name to 24 chars in pass_ics template.
Harden ::Macro::Code command discovery.
The problem was that in the case of inlineable subroutines (i.e. 'use
constant ...' a reference to the value was the actual value, not the
subroutine .. i.e. a REF, not a GLOB. So when tried to dereference the
CODE slot we blew up.
0.054 2024-03-31 T. R. Wyant
Prefer Astro::Coord::ECI::Utils::gm_strftime to POSIX::strftime
because the behavior of POSIX::strftime when formatting GMT changed in
Perl 5.39.8, and is no longer compatible with the libc implementation,
which does not alter the components given it. This requires
Implement \U and friends inside double quotes, except for \Q. If run
under Perl before version 5.15.8, \F is equivalent to \L.
Add interactive method error(). This aborts the macro or include
file in which it appears, displaying an error message.
Add if() operators -z and -n, which are analogous to the test (1)
operators of the same name.
Macro definitions are no longer unescaped. Unescaping was preventing
the \U ... functionality from working in a macro, and had no known
benefits. I must have put it in there for some reason, but I no
longer know why.
Correct eg/pass_ics to alert before and at rise.
0.041 2019-10-04 T. R. Wyant
Fix validation error caught by Astro::Coord::ECI 0.109_01.
Validate horizon, latitude, and longitude.
Time::y2038 for the benefit of older Perls, and it expects a Perl year.
The fix was to wrap the Time::y2038 calls in code that duplicates
Time::Local's year handling.
Thanks to Slaven Rezic for finding this, and for having smokers
configured with modules like Time::y2038 (which is optional for this
package) so that he _could_ find it. Kudos!
Better diagnostics for Date::Manip::DM5 test fails
Fix deep recursion in ::Macro->wail() & friends
Support formatting times with any class conforming to the DateTime
interface, via formatter attribute 'back_end'. If
DateTime::Calendar::Christian is used her, require version 0.06.
Support using DateTime (if available) to convert a parsed ISO-8601
time to epoch. An arbitrary class confirming to the DateTime
interface can be used instead, if specified.
Support era indicators (AD/BC, CE/BCE) suffixed to year in the
Improve tests that compare path to expected, to handle better the case
where the path contains a symbolic link.
Fixed failure in Astro::App::Satpass2::Format->decode(
'desired_equinox_dynamical' ) when the value was not 0.
In file name expansion, made ~~/... expand to configuration directory.
Added the ability to implement a macro as Perl code. These are handled
by Astro::App::Satpass2::Macro::Code. The corresponding satpass2
syntax is 'macro load Module_name'. Document this in TUTORIAL.
Updated required version of Astro::SpaceTrack to one that supports the
REST interface.
Require Astro::Coord::ECI 0.57 because of the international launch
designator problems introduced in 0.051_01.
Make load_package() optionally callable as a method so it can use the
same error reporting mechanism as everyone else if it is available.
Build.PL
Changes
eg/almanac
eg/es.pm
eg/flare_vcalendar
eg/My/Macros.pm
eg/pass_ics
eg/quarters_vcalendar
eg/README
eg/tle_celestia.tt2
eg/tle_json.tt2
eg/tle_stellarium.tt2
inc/My/Module/Build.pm
inc/My/Module/Meta.pm
inc/My/Module/Recommend.pm
inc/My/Module/Recommend/All.pm
lib/Astro/App/Satpass2/FormatTime/DateTime/Cldr.pm
lib/Astro/App/Satpass2/FormatTime/DateTime/Strftime.pm
lib/Astro/App/Satpass2/FormatTime/POSIX/Strftime.pm
lib/Astro/App/Satpass2/FormatTime/Strftime.pm
lib/Astro/App/Satpass2/FormatValue.pm
lib/Astro/App/Satpass2/FormatValue/Formatter.pm
lib/Astro/App/Satpass2/Geocode.pm
lib/Astro/App/Satpass2/Geocode/OSM.pm
lib/Astro/App/Satpass2/Locale.pm
lib/Astro/App/Satpass2/Locale/C.pm
lib/Astro/App/Satpass2/Macro.pm
lib/Astro/App/Satpass2/Macro/Code.pm
lib/Astro/App/Satpass2/Macro/Command.pm
lib/Astro/App/Satpass2/ParseTime.pm
lib/Astro/App/Satpass2/ParseTime/Code.pm
lib/Astro/App/Satpass2/ParseTime/Date/Manip.pm
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v5.pm
lib/Astro/App/Satpass2/ParseTime/Date/Manip/v6.pm
lib/Astro/App/Satpass2/ParseTime/ISO8601.pm
lib/Astro/App/Satpass2/TUTORIAL.pod
lib/Astro/App/Satpass2/Utils.pm
lib/Astro/App/Satpass2/Warner.pm
lib/Astro/App/Satpass2/Wrap/Array.pm
"version" : "0.056"
},
"Astro::App::Satpass2::Locale" : {
"file" : "lib/Astro/App/Satpass2/Locale.pm",
"version" : "0.056"
},
"Astro::App::Satpass2::Locale::C" : {
"file" : "lib/Astro/App/Satpass2/Locale/C.pm",
"version" : "0.056"
},
"Astro::App::Satpass2::Macro" : {
"file" : "lib/Astro/App/Satpass2/Macro.pm",
"version" : "0.056"
},
"Astro::App::Satpass2::Macro::Code" : {
"file" : "lib/Astro/App/Satpass2/Macro/Code.pm",
"version" : "0.056"
},
"Astro::App::Satpass2::Macro::Command" : {
"file" : "lib/Astro/App/Satpass2/Macro/Command.pm",
"version" : "0.056"
},
"Astro::App::Satpass2::ParseTime" : {
"file" : "lib/Astro/App/Satpass2/ParseTime.pm",
"version" : "0.056"
},
"Astro::App::Satpass2::ParseTime::Code" : {
"file" : "lib/Astro/App/Satpass2/ParseTime/Code.pm",
"version" : "0.056"
},
version: '0.056'
Astro::App::Satpass2::Geocode::OSM:
file: lib/Astro/App/Satpass2/Geocode/OSM.pm
version: '0.056'
Astro::App::Satpass2::Locale:
file: lib/Astro/App/Satpass2/Locale.pm
version: '0.056'
Astro::App::Satpass2::Locale::C:
file: lib/Astro/App/Satpass2/Locale/C.pm
version: '0.056'
Astro::App::Satpass2::Macro:
file: lib/Astro/App/Satpass2/Macro.pm
version: '0.056'
Astro::App::Satpass2::Macro::Code:
file: lib/Astro/App/Satpass2/Macro/Code.pm
version: '0.056'
Astro::App::Satpass2::Macro::Command:
file: lib/Astro/App/Satpass2/Macro/Command.pm
version: '0.056'
Astro::App::Satpass2::ParseTime:
file: lib/Astro/App/Satpass2/ParseTime.pm
version: '0.056'
Astro::App::Satpass2::ParseTime::Code:
file: lib/Astro/App/Satpass2/ParseTime/Code.pm
version: '0.056'
Astro::App::Satpass2::ParseTime::Date::Manip:
file: lib/Astro/App/Satpass2/ParseTime/Date/Manip.pm
version: '0.056'
eg/My/Macros.pm view on Meta::CPAN
package My::Macros;
use 5.008;
use strict;
use warnings;
use parent qw{ Astro::App::Satpass2 };
use Astro::App::Satpass2::Utils qw{ __arguments };
use Astro::Coord::ECI::Utils 0.059 qw{ rad2deg };
eg/My/Macros.pm view on Meta::CPAN
use YAML;
return ref( $self ) . "\n" . Dump( \@args );
}
1;
__END__
=head1 NAME
My::Macros - Implement 'macros' using code.
=head1 SYNOPSIS
The following assumes this file is actually findable in C<@INC>:
satpass2> macro load My::Macros
satpass2> hi Yehudi
Hello, Yehudi!
satpass2> angle sun moon -places 2
102.12
satpass2>
=head1 DESCRIPTION
This Perl package defines code macros for Astro::App::Satpass2. These
are implemented as subroutines, but do not appear as methods of
eg/My/Macros.pm view on Meta::CPAN
Instead it causes the Polish notation code to terminate.
=back
There are no options.
=head1 SEE ALSO
L<Astro::App::Satpass2|Astro::App::Satpass2>
L<Astro::App::Satpass2::Macro::Code|Astro::App::Satpass2::Macro::Code>.
The L<Code Macros|Astro::App::Satpass2::TUTORIAL/Code Macros> write-up
in the L<TUTORIAL|Astro::App::Satpass2::TUTORIAL>.
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2>,
L<https://github.com/trwyant/perl-Astro-App-Satpass2/issues>, or in
electronic mail to the author.
=head1 AUTHOR
have been loaded, and displays the results in vCalendar format.
CAVEAT: My ancient Palm desktop software appears not to properly
handle the switch between normal and daylight-saving time
(a.k.a. summer time), in that predictions made before the switch
for events after the switch get assigned the wrong time, even
though the UT event time is correct in the emitted file. I have
not changed the event times to local times in eg/flare_vcalendar
because the vcalendar standard specifies UT.
My/Macros.pm - A module that implements the following code macros
* angle - Given the names or OIDs of two objects (either
satellites or background bodies like the Moon or Sun)
computes the angle between them at the time specified by
the third argument, which defaults to the current time.
Options specify radians or degrees, and the number of
decimal places.
* hi - A 'hello world' macro. It takes one argument, which
defaults to 'world'.
* test - A macro that issues a command (or not) based on whether
or not specified conditions are met.
lib/Astro/App/Satpass2.pm view on Meta::CPAN
package Astro::App::Satpass2;
use 5.008;
use strict;
use warnings;
use Astro::App::Satpass2::Locale qw{ __localize };
use Astro::App::Satpass2::Macro::Command;
use Astro::App::Satpass2::Macro::Code;
use Astro::App::Satpass2::ParseTime;
use Astro::App::Satpass2::Utils qw{
:os
:ref
__arguments __legal_options
expand_tilde find_package_pod
has_method instance load_package
my_dist_config quoter
__parse_class_and_args
};
lib/Astro/App/Satpass2.pm view on Meta::CPAN
or return $self->__wail( 'You must provide a definition for the macro' );
$name !~ m/ \W /smx
and $name !~ m/ \A _ /smx
or return $self->__wail("Invalid macro name '$name'");
# NOTE the value of {def} used to be unescaped, but I do not now
# know why, and the implementation of \U and friends is more natural
# with this stripped out.
$self->{macro}{$name} =
Astro::App::Satpass2::Macro::Command->new(
name => $name,
parent => $self,
completion => $opt->{completion},
def => \@args,
generate => \&_macro_define_generator,
level1 => $self->{frame}[-1]{level1},
warner => $self->{_warner},
);
return $output;
}
sub _macro_define_generator {
my ( $self, @args ) = @_; # $self if Macro object
my $output;
foreach my $macro ( @args ) {
if ( my $comp = $self->completion() ) {
$output .= "macro define \\\n " .
"--completion '@$comp' \\\n " .
"$macro \\\n ";
} else {
$output .= "macro define $macro \\\n ";
}
$output .= join( " \\\n ", map { quoter( $_ ) } $self->def() ) .
lib/Astro/App/Satpass2.pm view on Meta::CPAN
or $self->wail( 'Must provide name of macro to load' );
my %marg = (
name => $name,
parent => $self,
generate => \&_macro_load_generator,
warner => $self->{_warner},
);
exists $opt->{lib}
and $marg{lib} = $opt->{lib};
my $obj = $self->{_macro_load}{$name} ||=
Astro::App::Satpass2::Macro::Code->new( %marg );
foreach my $mn ( @args ? @args : $obj->implements() ) {
$obj->implements( $mn, required => 1 )
and $self->{macro}{$mn} = $obj;
}
if ( $opt->{verbose} ) {
( my $fn = "$name.pm" ) =~ s| :: |/|smxg;
$output .= "Macro $name\n loaded from $INC{$fn}\n";
$output .= " implements:\n";
$output .= " $_\n" for sort $obj->implements();
}
$obj->implements( 'after_load', required => 0 )
and $output .= $self->dispatch( after_load => $opt, $name, @args );
return $output;
}
sub _macro_load_generator {
my ( $self, @args ) = @_;
lib/Astro/App/Satpass2.pm view on Meta::CPAN
};
my $condition = exists $opt->{condition} ?
$opt->{condition} :
$prior->{condition};
#### defined $stdout or $stdout = select();
my ( undef, $filename, $line ) = caller;
push @{$self->{frame}}, {
type => $type,
args => $args,
condition => $condition,
define => {}, # Macro defaults done with :=
local => {},
localout => undef, # Output for statement.
macro => {},
pushed_by => "$filename line $line",
spacetrack => {},
stdout => $prior->{localout} || $prior->{stdout},
unsatisfied_if => $prior->{unsatisfied_if} || ! $condition,
};
return $frames;
}
lib/Astro/App/Satpass2.pm view on Meta::CPAN
=item -completion
This option specifies a space-delimited list of completions for the
macro arguments. It can be specified more than once, in which case all
completion specifications will be concatenated.
=back
The first argument of the C<'load'> subcommand is the name of a Perl
module (e.g. C<My::Macros>) that implements one or more code macros.
Subsequent arguments, if any, are the names of macros to load from the
module. If no subsequent arguments are given, all macros defined by the
macro are loaded.
The C<'load'> subcommand supports the following options:
=over
=item -lib
lib/Astro/App/Satpass2.pm view on Meta::CPAN
Code macros are experimental. See
L<Astro::App::Satpass2::TUTORIAL|Astro::App::Satpass2::TUTORIAL> for how
to write one.
For subcommands other than C<'define'> and C<'load'>, the arguments are
macro names.
The C<brief> and C<list> subcommands return their documented output. The
C<delete> and C<define> subcommands return nothing.
Macros can be called programmatically via the L<dispatch()|/dispatch>
method.
=head2 magnitude_table
$output = $satpass2->magnitude_table( $subcommand, ... );
satpass2> magnitude_table subcommand ...
This interactive method manipulates the satellite magnitude table. This
provides intrinsic magnitudes for satellites loaded via the
L<load()|/load> method. The arguments are a subcommand (defaulting to
lib/Astro/App/Satpass2/Format.pm view on Meta::CPAN
$self->warner( delete $args{warner} );
$class eq __PACKAGE__
and 'My::Module::Test::App' ne caller
and $self->wail( __PACKAGE__,
' may not be instantiated. Use a subclass' );
$self->{parent} = delete $args{parent};
# FIXME the below is verbatim from
# Astro::App::Satpass2::Macro->init(), ca. line 63.
defined $self->{parent}
or $self->wail( q{Attribute 'parent' is required} );
instance( $self->{parent}, 'Astro::App::Satpass2' )
or $self->wail( q{Attribute 'parent' must be an Astro::App::Satpass2} );
weaken( $self->{parent} );
exists $args{tz} or $args{tz} = $ENV{TZ};
$self->time_formatter( delete $args{time_formatter} );
$self->time_formatter()->warner( $self->warner() );
lib/Astro/App/Satpass2/Macro.pm view on Meta::CPAN
package Astro::App::Satpass2::Macro;
use 5.008;
use strict;
use warnings;
use Astro::App::Satpass2::Utils qw{
instance
CODE_REF
@CARP_NOT
lib/Astro/App/Satpass2/Macro.pm view on Meta::CPAN
sub __level1_rewrite {
return;
}
1;
__END__
=head1 NAME
Astro::App::Satpass2::Macro - Implement a macro
=head1 SYNOPSIS
No user-serviceable parts inside.
=head1 DESCRIPTION
This is an abstract class to implement macros.
=head1 METHODS
This class supports the following public methods:
=head2 new
my $macro = Astro::App::Satpass2::Macro->new( name => 'Foo' );
This static method returns a new macro object. The arguments are
pairs of attribute names and values. An exception will be thrown if the
object can not be constructed.
=head2 execute
print $macro->execute( $name, @args );
This method executes the named macro, passing it the given arguments.
lib/Astro/App/Satpass2/Macro/Code.pm view on Meta::CPAN
package Astro::App::Satpass2::Macro::Code;
use 5.008;
use strict;
use warnings;
use parent qw{ Astro::App::Satpass2::Macro };
use Astro::App::Satpass2::Utils qw{
expand_tilde
load_package
quoter
@CARP_NOT
};
use File::Spec;
our $VERSION = '0.056';
lib/Astro/App/Satpass2/Macro/Code.pm view on Meta::CPAN
$self->SUPER::init();
my $parent = $self->parent();
my %popt = ( complaint => 'wail', fatal => 'wail' );
exists $self->{lib}
and $popt{lib} = $self->expand_tilde( $self->{lib} );
defined $self->{lib}
and not $self->{relative}
and not $self->{lib} =~ m/ \A ~ /smx
and $self->{lib} = File::Spec->rel2abs( $self->{lib} );
my $module = $self->load_package(
\%popt, $self->name(), 'Astro::App::Satpass2::Macro::Code'
);
$module->isa( 'Astro::App::Satpass2' )
or $self->wail( "$module is not a subclass of Astro::App::Satpass2" );
my %implements; # Names and references to found code
my $stb = "${module}::"; # Name of loaded symbol table
# Fairly deep magic begins here. We need symbolic references to
# traverse the symbol table of the loaded code, so:
no strict qw{ refs };
lib/Astro/App/Satpass2/Macro/Code.pm view on Meta::CPAN
my ( $self ) = @_;
return $self->{relative};
}
1;
__END__
=head1 NAME
Astro::App::Satpass2::Macro::Code - Implement code as macros
=head1 SYNOPSIS
No user-serviceable parts inside.
=head1 DESCRIPTION
This class is private to the C<Astro-App-Satpass2> distribution, mostly
because the code interface has not been written.
lib/Astro/App/Satpass2/Macro/Code.pm view on Meta::CPAN
caller.
=head2 has_lib
This method returns true if the C<lib> attribute was specified when the
class was created.
=head2 init
This method treats the C<name> attribute as the name of a module to be
loaded (either with or without C<'Astro::App::Satpass2::Macro::Code::'>
prepended). This module must be a subclass of C<Astro::App::Satpass2>.
The loaded module's symbol table is examined, and the C<implements>
attribute is populated with names of and references to any code that has
the C<Verb> attribute.
Note that this means the C<implements( $name )> method returns a
reference to the implementing code if C<$name> is actually implemented;
but users of this module should not rely on this behavior.
=head1 ATTRIBUTES
lib/Astro/App/Satpass2/Macro/Code.pm view on Meta::CPAN
left untouched. Otherwise, it is made into an absolute file reference
unless it begins with a tilde.
This is really only here to make testing easier.
=back
=head1 SEE ALSO
The superclass,
L<Astro::App::Satpass2::Macro|Astro::App::Satpass2::Macro>.
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2>,
L<https://github.com/trwyant/perl-Astro-App-Satpass2/issues>, or in
electronic mail to the author.
=head1 AUTHOR
lib/Astro/App/Satpass2/Macro/Command.pm view on Meta::CPAN
package Astro::App::Satpass2::Macro::Command;
use 5.008;
use strict;
use warnings;
use parent qw{ Astro::App::Satpass2::Macro };
use Astro::App::Satpass2::Utils qw{ quoter ARRAY_REF @CARP_NOT };
our $VERSION = '0.056';
sub execute {
my ( $self, $name ) = @_;
$self->implements( $name )
or $self->weep( "'$name' not implemented by this object" );
my $satpass2 = $self->parent();
lib/Astro/App/Satpass2/Macro/Command.pm view on Meta::CPAN
return;
}
1;
__END__
=head1 NAME
Astro::App::Satpass2::Macro::Command - Define a macro which consists of an array of commands
=head1 SYNOPSIS
No user-serviceable parts inside.
=head1 DESCRIPTION
This class is private to the Astro-App-Satpass2 distribution.
Documentation is for the benefit of the author only.
lib/Astro/App/Satpass2/Macro/Command.pm view on Meta::CPAN
The same-named method can be used to access this. The method returns an
array in list context, or an array reference in scalar context. Either
way the return is a copy of the definition; you can not access (and
therefore modify) the commands issued by the macro using the data
returned by this method.
=head1 SEE ALSO
The superclass,
L<Astro::App::Satpass2::Macro|Astro::App::Satpass2::Macro>.
=head1 SUPPORT
Support is by the author. Please file bug reports at
L<https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2>,
L<https://github.com/trwyant/perl-Astro-App-Satpass2/issues>, or in
electronic mail to the author.
=head1 AUTHOR
lib/Astro/App/Satpass2/TUTORIAL.pod view on Meta::CPAN
Similarly, if you install the optional L<Date::Manip|Date::Manip>
module, you can set a default input zone other than your own by
something like
satpass2> time_parser tz MST7MDT
The C<time_parser> and C<formatter> time zones are set separately not
only so that you can make them different, but because the author can not
guarantee that the underlying modules will accept the same settings.
=head2 Command Macros
A command macro is simply a named set of C<Astro::App::Satpass2>
commands, somewhat like a C<bash> shell function. A command macro is
executed by giving its name, so in essence command macros are ways of
creating new commands.
The definition of a macro is simply the list of commands it issues. Each
command is a single argument, and therefore probably needs to be quoted.
When the command to be issued itself contains quotes, you either use a
different style (single versus double quotes) or you escape the quote
lib/Astro/App/Satpass2/TUTORIAL.pod view on Meta::CPAN
> [%= data.elevation %]
> EOD
See the
L<Astro::App::Satpass2::FormatValue|Astro::App::Satpass2::FormatValue>
documentation for what format effectors are available. Inside the
template, the C<data> object will contain the data you want to format.
=head1 ADVANCED TOPICS
=head2 Code Macros
In addition to L<Command Macros|/Command Macros>, a macro can be defined
using Perl code. This allows one to add new functionality to
C<Astro::App::Satpass2>, over and above that provided by interactive
methods.
Code macros are currently unsupported, though it might be better to call
them experimental. The real situation is that I have been looking for
ways to plug bits of code into the system, and handling them like macros
seemed to be the best way. So I knocked something together along those
lines, and played with it. Further experience may show that the
interface or the implementation was ill-chosen, or even that there is
lib/Astro/App/Satpass2/Utils.pm view on Meta::CPAN
Astro::App::Satpass2::FormatTime::DateTime::Cldr
Astro::App::Satpass2::FormatTime::DateTime::Strftime
Astro::App::Satpass2::FormatTime::POSIX::Strftime
Astro::App::Satpass2::FormatTime::Strftime
Astro::App::Satpass2::FormatValue
Astro::App::Satpass2::FormatValue::Formatter
Astro::App::Satpass2::Geocode
Astro::App::Satpass2::Geocode::OSM
Astro::App::Satpass2::Locale
Astro::App::Satpass2::Locale::C
Astro::App::Satpass2::Macro
Astro::App::Satpass2::Macro::Code
Astro::App::Satpass2::Macro::Command
Astro::App::Satpass2::ParseTime
Astro::App::Satpass2::ParseTime::Code
Astro::App::Satpass2::ParseTime::Date::Manip
Astro::App::Satpass2::ParseTime::Date::Manip::v5
Astro::App::Satpass2::ParseTime::Date::Manip::v6
Astro::App::Satpass2::ParseTime::ISO8601
Astro::App::Satpass2::Utils
Astro::App::Satpass2::Warner
Astro::App::Satpass2::Wrap::Array
};
require_ok 'Astro::App::Satpass2::Warner';
can_ok 'Astro::App::Satpass2::Warner',
qw{ new wail warning weep whinge };
require_ok 'Astro::App::Satpass2::Copier';
can_ok 'Astro::App::Satpass2::Copier', @copier_methods;
require_ok 'Astro::App::Satpass2::Macro';
require_ok 'Astro::App::Satpass2::Macro::Command';
isa_ok 'Astro::App::Satpass2::Macro::Command',
'Astro::App::Satpass2::Macro';
require_ok 'Astro::App::Satpass2::Macro::Code';
isa_ok 'Astro::App::Satpass2::Macro::Code',
'Astro::App::Satpass2::Macro';
require_ok 'Astro::App::Satpass2::FormatTime';
isa_ok 'Astro::App::Satpass2::FormatTime', 'Astro::App::Satpass2::Copier';
can_ok 'Astro::App::Satpass2::FormatTime', @format_time_methods;
require_ok 'Astro::App::Satpass2::FormatTime::POSIX::Strftime';
t/macro_code.t view on Meta::CPAN
use 5.008;
use strict;
use warnings;
use lib qw{ inc };
use My::Module::Test::App; # For environment clean-up
use Astro::App::Satpass2;
use Astro::App::Satpass2::Utils ();
use Astro::App::Satpass2::Macro::Code;
use Test2::V0;
use constant LIB_DIR => 'eg';
-d LIB_DIR
or skip_all "Can not find @{[ LIB_DIR ]}/ directory";
my ( $mac, $sp );
eval {
t/macro_code.t view on Meta::CPAN
$sp->set(
location => '1600 Pennsylvania Ave NW Washington DC 20502',
latitude => 38.898748,
longitude => -77.037684,
height => 16.68,
);
1;
} or skip_all "Can not instantiate Satpass2: $@";
eval {
$mac = Astro::App::Satpass2::Macro::Code->new(
lib => LIB_DIR,
relative => 1,
name => 'My::Macros',
generate => \&Astro::App::Satpass2::_macro_load_generator,
parent => $sp,
warner => $sp->{_warner}, # TODO Encapsulation violation
);
1;
} or skip_all "Can not instantiate macro: $@";
cmp_ok scalar $mac->implements(), '==', 5, 'Module implements 5 macros';
ok $mac->implements( 'after_load' ), 'Module implements after_load()';
ok $mac->implements( 'angle' ), 'Module implements angle()';
ok $mac->implements( 'dumper' ), 'Module implements dumper()';
ok $mac->implements( 'hi' ), 'Module implements hi()';
ok $mac->implements( 'test' ), 'Module implements test()';
is $mac->generator(), <<'EOD', 'Module serializes correctly';
macro load -lib eg -relative My::Macros after_load
macro load -lib eg -relative My::Macros angle
macro load -lib eg -relative My::Macros dumper
macro load -lib eg -relative My::Macros hi
macro load -lib eg -relative My::Macros test
EOD
is $mac->generator( 'angle' ), <<'EOD', 'Single macro serializes';
macro load -lib eg -relative My::Macros angle
EOD
is $mac->execute( hi => 'sailor' ), <<'EOD', q{Macro 'hi' executes};
Hello, sailor!
EOD
eval {
is $mac->execute(
qw{ angle -places 2 sun moon 20130401T120000Z } ),
<<'EOD', q{Macro 'angle' executes with command options};
112.73
EOD
1;
} or diag "Macro 'angle' failed: $@";
eval {
is $mac->execute(
angle => { places => 3 }, qw{ sun moon 20130401T120000Z } ),
<<'EOD', q{Macro 'angle' executes with hash ref options};
112.727
EOD
1;
} or diag "Macro 'angle' failed: $@";
{
my $warning = '';
local $SIG{__WARN__} = sub {
$warning = $_[0];
return;
};
my $msg = 'By the pricking of my thumbs';