Net-Flickr-Backup

 view release on metacpan or  search on metacpan

lib/Net/Flickr/Backup.pm  view on Meta::CPAN

#pod
#pod =over 4
#pod
#pod =item C<computer>
#pod
#pod x-urn:B<$OSNAME>: (where $OSNAME is the value of C<$^O>)
#pod
#pod =back
#pod
#pod =cut

sub namespaces {
  my $self = shift;
  my %ns = %{$self->SUPER::namespaces};
  $ns{computer} = sprintf "x-urn:%s:", $^O;
  return (wantarray) ? %ns : \%ns;
}

#pod =head2 $obj->namespace_prefix($uri)
#pod
#pod Return the namespace prefix for I<$uri>
#pod
#pod =cut

# Defined in Net::Flickr::RDF

#pod =head2 $obj->uri_shortform($prefix,$name)
#pod
#pod Returns a string in the form of I<prefix>:I<property>. The property is
#pod the value of $name. The prefix passed may or may be the same as the prefix
#pod returned depending on whether or not the user has defined or redefined their
#pod own list of namespaces.
#pod
#pod The prefix passed to the method is assumed to be one of prefixes in the
#pod B<default> list of namespaces.
#pod
#pod =cut

# Defined in Net::Flickr::RDF

#pod =head2 $obj->make_photo_triples(\%data)
#pod
#pod Returns an array ref of array refs of the meta data associated with a
#pod photo (I<%data>).
#pod
#pod If any errors are unencounter an error is recorded via the B<log>
#pod method and the method returns undef.
#pod
#pod =cut

sub make_photo_triples {
  my $self = shift;
  my $data = shift;

  my $triples = $self->SUPER::make_photo_triples($data);

  if (! $triples) {
    return undef;
  }

  my $user_id     = (getpwuid($>))[0];
  my $os_uri      = sprintf("x-urn:%s:",$^O);
  my $user_uri    = $os_uri."user";

  my $creator_uri = sprintf("x-urn:%s#%s", $self->hostname_short, $user_id);

  push @$triples, [$user_uri, $self->uri_shortform("rdfs", "subClassOf"), "http://xmlns.com/foaf/0.1/Person"];

  foreach my $label (keys %{$self->{__files}}) {

    my $uri   = "file://".$self->{__files}->{$label};
    my $photo = sprintf("%s%s/%s", $FLICKR_URL_PHOTOS, $data->{user_id}, $data->{photo_id});

    push @$triples, [$uri, $self->uri_shortform("rdfs", "seeAlso"), $photo];
    push @$triples, [$uri, $self->uri_shortform("dc", "creator"), $creator_uri];
    push @$triples, [$uri, $self->uri_shortform("dcterms", "created"), _w3cdtf() ];
  }

  push @$triples, [$creator_uri, $self->uri_shortform("foaf", "name"), (getpwuid($>))[6]];
  push @$triples, [$creator_uri, $self->uri_shortform("foaf", "nick"), $user_id];
  push @$triples, [$creator_uri, $self->uri_shortform("rdf", "type"), "computer:user"];

  return $triples;
}

sub hostname_short {
  my $self = shift;

  if ($self->{__hostname}){
    return $self->{__hostname};
  }

  my @parts = split(/\./, hostname);
  my $short = $parts[0];

  $self->{__hostname} = $short;
  return $short;
}

#pod =head2 $obj->namespace_prefix($uri)
#pod
#pod Return the namespace prefix for I<$uri>
#pod
#pod =cut

#pod =head2 $obj->uri_shortform($prefix,$name)
#pod
#pod Returns a string in the form of I<prefix>:I<property>. The property is
#pod the value of $name. The prefix passed may or may be the same as the prefix
#pod returned depending on whether or not the user has defined or redefined their
#pod own list of namespaces.
#pod
#pod The prefix passed to the method is assumed to be one of prefixes in the
#pod B<default> list of namespaces.
#pod
#pod =cut

# Defined in Net::Flickr::RDF

#pod =head2 $obj->api_call(\%args)
#pod
#pod Valid args are:
#pod
#pod =over 4
#pod
#pod =item C<method>
#pod
#pod A string containing the name of the Flickr API method you are
#pod calling.
#pod
#pod =item C<args>
#pod
#pod A hash ref containing the key value pairs you are passing to
#pod I<method>
#pod
#pod =back
#pod
#pod If the method encounters any errors calling the API, receives an API error
#pod or can not parse the response it will log an error event, via the B<log> method,



( run in 1.230 second using v1.01-cache-2.11-cpan-9581c071862 )