aboutsummaryrefslogtreecommitdiffstats
path: root/github3/models/gists.py
blob: 8979dbb9ef03ff3d9b0266f3d2ff75bbd25edf05 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from .base import BaseResource
from .user import User


class GistComment(BaseResource):
    """ Gist comment """

    @classmethod
    def idl(self):
        return {
            'strs': ['url', 'body', 'body_text', 'body_html'],
            'ints': ['id'],
            'maps': {'user': User},
            'dates': ['created_at'],
        }

    def __repr__(self):
        return '<GistComment %s>' % self.user.login


class File(BaseResource):
    """ File model """

    @classmethod
    def idl(self):
        return {
            'strs': ['filename', 'raw_url', 'content', 'language', 'type'],
            'ints': ['size'],
        }

    def __repr__(self):
        return '<File gist> %s' % self.filename


class GistFork(BaseResource):
    """ GistFork model """

    @classmethod
    def idl(self):
        return {
            'strs': ['url'],
            'dates': ['created_at'],
            'maps': {'user': User}
        }

    def __repr__(self):
        return '<Gist fork> %s>' % self.user.login


class ChangeStatus(BaseResource):
    """ ChangeStatus model """

    @classmethod
    def idl(self):
        return {
            'ints': ['deletions', 'additions', 'total'],
        }

    def __repr__(self):
        return '<Gist history> change_status>'


class GistHistory(BaseResource):
    """ """

    @classmethod
    def idl(self):
        return {
            'strs': ['url', 'version'],
            'maps': {'user': User, 'change_status': ChangeStatus},
            'dates': ['committed_at'],
        }

    def __repr__(self):
        return '<GistHistory %s/%s>' % (self.user, self.committed_at)


class Gist(BaseResource):
    """ """

    @classmethod
    def idl(self):
        return {
            'strs': ['url', 'description', 'html_url', 'git_pull_url',
                     'git_push_url'],
            'ints': ['id', 'comments'],
            'bools': ['public'],
            'dates': ['created_at'],
            'maps': {'user': User},
            'collection_maps': {'files': File, 'forks': GistFork,
                                'history': GistHistory},
        }

    def __repr__(self):
        return '<Gist %s/%s>' % (self.user, self.description)