Giter Club home page Giter Club logo

pithub's Introduction

codecov CPAN Cover Status Kwalitee status Actions Status Cpan license Cpan version

NAME

Pithub - Github v3 API

VERSION

version 0.01041

SYNOPSIS

use Pithub ();

my $p = Pithub->new;
# my $p = Pithub->new(utf8 => 0); # enable compatibility options for version 0.01029 or lower
my $repo = $p->repos->get( user => 'plu', repo => 'Pithub' );

# $repo->content is either an arrayref or an hashref
# depending on the API call that has been made
printf "%s\n", $repo->content->{html_url};     # prints https://github.com/plu/Pithub
printf "%s\n", $repo->content->{clone_url};    # prints https://github.com/plu/Pithub.git

# if the result is an arrayref, you can use the result iterator
my $repos = $p->repos->list( user => 'plu' );
while ( my $row = $repos->next ) {
    printf "%s\n", $row->{name};
}

# Connect to your local GitHub Enterprise instance
my $ghe_p = Pithub->new(
    api_uri => 'https://github.yourdomain.com/api/v3/'
);

# No need to provide user/repo to each module:
my $pit = Pithub->new(
  user  => 'plu',
  repo  => 'pithub',
  token => 'my_oauth_token',
);

$pit->repos->get;
$pit->repos->commits->list;

# Use a caching UserAgent
use CHI                    ();
use Pithub::Repos          ();
use WWW::Mechanize::Cached ();

my $cache = CHI->new(
    driver   => 'File',
    root_dir => '/tmp/pithub-example'
);

my $mech = WWW::Mechanize::Cached->new( cache => $cache );

my $cached_pithub = Pithub::Repos->new(
    auto_pagination => 1,
    per_page        => 100,
    ua              => $mech,
);

DESCRIPTION

Pithub (Perl + Github) provides a set of modules to access the Github v3 API in an object oriented way. There is also Net::GitHub which does the same for all the versions (v1, v2, v3) of the Github API. Pithub supports all API calls so far, but only for v3.

ATTRIBUTES

search_api

my $p = Pithub->new({ search_api => 'v3' });
my $search = $p->search; # $search->isa('Pithub::SearchV3');

This attribute allows the default for the API to use for searches to be specified. The two accepted values are v3 and legacy. For compatibility reasons the default is legacy.

METHODS

events

Provides access to Pithub::Events.

gists

Provides access to Pithub::Gists.

git_data

Provides access to Pithub::GitData.

issues

Provides access to Pithub::Issues.

markdown

Provides access to Pithub::Markdown.

orgs

Provides access to Pithub::Orgs.

pull_requests

Provides access to Pithub::PullRequests.

repos

Provides access to Pithub::Repos.

search

my $legacy_search  = $p->search(search_api => 'legacy');
my $v3_search      = $p->search(search_api => 'v3');
my $default_search = $p->search;

Provides access to Pithub::Search and Pithub::SearchV3. When no search_api option is given, the value provided by the search_api attribute is used.

users

Provides access to Pithub::Users.

DOCUMENTATION

Quite a lot of the Pithub documentation has been taken directly from the great API documentation at Github. Please also read the documentation there, since it might be more complete and more up-to-date.

Pithub::Base contains documentation for attributes inherited by all Pithub modules.

WARNING

Pithub as well as the Github v3 API are still under development. So there might be things broken on both sides. Besides that it's possible that the API will change. This applies to Pithub itself as well as the Github v3 API.

CONTRIBUTE

This module is hosted on Github, so feel free to fork it and send pull requests. There are two different kinds of test suites, one is just checking the HTTP requests that are created by the method calls, without actually sending them. The second one is sending real requests to the Github API. If you want to contribute to this project, I highly recommend to run the live tests on a test account, because it will generate a lot of activity.

MODULES

There are different ways of using the Pithub library. You can either use the main module Pithub to get access to all other modules, like Pithub::Repos for example. Or you can use Pithub::Repos directly and create an instance of it. All modules accept the same attributes, either in the constructor or later by calling the setters.

Besides that there are other modules involved. Every method call which maps directly to a Github API call returns a Pithub::Result object. This contains everything interesting about the response returned from the API call.

Pithub::Base might be interesting for two reasons:

CONTRIBUTORS

  • Andreas Marienborg
  • Alessandro Ghedini
  • Michael G Schwern

AUTHOR

Johannes Plunien [email protected]

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Johannes Plunien.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

pithub's People

Contributors

bessarabov avatar frewsxcv avatar ghedo avatar jjatria avatar konboi avatar masasuzu avatar oalders avatar omega avatar plicease avatar plu avatar rafl avatar rwstauner avatar schwern avatar shogo82148 avatar teckl avatar thibaultduponchelle avatar timlegge avatar tux avatar zoffixznet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pithub's Issues

Cascade attribute calls

Cascade calls to:

  • api_uri
  • auto_pagination
  • jsonp_callback
  • per_page
  • repo
  • skip_request
  • token
  • ua
  • user

Not sure though if that's a good idea. Probably this should only be done if the call was made on the root object, which isa('Pithub'). Then it would cascade down the call to all objects that are instantiated already.

Example:

  my $p = Pithub->new;
  my $u = $p->users;
  print $p->token; #undef
  print $u->token; #undef
  $p->token('123');
  print $p->token; #123
  print $u->token; #123

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.