summaryrefslogtreecommitdiff
path: root/lib/githubexplorer.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-01-23 19:36:24 +0100
committerfranck cuny <franck@lumberjaph.net>2010-01-23 19:36:24 +0100
commita7cc690ced15e1a0191d27034006bfb17a0deeb5 (patch)
tree6cef1a2e07727e8cd5249764f461222073e8211a /lib/githubexplorer.pm
downloadgithub-explorer-a7cc690ced15e1a0191d27034006bfb17a0deeb5.tar.gz
basic github crawler using api
Diffstat (limited to 'lib/githubexplorer.pm')
-rw-r--r--lib/githubexplorer.pm51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/githubexplorer.pm b/lib/githubexplorer.pm
new file mode 100644
index 0000000..fdd609a
--- /dev/null
+++ b/lib/githubexplorer.pm
@@ -0,0 +1,51 @@
+package githubexplorer;
+use 5.010;
+use lib ('/home/franck/code/git/net-github/lib');
+use YAML::Syck;
+use Moose;
+use githubexplorer::Schema;
+
+with qw/githubexplorer::Profile githubexplorer::Repositorie/;
+
+has seed => ( isa => 'ArrayRef', is => 'ro', required => 1 );
+has api_login => ( isa => 'Str', is => 'ro', required => 1 );
+has api_token => ( isa => 'Str', is => 'ro', required => 1 );
+has connect_info => ( isa => 'ArrayRef', is => 'ro', required => 1 );
+has with_repo => ( isa => 'Bool', is => 'ro', default => sub {0} );
+has schema => (
+ isa => 'githubexplorer::Schema',
+ is => 'rw',
+ predicate => 'has_schema'
+);
+
+sub deploy {
+ my ($self) = @_;
+ $self->_connect() unless $self->has_schema;
+ $self->schema->deploy;
+}
+
+sub _connect {
+ my $self = shift;
+ $self->schema(
+ githubexplorer::Schema->connect( @{ $self->connect_info } ) );
+}
+
+sub harvest_profiles {
+ my ( $self, $depth) = @_;
+ $self->_connect() unless $self->has_schema;
+ $depth //= 1;
+ foreach my $login ( @{ $self->seed } ) {
+ $self->fetch_profile($login, $depth);
+ }
+}
+
+sub harvest_repo {
+ my ($self) = @_;
+ $self->_connect unless $self->has_schema;
+ my $profiles = $self->schema->resultset('Profiles')->search();
+ while (my $p = $profiles->next) {
+ $self->fetch_repo($p);
+ }
+}
+
+1;