| Youri-Media documentation | Contained in the Youri-Media distribution. |
Youri::Media - Abstract media class
This abstract class defines Youri::Media interface.
Creates and returns a new Youri::Media object.
Generic parameters:
Media id.
Media name.
Media type.
Test mode (default: false).
Verbose mode (default: false).
Hash of test-specific options.
List of tests to skip.
List of arches to skip.
Subclass may define additional parameters.
Warning: do not call directly, call subclass constructor instead.
Returns media identity.
Returns the name of this media.
Returns the type of this media.
Returns a specific option for given test.
Returns the list of arch which are to be skipped for this media.
Tells wether given arch is to be skipped for this media.
Returns the list of id of test which are to be skipped for this media.
Tells wether test with given id is to be skipped for this media.
Return package class for this media.
Apply given function to all files of this media.
Apply given function to all headers, partially parsed, of this media.
Apply given function to all headers, fully parsed, of this media.
The following methods have to be implemented:
Copyright (C) 2002-2006, YOURI project
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Youri-Media documentation | Contained in the Youri-Media distribution. |
# $Id: /mirror/youri/soft/Media/trunk/lib/Youri/Media.pm 2367 2007-04-22T18:47:34.552172Z guillomovitch $ package Youri::Media;
use Carp; use strict; use warnings; use version; our $VERSION = qv('0.2.1');
sub new { my $class = shift; croak "Abstract class" if $class eq __PACKAGE__; my %options = ( name => '', # media name canonical_name => '', # media canonical name type => '', # media type test => 0, # test mode verbose => 0, # verbose mode options => undef, @_ ); croak "No type given" unless $options{type}; croak "Wrong value for type: $options{type}" unless $options{type} =~ /^(?:binary|source)$/; # some options need to be arrays. Check it and convert to hashes foreach my $option (qw(skip_archs skip_tests)) { next unless defined $options{$option}; croak "$option should be an arrayref" unless ref $options{$option} eq 'ARRAY'; $options{$option} = { map { $_ => 1 } @{$options{$option}} }; } croak "options should be an hashref" if $options{options} && ref $options{options} ne 'HASH'; my $self = bless { _id => $options{id}, _verbose => $options{verbose}, _name => $options{name} || $options{id}, _type => $options{type}, _options => $options{options}, _skip_archs => $options{skip_archs}, _skip_tests => $options{skip_tests}, }, $class; $self->_init(%options); # remove unwanted archs if ($options{skip_archs}->{all}) { $self->_remove_all_archs() } elsif ($options{skip_archs}) { $self->_remove_archs($options{skip_archs}); } return $self; } sub _init { # do nothing }
sub get_id { my ($self) = @_; croak "Not a class method" unless ref $self; return $self->{_id}; }
sub get_name { my ($self) = @_; croak "Not a class method" unless ref $self; return $self->{_name}; }
sub get_type { my ($self) = @_; croak "Not a class method" unless ref $self; return $self->{_type}; }
sub get_option { my ($self, $test, $option) = @_; croak "Not a class method" unless ref $self; return $self->{_options}->{$test}->{$option}; }
sub skip_archs { my ($self) = @_; croak "Not a class method" unless ref $self; return keys %{$self->{_skip_archs}}; }
sub skip_arch { my ($self, $arch) = @_; croak "Not a class method" unless ref $self; return $self->{_skip_archs}->{all} || $self->{_skip_archs}->{$arch}; }
sub skip_tests { my ($self) = @_; croak "Not a class method" unless ref $self; return keys %{$self->{_skip_tests}}; }
sub skip_test { my ($self, $test) = @_; croak "Not a class method" unless ref $self; return $self->{_skip_tests}->{all} || $self->{_skip_tests}->{$test}; }
1;