App-perlrdf

 view release on metacpan or  search on metacpan

lib/App/perlrdf/Command/StoreTruncate.pm  view on Meta::CPAN

use constant command_names => qw( store_truncate truncate );
use constant description   => <<'INTRO' . __PACKAGE__->store_help . <<'DESCRIPTION';
Delete data from an RDF::Trine::Store.
INTRO

Note that because multiple stores may share a database, the 'nuke' option
does not currently drop the database; it just removes the table which holds
RDF quads.

When one or more graph URIs are specified, the 'nuke' option is ignored,
and prompts are skipped.
DESCRIPTION

use constant opt_spec => (
	__PACKAGE__->store_opt_spec,
	[]=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>=>,
	[ 'graph|g=s@',        'Graph(s) to delete (default: all graphs)' ],
	[ 'yes',               'Answer "yes" to prompts' ],
	[ 'nuke',              'Delete the entire store' ],
);

sub execute
{
	require RDF::Trine;
	require App::perlrdf::FileSpec::OutputRDF;
	
	my ($self, $opt, $arg) = @_;

lib/App/perlrdf/Command/StoreTruncate.pm  view on Meta::CPAN

			my $graph = RDF::Trine::Node::Resource->new($_);
			$model->remove_statements((undef)x3, $graph);
		}
		
		printf STDERR "'nuke' ignored when 'graph' specified\n"
			if $opt->{nuke};
	}
	
	else
	{
		if ($opt->{yes} or prompt_yn("Really delete all data from this store?"))
		{
			$model->remove_statements((undef)x4);
		}
		
		if ($opt->{nuke})
		{
			if ($opt->{yes} or prompt_yn("Really nuke this store?"))
			{
				$store->nuke;
			}
		}
	}
}

1;



( run in 0.491 second using v1.01-cache-2.11-cpan-0b5f733616e )