Mac-Pasteboard

 view release on metacpan or  search on metacpan

inc/My/Module/Test.pm  view on Meta::CPAN


    eval {
	require Mac::Pasteboard;
	1;
    } or plan skip_all => 'Can not load Mac::Pasteboard';

    Mac::Pasteboard->set( fatal => 0 );
    Mac::Pasteboard->new();
    Mac::Pasteboard->get( 'status' ) ==
    Mac::Pasteboard::coreFoundationUnknownErr()
	and plan skip_all => 'No access to desktop (maybe running as ssh session or cron job?)';
    Mac::Pasteboard->set( fatal => 1 );

    return;
}

{
    my $do_utf = eval {
	require POSIX;
	my ( $rls ) = split qr{ [.] }smx, ( POSIX::uname() )[2];
	$rls >= 12;	# Mountain Lion.

lib/Mac/Pasteboard.pm  view on Meta::CPAN

stale data from the pasteboard. Because this module is supposed to
synchronize before fetching, it represents either a bug or a race
condition. It is not a dualvar -- it just represents the number of the
error, which is -25130.

=head3 coreFoundationUnknownErr

This constant represents B<the> unknown error, not just B<an> unknown
error. One would think you would never get this from Apple's code, but
it appears that you will get this error if the caller does not have
access to the desktop. For example, you can get this error in a script
running over an ssh connection, or in a cron job.

B<This constant is not exported with the :const tag,> because there are
other places it could potentially come from. If you want it, you will
need to import it explicitly. It is not a dualvar -- it just represents
the number of the error, which is -4960.

=head3 noPasteboardPromiseKeeperErr

This constant represents the error returned when the user tries to place

t/basic.t  view on Meta::CPAN

require_ok 'Mac::Pasteboard'
    or BAIL_OUT 'Can not continue without loadable Mac::Pasteboard';

SKIP: {
    Mac::Pasteboard->set( fatal => 0 );
    if ( my $pb = Mac::Pasteboard->new() ) {
	isa_ok $pb, 'Mac::Pasteboard'
    } else {
	my $status = Mac::Pasteboard->get( 'status' );
	$status == Mac::Pasteboard::coreFoundationUnknownErr()
	    and skip 'No access to desktop (maybe running as ssh session or cron job?)', 1;
	fail "Failed to instantiate Mac::Pasteboard: $status";
    }
    Mac::Pasteboard->set( fatal => 1 );
}

is( Mac::Pasteboard->flavor_flag_names( 0 ), 'kPasteboardFlavorNoFlags',
    'Flavor flag 0 is kPasteboardFlavorNoFlags' );

is( Mac::Pasteboard->flavor_flag_names( 1 ), 'kPasteboardFlavorSenderOnly',
    'Flavor flag 1 is kPasteboardFlavorSenderOnly' );

t/error.tx  view on Meta::CPAN

use warnings;

use Mac::Pasteboard qw{coreFoundationUnknownErr};
use Test::More 0.88;

sub test_error (@);	## no critic (ProhibitSubroutinePrototypes)

Mac::Pasteboard->set (fatal => 0);
my $pb = Mac::Pasteboard->new ();
if (Mac::Pasteboard->get ('status') == coreFoundationUnknownErr) {
    plan skip_all => 'No access to desktop (maybe running as ssh session or cron job?)';
    exit;
}
$pb or die Mac::Pasteboard->get ('status');

$pb->clear ();
my $data;
eval {
    $data = $pb->paste();
    1;
} or do {

t/misc.tx  view on Meta::CPAN

use strict;
use warnings;

use Mac::Pasteboard qw{:all};
use Test::More 0.88;

{
    Mac::Pasteboard->set (fatal => 0);
    Mac::Pasteboard->new ();
    if (Mac::Pasteboard->get ('status') == coreFoundationUnknownErr ()) {
	plan skip_all => 'No access to desktop (maybe running as ssh session or cron job?)';
	exit;
    }
    Mac::Pasteboard->set (fatal => 1);
}

{
    my $text = 'Deck us all with Boston Charlie';
    my $orig = Mac::Pasteboard->new (kPasteboardUniqueName);

    ok $orig, 'Instantiate unique-named pasteboard';

t/synch.tx  view on Meta::CPAN


`pbcopy -help 2>&1`;
if ($?) {
    plan skip_all => 'Pbcopy program not found.';
    exit;
}

Mac::Pasteboard->set (fatal => 0);
my $pb = Mac::Pasteboard->new ();
if (Mac::Pasteboard->get ('status') == coreFoundationUnknownErr) {
    plan skip_all => 'No access to desktop (maybe running as ssh session or cron job?)';
    exit;
}
$pb or die Mac::Pasteboard->get ('status');

{
    open (my $fh, '|-', 'pbcopy')
	or die "Unable to open pipe to pbcopy: $!\n";
    print $fh <<eod;
The Bustard's a genial fowl,
With minimal reason to growl.



( run in 0.429 second using v1.01-cache-2.11-cpan-299005ec8e3 )