github-api-client 0.1.3.0 → 0.1.3.2
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/lib/github_api.rb +1 -0
- data/lib/github_api/base.rb +12 -6
- data/lib/github_api/browser.rb +2 -2
- data/lib/github_api/config.rb +2 -0
- data/lib/github_api/repo.rb +4 -3
- data/lib/github_api/user.rb +8 -6
- metadata +3 -3
data/lib/github_api.rb
CHANGED
data/lib/github_api/base.rb
CHANGED
@@ -17,15 +17,21 @@ module GitHub
|
|
17
17
|
def self.sync
|
18
18
|
puts "Synchronizing local database with GitHub"
|
19
19
|
users = GitHub::User.all
|
20
|
-
|
21
|
-
|
20
|
+
repos = GitHub::Repo.all
|
21
|
+
puts "Updating Records of all #{"users".color(:yellow).bright}"
|
22
|
+
progress = ProgressBar.new("Updating records", users.count)
|
22
23
|
users.each do |user|
|
23
|
-
puts "#{count.to_s.color(:green).bright} / #{i.to_s.color(:blue).bright} - Updating records"
|
24
|
-
i = i + 1
|
25
24
|
# Disabled because of its length
|
26
|
-
|
27
|
-
|
25
|
+
user.fetch(:self)
|
26
|
+
progress.inc
|
28
27
|
end
|
28
|
+
progress.finish
|
29
|
+
progress = ProgressBar.new("Updating records", repos.count)
|
30
|
+
repos.each do |repo|
|
31
|
+
repo.fetch(:self, :watchers)
|
32
|
+
progress.inc
|
33
|
+
end
|
34
|
+
progress.finish
|
29
35
|
nil
|
30
36
|
end
|
31
37
|
|
data/lib/github_api/browser.rb
CHANGED
@@ -14,7 +14,7 @@ module GitHub
|
|
14
14
|
# @return [String] request result
|
15
15
|
def self.get(uri)
|
16
16
|
uri = uri.gsub(" ","+")
|
17
|
-
puts "Requesting #{URI.parse(self.base_uri + uri)}"
|
17
|
+
puts "Requesting #{URI.parse(self.base_uri + uri)}" if GitHub::Config::Options[:verbose]
|
18
18
|
Net::HTTP.get URI.parse(self.base_uri + uri)
|
19
19
|
end
|
20
20
|
|
@@ -23,7 +23,7 @@ module GitHub
|
|
23
23
|
# @return [String] request result
|
24
24
|
def self.post(uri, options = {})
|
25
25
|
uri = uri.gsub(" ","+")
|
26
|
-
puts "Requesting #{URI.parse(self.base_uri + uri)} with options: #{options}"
|
26
|
+
puts "Requesting #{URI.parse(self.base_uri + uri)} with options: #{options}" if GitHub::Config::Options[:verbose]
|
27
27
|
Net::HTTP.post_form URI.parse(self.base_uri + uri), options
|
28
28
|
end
|
29
29
|
end
|
data/lib/github_api/config.rb
CHANGED
data/lib/github_api/repo.rb
CHANGED
@@ -34,15 +34,16 @@ module GitHub
|
|
34
34
|
private
|
35
35
|
def get_watchers
|
36
36
|
watchers = YAML::load(GitHub::Browser.get("/repos/show/#{self.permalink}/watchers"))['watchers']
|
37
|
-
|
37
|
+
puts "Fetching watchers for #{"repo".color(:blue).bright} #{self.permalink.color(:green).bright}"
|
38
|
+
progress = ProgressBar.new("progress", watchers.count)
|
38
39
|
self.transaction do
|
39
40
|
watchers.each do |watcher|
|
40
|
-
puts "#{watchers.length.to_s.color(:green).bright} / #{i.to_s.color(:blue).bright} - Fetching watchers"
|
41
|
-
i = i + 1
|
42
41
|
attr = {:login => watcher}
|
43
42
|
self.watchers.find_or_create(GitHub::User.find_or_create_by_login(attr))
|
43
|
+
progress.inc
|
44
44
|
end
|
45
45
|
end
|
46
|
+
progress.finish
|
46
47
|
self
|
47
48
|
end
|
48
49
|
|
data/lib/github_api/user.rb
CHANGED
@@ -73,29 +73,31 @@ module GitHub
|
|
73
73
|
private
|
74
74
|
def get_followers
|
75
75
|
users = YAML::load(GitHub::Browser.get "/user/show/#{login}/followers")['users']
|
76
|
-
|
76
|
+
puts "Fetching followers for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
|
77
|
+
progress = ProgressBar.new("progress", users.count)
|
77
78
|
self.transaction do
|
78
79
|
users.each do |user|
|
79
|
-
puts "#{users.length.to_s.color(:green).bright} / #{i.to_s.color(:blue).bright} - Fetching followers"
|
80
|
-
i = i + 1
|
81
80
|
u = GitHub::User.find_or_create_by_login(user)
|
82
81
|
self.followers.find_or_create u
|
82
|
+
progress.inc
|
83
83
|
end
|
84
84
|
end
|
85
|
+
progress.finish
|
85
86
|
self
|
86
87
|
end
|
87
88
|
|
88
89
|
def get_followings
|
89
90
|
users = YAML::load(GitHub::Browser.get "/user/show/#{login}/following")['users']
|
90
|
-
|
91
|
+
puts "Fetching followings for #{"user".color(:yellow).bright} #{self.login.color(:green).bright}"
|
92
|
+
progress = ProgressBar.new("progress", users.count)
|
91
93
|
self.transaction do
|
92
94
|
users.each do |user|
|
93
|
-
puts "#{users.length.to_s.color(:green).bright} / #{i.to_s.color(:blue).bright} - Fetching followings"
|
94
|
-
i = i + 1
|
95
95
|
u = GitHub::User.find_or_create_by_login(user)
|
96
96
|
self.followings.find_or_create u
|
97
|
+
progress.inc
|
97
98
|
end
|
98
99
|
end
|
100
|
+
progress.finish
|
99
101
|
self
|
100
102
|
end
|
101
103
|
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.1.3.
|
9
|
+
- 2
|
10
|
+
version: 0.1.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jakub Oko\xC5\x84ski"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-04 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|