ghtorrent 0.3.1 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +23 -0
- data/bin/ght-data-retrieval +34 -39
- data/bin/ght-load +0 -33
- data/bin/ght-mirror-events +0 -30
- data/bin/ght-rm-dupl +0 -32
- data/bin/ght-torrent-index +0 -30
- data/lib/ghtorrent.rb +21 -3
- data/lib/ghtorrent/adapters/base_adapter.rb +1 -29
- data/lib/ghtorrent/adapters/mongo_persister.rb +10 -30
- data/lib/ghtorrent/adapters/noop_persister.rb +0 -28
- data/lib/ghtorrent/api_client.rb +1 -28
- data/lib/ghtorrent/call_stack.rb +0 -28
- data/lib/ghtorrent/command.rb +0 -28
- data/lib/ghtorrent/ghtorrent.rb +260 -94
- data/lib/ghtorrent/logging.rb +0 -28
- data/lib/ghtorrent/migrations/005_add_repo_collaborators.rb +23 -0
- data/lib/ghtorrent/migrations/006_add_watchers.rb +23 -0
- data/lib/ghtorrent/persister.rb +0 -28
- data/lib/ghtorrent/retriever.rb +111 -92
- data/lib/ghtorrent/settings.rb +1 -29
- data/lib/ghtorrent/utils.rb +0 -28
- metadata +7 -5
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2012, Georgios Gousios
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
14
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
15
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
16
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
17
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
18
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
19
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
20
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
21
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
22
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
23
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/bin/ght-data-retrieval
CHANGED
@@ -1,33 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or
|
6
|
-
# without modification, are permitted provided that the following
|
7
|
-
# conditions are met:
|
8
|
-
#
|
9
|
-
# 1. Redistributions of source code must retain the above
|
10
|
-
# copyright notice, this list of conditions and the following
|
11
|
-
# disclaimer.
|
12
|
-
#
|
13
|
-
# 2. Redistributions in binary form must reproduce the above
|
14
|
-
# copyright notice, this list of conditions and the following
|
15
|
-
# disclaimer in the documentation and/or other materials
|
16
|
-
# provided with the distribution.
|
17
|
-
#
|
18
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
20
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
21
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
22
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
25
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
26
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
28
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
1
|
require 'rubygems'
|
32
2
|
require 'amqp'
|
33
3
|
require 'json'
|
@@ -37,6 +7,7 @@ require 'pp'
|
|
37
7
|
class GHTDataRetrieval < GHTorrent::Command
|
38
8
|
|
39
9
|
include GHTorrent::Settings
|
10
|
+
include GHTorrent::Logging
|
40
11
|
|
41
12
|
attr_reader :settings, :name
|
42
13
|
|
@@ -54,21 +25,45 @@ class GHTDataRetrieval < GHTorrent::Command
|
|
54
25
|
|
55
26
|
def WatchEvent(evt)
|
56
27
|
data = parse evt
|
57
|
-
|
58
|
-
|
28
|
+
owner = data['repo']['name'].split(/\//)[0]
|
29
|
+
repo = data['repo']['name'].split(/\//)[1]
|
30
|
+
watcher = data['actor']['login']
|
31
|
+
created_at = data['created_at']
|
32
|
+
|
33
|
+
@gh.get_watcher owner, repo, watcher, created_at
|
59
34
|
end
|
60
35
|
|
61
36
|
def FollowEvent(evt)
|
37
|
+
data = parse evt
|
38
|
+
follower = data['actor']['login']
|
39
|
+
followed = data['payload']['target']['login']
|
40
|
+
created_at = data['created_at']
|
41
|
+
|
42
|
+
@gh.get_follower(follower, followed, created_at)
|
43
|
+
end
|
44
|
+
|
45
|
+
def MemberEvent(evt)
|
46
|
+
data = parse evt
|
47
|
+
owner = data['actor']['login']
|
48
|
+
repo = data['repo']['name'].split(/\//)[1]
|
49
|
+
new_member = data['payload']['member']['login']
|
50
|
+
created_at = data['created_at']
|
51
|
+
|
52
|
+
@gh.get_project_member(owner, repo, new_member, created_at)
|
53
|
+
end
|
54
|
+
|
55
|
+
def CommitCommentEvent(evt)
|
62
56
|
data = parse evt
|
63
57
|
user = data['actor']['login']
|
64
|
-
|
58
|
+
repo = data['repo']['name'].split(/\//)[1]
|
59
|
+
id = data['payload']['comment']['id']
|
60
|
+
created_at = data['created_at']
|
65
61
|
|
66
|
-
|
67
|
-
#@gh.get_followers followed
|
62
|
+
@gh.get_commit_comment(user, repo, id, created_at)
|
68
63
|
end
|
69
64
|
|
70
65
|
def handlers
|
71
|
-
%w(PushEvent WatchEvent FollowEvent)
|
66
|
+
%w(PushEvent WatchEvent FollowEvent MemberEvent CommitCommentEvent)
|
72
67
|
end
|
73
68
|
|
74
69
|
def prepare_options(options)
|
@@ -81,11 +76,11 @@ class GHTDataRetrieval < GHTorrent::Command
|
|
81
76
|
|
82
77
|
# Graceful exit
|
83
78
|
Signal.trap('INT') {
|
84
|
-
info
|
79
|
+
info "Received SIGINT, exiting"
|
85
80
|
AMQP.stop { EM.stop }
|
86
81
|
}
|
87
82
|
Signal.trap('TERM') {
|
88
|
-
info
|
83
|
+
info "Received SIGTERM, exiting"
|
89
84
|
AMQP.stop { EM.stop }
|
90
85
|
}
|
91
86
|
|
@@ -102,7 +97,7 @@ class GHTDataRetrieval < GHTorrent::Command
|
|
102
97
|
queue = channel.queue("#{h}s", {:durable => true})\
|
103
98
|
.bind(exchange, :routing_key => "evt.#{h}")
|
104
99
|
|
105
|
-
|
100
|
+
info "Binding handler #{h} to routing key evt.#{h}"
|
106
101
|
|
107
102
|
queue.subscribe(:ack => true) do |headers, msg|
|
108
103
|
begin
|
data/bin/ght-load
CHANGED
@@ -1,36 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Loads items from Mongo to the queue for further processing
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
7
|
-
#
|
8
|
-
# Redistribution and use in source and binary forms, with or
|
9
|
-
# without modification, are permitted provided that the following
|
10
|
-
# conditions are met:
|
11
|
-
#
|
12
|
-
# 1. Redistributions of source code must retain the above
|
13
|
-
# copyright notice, this list of conditions and the following
|
14
|
-
# disclaimer.
|
15
|
-
#
|
16
|
-
# 2. Redistributions in binary form must reproduce the above
|
17
|
-
# copyright notice, this list of conditions and the following
|
18
|
-
# disclaimer in the documentation and/or other materials
|
19
|
-
# provided with the distribution.
|
20
|
-
#
|
21
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
23
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
24
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
25
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
28
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
29
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
30
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
31
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
|
34
1
|
require 'rubygems'
|
35
2
|
require 'ghtorrent-old'
|
36
3
|
require 'mongo'
|
data/bin/ght-mirror-events
CHANGED
@@ -1,33 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or
|
6
|
-
# without modification, are permitted provided that the following
|
7
|
-
# conditions are met:
|
8
|
-
#
|
9
|
-
# 1. Redistributions of source code must retain the above
|
10
|
-
# copyright notice, this list of conditions and the following
|
11
|
-
# disclaimer.
|
12
|
-
#
|
13
|
-
# 2. Redistributions in binary form must reproduce the above
|
14
|
-
# copyright notice, this list of conditions and the following
|
15
|
-
# disclaimer in the documentation and/or other materials
|
16
|
-
# provided with the distribution.
|
17
|
-
#
|
18
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
20
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
21
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
22
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
25
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
26
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
28
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
1
|
require 'rubygems'
|
32
2
|
require 'yaml'
|
33
3
|
require 'amqp'
|
data/bin/ght-rm-dupl
CHANGED
@@ -1,35 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Knows how to remove duplicate entries from various collections.
|
4
|
-
#
|
5
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
6
|
-
#
|
7
|
-
# Redistribution and use in source and binary forms, with or
|
8
|
-
# without modification, are permitted provided that the following
|
9
|
-
# conditions are met:
|
10
|
-
#
|
11
|
-
# 1. Redistributions of source code must retain the above
|
12
|
-
# copyright notice, this list of conditions and the following
|
13
|
-
# disclaimer.
|
14
|
-
#
|
15
|
-
# 2. Redistributions in binary form must reproduce the above
|
16
|
-
# copyright notice, this list of conditions and the following
|
17
|
-
# disclaimer in the documentation and/or other materials
|
18
|
-
# provided with the distribution.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
22
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
23
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
24
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
25
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
26
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
27
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
28
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
29
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
30
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
32
|
-
|
33
1
|
require 'rubygems'
|
34
2
|
require 'mongo'
|
35
3
|
require 'ghtorrent-old'
|
data/bin/ght-torrent-index
CHANGED
@@ -1,33 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
4
|
-
#
|
5
|
-
# Redistribution and use in source and binary forms, with or
|
6
|
-
# without modification, are permitted provided that the following
|
7
|
-
# conditions are met:
|
8
|
-
#
|
9
|
-
# 1. Redistributions of source code must retain the above
|
10
|
-
# copyright notice, this list of conditions and the following
|
11
|
-
# disclaimer.
|
12
|
-
#
|
13
|
-
# 2. Redistributions in binary form must reproduce the above
|
14
|
-
# copyright notice, this list of conditions and the following
|
15
|
-
# disclaimer in the documentation and/or other materials
|
16
|
-
# provided with the distribution.
|
17
|
-
#
|
18
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
20
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
21
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
22
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
25
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
26
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
27
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
28
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
-
|
31
1
|
require 'rubygems'
|
32
2
|
require 'erb'
|
33
3
|
require 'set'
|
data/lib/ghtorrent.rb
CHANGED
@@ -1,7 +1,25 @@
|
|
1
|
-
#require 'ghtorrent-old/ghtorrent-old'
|
2
|
-
|
3
1
|
module GHTorrent
|
4
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.4'
|
3
|
+
|
4
|
+
# Route keys used for setting up queues for events, using GHTorrent
|
5
|
+
ROUTEKEY_CREATE = "evt.CreateEvent"
|
6
|
+
ROUTEKEY_DELETE = "evt.DeleteEvent"
|
7
|
+
ROUTEKEY_DOWNLOAD = "evt.DownloadEvent"
|
8
|
+
ROUTEKEY_FOLLOW = "evt.FollowEvent"
|
9
|
+
ROUTEKEY_FORK = "evt.ForkEvent"
|
10
|
+
ROUTEKEY_FORK_APPLY = "evt.ForkApplyEvent"
|
11
|
+
ROUTEKEY_GIST = "evt.GistEvent"
|
12
|
+
ROUTEKEY_GOLLUM = "evt.GollumEvent"
|
13
|
+
ROUTEKEY_ISSUE_COMMENT = "evt.IssueCommentEvent"
|
14
|
+
ROUTEKEY_ISSUES = "evt.IssuesEvent"
|
15
|
+
ROUTEKEY_MEMBER = "evt.MemberEvent"
|
16
|
+
ROUTEKEY_PUBLIC = "evt.PublicEvent"
|
17
|
+
ROUTEKEY_PULL_REQUEST = "evt.PullRequestEvent"
|
18
|
+
ROUTEKEY_PULL_REQUEST_REVIEW_COMMENT = "evt.PullRequestReviewCommentEvent"
|
19
|
+
ROUTEKEY_PUSH = "evt.PushEvent"
|
20
|
+
ROUTEKEY_TEAM_ADD = "evt.TeamAddEvent"
|
21
|
+
ROUTEKEY_WATCH = "evt.WatchEvent"
|
22
|
+
|
5
23
|
end
|
6
24
|
|
7
25
|
require 'ghtorrent/command'
|
@@ -1,37 +1,9 @@
|
|
1
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or
|
4
|
-
# without modification, are permitted provided that the following
|
5
|
-
# conditions are met:
|
6
|
-
#
|
7
|
-
# 1. Redistributions of source code must retain the above
|
8
|
-
# copyright notice, this list of conditions and the following
|
9
|
-
# disclaimer.
|
10
|
-
#
|
11
|
-
# 2. Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following
|
13
|
-
# disclaimer in the documentation and/or other materials
|
14
|
-
# provided with the distribution.
|
15
|
-
#
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
20
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
28
|
-
|
29
1
|
module GHTorrent
|
30
2
|
|
31
3
|
class BaseAdapter
|
32
4
|
|
33
5
|
ENTITIES = [:users, :commits, :followers, :repos, :events, :org_members,
|
34
|
-
:commit_comments
|
6
|
+
:commit_comments, :repo_collaborators, :watchers
|
35
7
|
]
|
36
8
|
|
37
9
|
# Stores +data+ into +entity+. Returns a unique key for the stored entry.
|
@@ -1,31 +1,3 @@
|
|
1
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or
|
4
|
-
# without modification, are permitted provided that the following
|
5
|
-
# conditions are met:
|
6
|
-
#
|
7
|
-
# 1. Redistributions of source code must retain the above
|
8
|
-
# copyright notice, this list of conditions and the following
|
9
|
-
# disclaimer.
|
10
|
-
#
|
11
|
-
# 2. Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following
|
13
|
-
# disclaimer in the documentation and/or other materials
|
14
|
-
# provided with the distribution.
|
15
|
-
#
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
20
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
28
|
-
|
29
1
|
require 'mongo'
|
30
2
|
|
31
3
|
module GHTorrent
|
@@ -65,10 +37,13 @@ module GHTorrent
|
|
65
37
|
:followers => get_collection("followers"),
|
66
38
|
:events => get_collection("events"),
|
67
39
|
:org_members => get_collection("org_members"),
|
68
|
-
:commit_comments => get_collection("commit_comments")
|
40
|
+
:commit_comments => get_collection("commit_comments"),
|
41
|
+
:repo_collaborators => get_collection("repo_collaborators"),
|
42
|
+
:watchers => get_collection("watchers")
|
69
43
|
}
|
70
44
|
|
71
45
|
# Ensure that the necessary indexes exist
|
46
|
+
ensure_index(:events, "id")
|
72
47
|
ensure_index(:users, "login")
|
73
48
|
ensure_index(:commits, "sha")
|
74
49
|
ensure_index(:repos, "name")
|
@@ -77,9 +52,14 @@ module GHTorrent
|
|
77
52
|
ensure_index(:commit_comments, "repo")
|
78
53
|
ensure_index(:commit_comments, "user")
|
79
54
|
ensure_index(:commit_comments, "commit_id")
|
55
|
+
ensure_index(:repo_collaborators, "repo")
|
56
|
+
ensure_index(:repo_collaborators, "owner")
|
57
|
+
ensure_index(:repo_collaborators, "login")
|
58
|
+
ensure_index(:watchers, "repo")
|
59
|
+
ensure_index(:watchers, "owner")
|
60
|
+
ensure_index(:watchers, "login")
|
80
61
|
end
|
81
62
|
|
82
|
-
|
83
63
|
def store(entity, data = {})
|
84
64
|
super
|
85
65
|
get_entity(entity).insert(data).to_s
|
@@ -1,31 +1,3 @@
|
|
1
|
-
# Copyright 2012 Georgios Gousios <gousiosg@gmail.com>
|
2
|
-
#
|
3
|
-
# Redistribution and use in source and binary forms, with or
|
4
|
-
# without modification, are permitted provided that the following
|
5
|
-
# conditions are met:
|
6
|
-
#
|
7
|
-
# 1. Redistributions of source code must retain the above
|
8
|
-
# copyright notice, this list of conditions and the following
|
9
|
-
# disclaimer.
|
10
|
-
#
|
11
|
-
# 2. Redistributions in binary form must reproduce the above
|
12
|
-
# copyright notice, this list of conditions and the following
|
13
|
-
# disclaimer in the documentation and/or other materials
|
14
|
-
# provided with the distribution.
|
15
|
-
#
|
16
|
-
# THIS SOFTWARE IS PROVIDED BY BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
-
# AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
-
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
-
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
20
|
-
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23
|
-
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24
|
-
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25
|
-
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26
|
-
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
28
|
-
|
29
1
|
module GHTorrent
|
30
2
|
|
31
3
|
# Persister adapter that does not store any data.
|