ghtorrent 0.4 → 0.5

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.
Files changed (38) hide show
  1. data/CHANGELOG +24 -0
  2. data/Gemfile +17 -0
  3. data/Gemfile.lock +40 -0
  4. data/README.md +23 -22
  5. data/bin/ght-data-retrieval +66 -24
  6. data/bin/ght-load +41 -19
  7. data/bin/ght-mirror-events +13 -16
  8. data/bin/ght-rm-dupl +119 -77
  9. data/lib/ghtorrent.rb +14 -4
  10. data/lib/ghtorrent/adapters/base_adapter.rb +17 -5
  11. data/lib/ghtorrent/adapters/mongo_persister.rb +122 -56
  12. data/lib/ghtorrent/api_client.rb +151 -16
  13. data/lib/ghtorrent/bson_orderedhash.rb +23 -0
  14. data/lib/ghtorrent/cache.rb +97 -0
  15. data/lib/ghtorrent/command.rb +43 -25
  16. data/lib/ghtorrent/gh_torrent_exception.rb +6 -0
  17. data/lib/ghtorrent/ghtorrent.rb +615 -164
  18. data/lib/ghtorrent/hash.rb +11 -0
  19. data/lib/ghtorrent/logging.rb +11 -7
  20. data/lib/ghtorrent/migrations/001_init_schema.rb +3 -3
  21. data/lib/ghtorrent/migrations/002_add_external_ref_ids.rb +2 -0
  22. data/lib/ghtorrent/migrations/003_add_orgs.rb +4 -1
  23. data/lib/ghtorrent/migrations/004_add_commit_comments.rb +4 -2
  24. data/lib/ghtorrent/migrations/005_add_repo_collaborators.rb +2 -0
  25. data/lib/ghtorrent/migrations/006_add_watchers.rb +2 -0
  26. data/lib/ghtorrent/migrations/007_add_pull_requests.rb +64 -0
  27. data/lib/ghtorrent/migrations/008_add_project_unq.rb +23 -0
  28. data/lib/ghtorrent/migrations/009_add_project_commit.rb +27 -0
  29. data/lib/ghtorrent/migrations/010_add_forks.rb +28 -0
  30. data/lib/ghtorrent/migrations/mysql_defaults.rb +6 -0
  31. data/lib/ghtorrent/persister.rb +3 -0
  32. data/lib/ghtorrent/retriever.rb +298 -102
  33. data/lib/ghtorrent/settings.rb +20 -1
  34. data/lib/ghtorrent/time.rb +5 -0
  35. data/lib/ghtorrent/utils.rb +22 -4
  36. data/lib/version.rb +5 -0
  37. metadata +173 -145
  38. data/lib/ghtorrent/call_stack.rb +0 -91
@@ -1,5 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
+ require 'ghtorrent/utils'
4
+
3
5
  module GHTorrent
4
6
  module Settings
5
7
 
@@ -11,6 +13,7 @@ module GHTorrent
11
13
  :amqp_username => "amqp.username",
12
14
  :amqp_password => "amqp.password",
13
15
  :amqp_exchange => "amqp.exchange",
16
+ :amqp_prefetch => "amqp.prefetch",
14
17
 
15
18
  :sql_url => "sql.url",
16
19
 
@@ -21,7 +24,13 @@ module GHTorrent
21
24
  :mirror_persister => "mirror.persister",
22
25
  :mirror_commit_pages_new_repo => "mirror.commit_pages_new_repo",
23
26
 
24
- :uniq_id => "mirror.uniq_id"
27
+ :uniq_id => "mirror.uniq_id",
28
+
29
+ :cache_mode => "mirror.cache_mode",
30
+ :cache_dir => "mirror.cache_dir",
31
+ :cache_stale_age => "mirror.cache_stale_age",
32
+
33
+ :attach_ip => "mirror.attach_ip"
25
34
  }
26
35
 
27
36
  def config(key)
@@ -32,5 +41,15 @@ module GHTorrent
32
41
  more_keys.each {|k,v| CONFIGKEYS[k] = v}
33
42
  end
34
43
 
44
+ def merge_config_values(values)
45
+ values.reduce(settings) {|acc, k|
46
+ acc.merge_recursive write_value(settings, CONFIGKEYS[k[0]], k[1])
47
+ }
48
+ end
49
+
50
+ def settings
51
+ raise Exception("Unimplemented")
52
+ end
53
+
35
54
  end
36
55
  end
@@ -0,0 +1,5 @@
1
+ class Time
2
+ def to_ms
3
+ (self.to_f * 1000.0).to_i
4
+ end
5
+ end
@@ -1,3 +1,5 @@
1
+ require 'ghtorrent/hash'
2
+
1
3
  module GHTorrent
2
4
  module Utils
3
5
 
@@ -5,9 +7,8 @@ module GHTorrent
5
7
  other.extend self
6
8
  end
7
9
 
8
- # Read a value whose format is "foo.bar.baz" from a hierarchical map
9
- # (the result of a JSON parse or a Mongo query), where a dot represents
10
- # one level deep in the result hierarchy.
10
+ # Read the value for a key whose format is "foo.bar.baz" from a hierarchical
11
+ # map, where a dot represents one level deep in the hierarchy.
11
12
  def read_value(from, key)
12
13
  return from if key.nil? or key == ""
13
14
 
@@ -32,6 +33,23 @@ module GHTorrent
32
33
  end
33
34
  end
34
35
 
36
+ # Overwrite an existing +key+ whose format is "foo.bar" (where a dot
37
+ # represents one level deep in the hierarchy) in hash +to+ with +value+.
38
+ # If the key does not exist, it will be added at the appropriate depth level
39
+ def write_value(to, key, value)
40
+ return to if key.nil? or key == ""
41
+
42
+ prev = nil
43
+ key.split(/\./).reverse.each {|x|
44
+ a = Hash.new
45
+ a[x] = if prev.nil? then value else prev end
46
+ prev = a
47
+ a
48
+ }
49
+
50
+ to.merge_recursive(prev)
51
+ end
52
+
35
53
  def user_type(type)
36
54
  if type == "User"
37
55
  "USR"
@@ -40,4 +58,4 @@ module GHTorrent
40
58
  end
41
59
  end
42
60
  end
43
- end
61
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module GHTorrent
2
+
3
+ VERSION = '0.5'
4
+
5
+ end
metadata CHANGED
@@ -1,163 +1,166 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ghtorrent
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.5'
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- version: "0.4"
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Georgios Gousios
13
9
  - Diomidis Spinellis
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2012-07-11 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
13
+ date: 2012-08-07 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: amqp
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 25
29
- segments:
30
- - 0
31
- - 9
32
- version: "0.9"
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0.9'
33
23
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: mongo
37
24
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 1
46
- - 6
47
- version: "1.6"
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0.9'
31
+ - !ruby/object:Gem::Dependency
32
+ name: mongo
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '1.6'
48
39
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: bson_ext
52
40
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 1
61
- - 6
62
- version: "1.6"
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '1.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bson_ext
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
63
55
  type: :runtime
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: json
67
56
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 1
76
- - 6
77
- version: "1.6"
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '1.6'
63
+ - !ruby/object:Gem::Dependency
64
+ name: json
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '1.6'
78
71
  type: :runtime
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: trollop
82
72
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 47
89
- segments:
90
- - 1
91
- - 16
92
- version: "1.16"
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '1.6'
79
+ - !ruby/object:Gem::Dependency
80
+ name: trollop
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '1.16'
93
87
  type: :runtime
94
- version_requirements: *id005
95
- - !ruby/object:Gem::Dependency
96
- name: sequel
97
88
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
99
- none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 65
104
- segments:
105
- - 3
106
- - 35
107
- version: "3.35"
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '1.16'
95
+ - !ruby/object:Gem::Dependency
96
+ name: sequel
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '3.35'
108
103
  type: :runtime
109
- version_requirements: *id006
110
- - !ruby/object:Gem::Dependency
111
- name: sqlite3-ruby
112
104
  prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
114
- none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 31
119
- segments:
120
- - 1
121
- - 3
122
- - 2
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '3.35'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3-ruby
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
123
118
  version: 1.3.2
124
119
  type: :runtime
125
- version_requirements: *id007
126
- - !ruby/object:Gem::Dependency
127
- name: daemons
128
120
  prerelease: false
129
- requirement: &id008 !ruby/object:Gem::Requirement
130
- none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- hash: 3
135
- segments:
136
- - 1
137
- - 1
138
- - 8
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: 1.3.2
127
+ - !ruby/object:Gem::Dependency
128
+ name: daemons
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
139
134
  version: 1.1.8
140
135
  type: :runtime
141
- version_requirements: *id008
142
- description: |-
143
- A library and a collection of associated programs
144
- to mirror and process Github data
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: 1.1.8
143
+ description: ! "A library and a collection of associated programs\n to
144
+ mirror and process Github data"
145
145
  email: gousiosg@gmail.com
146
- executables:
146
+ executables:
147
147
  - ght-data-retrieval
148
148
  - ght-mirror-events
149
+ - ght-load
150
+ - ght-rm-dupl
149
151
  extensions: []
150
-
151
152
  extra_rdoc_files: []
152
-
153
- files:
153
+ files:
154
154
  - lib/ghtorrent/adapters/base_adapter.rb
155
155
  - lib/ghtorrent/adapters/mongo_persister.rb
156
156
  - lib/ghtorrent/adapters/noop_persister.rb
157
157
  - lib/ghtorrent/api_client.rb
158
- - lib/ghtorrent/call_stack.rb
158
+ - lib/ghtorrent/bson_orderedhash.rb
159
+ - lib/ghtorrent/cache.rb
159
160
  - lib/ghtorrent/command.rb
161
+ - lib/ghtorrent/gh_torrent_exception.rb
160
162
  - lib/ghtorrent/ghtorrent.rb
163
+ - lib/ghtorrent/hash.rb
161
164
  - lib/ghtorrent/logging.rb
162
165
  - lib/ghtorrent/migrations/001_init_schema.rb
163
166
  - lib/ghtorrent/migrations/002_add_external_ref_ids.rb
@@ -165,53 +168,78 @@ files:
165
168
  - lib/ghtorrent/migrations/004_add_commit_comments.rb
166
169
  - lib/ghtorrent/migrations/005_add_repo_collaborators.rb
167
170
  - lib/ghtorrent/migrations/006_add_watchers.rb
171
+ - lib/ghtorrent/migrations/007_add_pull_requests.rb
172
+ - lib/ghtorrent/migrations/008_add_project_unq.rb
173
+ - lib/ghtorrent/migrations/009_add_project_commit.rb
174
+ - lib/ghtorrent/migrations/010_add_forks.rb
175
+ - lib/ghtorrent/migrations/mysql_defaults.rb
168
176
  - lib/ghtorrent/persister.rb
169
177
  - lib/ghtorrent/retriever.rb
170
178
  - lib/ghtorrent/settings.rb
179
+ - lib/ghtorrent/time.rb
171
180
  - lib/ghtorrent/utils.rb
172
181
  - lib/ghtorrent.rb
182
+ - lib/version.rb
173
183
  - bin/ght-data-retrieval
174
184
  - bin/ght-load
175
185
  - bin/ght-mirror-events
176
186
  - bin/ght-periodic-dump
177
187
  - bin/ght-rm-dupl
178
188
  - bin/ght-torrent-index
189
+ - CHANGELOG
190
+ - Gemfile
191
+ - Gemfile.lock
179
192
  - LICENSE
180
193
  - Rakefile
181
194
  - README.md
182
195
  - test/callstack_test.rb
183
196
  homepage: https://github.com/gousiosg/github-mirror
184
197
  licenses: []
185
-
186
- post_install_message:
187
- rdoc_options:
198
+ post_install_message: !binary |-
199
+ WxtbMzJtVmVyc2lvbiAwLjUbWzBtXSBHZW5lcmljIG1ldGhvZHMgZm9yIHJl
200
+ dHJpZXZpbmcgaXRlbXMgdGhhdCBhcmUgYm91bmQgdG8gcmVwb3NpdG9yaWVz
201
+ ClsbWzMybVZlcnNpb24gMC41G1swbV0gUHJvY2Vzc2luZyBvZiBwdWxsIHJl
202
+ cXVlc3RzIHdpdGggY29tbWl0cywgY29tbWVudHMgYW5kIGhpc3RvcnkKWxtb
203
+ MzJtVmVyc2lvbiAwLjUbWzBtXSBQcm9jZXNzaW5nIG9mIHByb2plY3QgZm9y
204
+ a3MKWxtbMzJtVmVyc2lvbiAwLjUbWzBtXSBOZXcgdG9vbCAoZ2h0LWxvYWQp
205
+ IHRvIGZpbHRlciBhbmQgbG9hZCBldmVudHMgdG8gdGhlIHF1ZXVlClsbWzMy
206
+ bVZlcnNpb24gMC41G1swbV0gTmV3IHRvb2wgKGdodC1ybS1kdXBsKSB0byBk
207
+ ZWxldGUgZHVwbGljYXRlIGVudHJpZXMgZnJvbSBjb2xsZWN0aW9ucyAoZXZl
208
+ bnRzICYgY29tbWl0cyBzdXBwb3J0ZWQpClsbWzMybVZlcnNpb24gMC41G1sw
209
+ bV0gUHJvamVjdCB3aWRlIHJlcXVlc3RpbmcgcmVzdWx0IGNhY2hpbmcgZm9y
210
+ IG11bHRpLXBhZ2UgcmVxdWVzdHMKWxtbMzJtVmVyc2lvbiAwLjUbWzBtXSBC
211
+ ZXR0ZXIgbG9nZ2luZyBpbiB2YXJpb3VzIHBsYWNlcwpbG1szMm1WZXJzaW9u
212
+ IDAuNRtbMG1dIEJldHRlciBkZWZhdWx0cyBmb3IgTXlTUUwgKFVURjggKyBJ
213
+ bm5vREIgdGFibGVzKQpbG1szMm1WZXJzaW9uIDAuNRtbMG1dIENvbW1pdHMg
214
+ YXJlIG5vdyBzZXBlcmF0ZWQgZnJvbSBwcm9qZWN0cy4gUHJvamVjdCBmb3Jr
215
+ cyBjYW4gc2hhcmUgY29tbWl0cy4KWxtbMzJtVmVyc2lvbiAwLjUbWzBtXSBT
216
+ dXBwb3J0IGZvciBzZXR0aW5nIHRoZSBJUCBhZGRyZXNzIHRvIHVzZSBmb3Ig
217
+ cmV0cmlldmFsIG9uIG11bHRpLWhvbWVkClsbWzMybVZlcnNpb24gMC41G1sw
218
+ bV0gQ29tcGF0aWJpbGl0eSB3aXRoIFJ1YnkgMS45IChub3cgZGVmYXVsdCkg
219
+ YW5kIEpSdWJ5ClsbWzMybVZlcnNpb24gMC41G1swbV0gUHJvcGVyIG1vZHVs
220
+ YXJpemF0aW9uLCBmb2xsb3dpbmcgdGhlIGNha2UgZGVzaWduIHBhdHRlcm4K
221
+ WxtbMzJtVmVyc2lvbiAwLjUbWzBtXSBOZXZlciByZXRyaWV2ZSBhcnJheXMg
222
+ b2YgcmVzdWx0cyBmcm9tIE1vbmdvREIK
223
+ rdoc_options:
188
224
  - --charset=UTF-8
189
- require_paths:
225
+ require_paths:
190
226
  - lib
191
- required_ruby_version: !ruby/object:Gem::Requirement
227
+ required_ruby_version: !ruby/object:Gem::Requirement
192
228
  none: false
193
- requirements:
194
- - - ">="
195
- - !ruby/object:Gem::Version
196
- hash: 3
197
- segments:
198
- - 0
199
- version: "0"
200
- required_rubygems_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ! '>='
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
234
  none: false
202
- requirements:
203
- - - ">="
204
- - !ruby/object:Gem::Version
205
- hash: 3
206
- segments:
207
- - 0
208
- version: "0"
235
+ requirements:
236
+ - - ! '>='
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
209
239
  requirements: []
210
-
211
240
  rubyforge_project:
212
241
  rubygems_version: 1.8.24
213
242
  signing_key:
214
243
  specification_version: 3
215
244
  summary: Mirror and process Github data
216
245
  test_files: []
217
-