summaryrefslogtreecommitdiff
path: root/lib/githubexplorer/Gexf.pm
blob: 0d814f044d3b4809ca6e1559f4b2180c74c63f7f (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package githubexplorer::Gexf;

use Moose;
use XML::Simple;

has schema => (is => 'ro', isa => 'Object', required => 1);

has graph => (
    is      => 'rw',
    isa     => 'HashRef',
    default => sub {
        my $graph = {
            gexf => {
                version => "1.0",
                meta    => { creator => ['rtgi'] },
                graph   => {
                    type       => 'static',
                    attributes => {
                        class     => 'node',
                        type      => 'static',
                        attribute => [
                            {
                                id    => 0,
                                type  => 'string',
                                title => 'totalrepo'
                            },
                            {
                                id    => 1,
                                type  => 'string',
                                title => 'accountlogin'
                            },
                            {
                                id    => 2,
                                type  => 'string',
                                title => 'forkedrepo'
                            },
                        ]
                    }
                }
            }
        };
    }
);

sub profiles {
    my $self     = shift;
    my $profiles = $self->schema->resultset('Profiles')->search();

    while ( my $profile = $profiles->next ) {
        my $node = {
            id        => $profile->name,
            label     => $profile->name,
            attvalues => [
                { id => 0, value => 'total' },
                { id => 1, $profile->name },
                { id => 2, 'forked' }
            ]
        };
        push @{ $self->graph->{gexf}->{graph}->{nodes}->{node} }, $node;
    }
    use YAML::Syck;
    warn Dump $self->graph;
}

1;