summaryrefslogtreecommitdiff
path: root/lib/GitHub/Collector/Command/graph.pm
blob: c7766a845ce443e251832f64708a308ed5a3c528 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package GitHub::Collector::Command::graph;

use Moose;
use YAML::Syck;

extends qw(MooseX::App::Cmd::Command);

with qw(
  GitHub::Collector::Role::Context
  GitHub::Collector::Role::Logger
  GitHub::Collector::Role::MongoDB
  GitHub::Collector::Role::Graph::Query
  GitHub::Collector::Role::Graph::Nodes
  GitHub::Collector::Role::Graph::Edges
  GitHub::Collector::Role::Graph::Neighbors
  GitHub::Collector::Role::Graph::Search
  GitHub::Collector::Role::Graph::Gexf
);

has profile => (
    is        => 'ro',
    isa       => 'Str',
    predicate => 'has_profile',
);

has indegree => (
    is => 'ro',
    isa => 'Int',
    predicate => 'has_indegree',
);

sub execute {
    my $self = shift;

    if ($self->has_profile){
        $self->neighbors($self->profile, 1);
        $self->remove_leaves();
    }elsif($self->has_indegree){
        $self->build_from_query( { indegree => { '$gt' => $self->indegree } } );
    }else{
        $self->build_from_query();
    }

    $self->export() if $self->should_export;
}

1;