JSAN::Index::Author - A JavaScript Archive Network (JSAN) Author


JSAN-Client documentation Contained in the JSAN-Client distribution.

Index


Code Index:

NAME

Top

JSAN::Index::Author - A JavaScript Archive Network (JSAN) Author

DESCRIPTION

Top

This class provides objects that represent authors in the JSAN::Index.

METHODS

Top

In addition to the general methods provided by ORLite, this class has the following additional methods.

login

The login accessor returns the JSAN author code/login for the author.

name

The name accessor returns the full name of the author.

doc

The doc accessor returns the root-relative documentation path for the author on any http://openjsan.org/ mirror.

email

The email accessor returns the public email address for the author.

url

The url acessor returns the uri for the authors homepage as a string.

releases

The releases method finds and retrieves all of the releases for an author.

Returns a list of JSAN::Index::Release objects.

SUPPORT

Top

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=JSAN-Client

For other issues, contact the author.

AUTHOR

Top

Adam Kennedy <adamk@cpan.org>

SEE ALSO

Top

JSAN::Index, JSAN::Shell, http://openjsan.org

COPYRIGHT

Top

NAME

Top

JSAN::Index::Author - JSAN::Index class for the author table

SYNOPSIS

Top

  TO BE COMPLETED

DESCRIPTION

Top

TO BE COMPLETED

METHODS

Top

select

  # Get all objects in list context
  my @list = JSAN::Index::Author->select;

  # Get a subset of objects in scalar context
  my $array_ref = JSAN::Index::Author->select(
      'where login > ? order by login',
      1000,
  );

The select method executes a typical SQL SELECT query on the author table.

It takes an optional argument of a SQL phrase to be added after the FROM author section of the query, followed by variables to be bound to the placeholders in the SQL phrase. Any SQL that is compatible with SQLite can be used in the parameter.

Returns a list of JSAN::Index::Author objects when called in list context, or a reference to an ARRAY of JSAN::Index::Author objects when called in scalar context.

Throws an exception on error, typically directly from the DBI layer.

count

  # How many objects are in the table
  my $rows = JSAN::Index::Author->count;

  # How many objects 
  my $small = JSAN::Index::Author->count(
      'where login > ?',
      1000,
  );

The count method executes a SELECT COUNT(*) query on the author table.

It takes an optional argument of a SQL phrase to be added after the FROM author section of the query, followed by variables to be bound to the placeholders in the SQL phrase. Any SQL that is compatible with SQLite can be used in the parameter.

Returns the number of objects that match the condition.

Throws an exception on error, typically directly from the DBI layer.

ACCESSORS

Top

login

  if ( $object->login ) {
      print "Object has been inserted\n";
  } else {
      print "Object has not been inserted\n";
  }

Returns true, or throws an exception on error.

REMAINING ACCESSORS TO BE COMPLETED

SQL

Top

The author table was originally created with the following SQL command.

  CREATE TABLE author (
      login varchar (
          100
      )
      NOT NULL,
      name varchar (
          100
      )
      NOT NULL,
      doc varchar (
          100
      )
      NOT NULL,
      email varchar (
          100
      )
      NOT NULL,
      url varchar (
          100
      )
  ,
      PRIMARY KEY (
          login
      )
  )




SUPPORT

Top

JSAN::Index::Author is part of the JSAN::Index API.

See the documentation for JSAN::Index for more information.

COPYRIGHT

Top


JSAN-Client documentation Contained in the JSAN-Client distribution.

package JSAN::Index::Author;

use 5.006;
use strict;
use warnings;
use JSAN::Index::Release ();

our $VERSION = '0.29';

sub releases {
    JSAN::Index::Release->select( 'where author = ?', $_[0]->login );
}

sub retrieve {
    my $class  = shift;
    my %params = @_;
    my $sql    = join " and ", map { "$_ = ?" } keys(%params); 
    my @result = $class->select( "where $sql", values(%params) );
    if ( @result == 1 ) {
        return $result[0];
    }
    if ( @result > 1 ) {
        Carp::croak("Found more than one author record");
    } else {
        return undef;
    }
}


sub search_like {
    my $class  = shift;
    my %params = @_;
    my $sql    = join " and ", map { "$_ like ?" } keys(%params); 
    
    my @result = $class->select( "where $sql", values(%params) );
    
    return @result
}



######################################################################
# Generated by ORLite 1.25 (Unused parts are commented out)

#sub base { 'JSAN::Index' }
#
#sub table { 'author' }

sub select {
    my $class = shift;
    my $sql   = 'select "login", "name", "doc", "email", "url" from author ';
       $sql  .= shift if @_;
    my $rows  = JSAN::Index->selectall_arrayref( $sql, { Slice => {} }, @_ );
    bless( $_, 'JSAN::Index::Author' ) foreach @$rows;
    wantarray ? @$rows : $rows;
}

sub count {
    my $class = shift;
    my $sql   = 'select count(*) from author ';
       $sql  .= shift if @_;
    JSAN::Index->selectrow_array( $sql, {}, @_ );
}

sub iterate {
    my $class = shift;
    my $call  = pop;
    my $sql   = 'select "login", "name", "doc", "email", "url" from author ';
       $sql  .= shift if @_;
    my $sth   = JSAN::Index->prepare( $sql );
    $sth->execute( @_ );
    while ( $_ = $sth->fetchrow_hashref ) {
        bless( $_, 'JSAN::Index::Author' );
        $call->() or last;
    }
    $sth->finish;
}

sub login {
    $_[0]->{login};
}

sub name {
    $_[0]->{name};
}

sub doc {
    $_[0]->{doc};
}

sub email {
    $_[0]->{email};
}

sub url {
    $_[0]->{url};
}

1;

__END__;