github-api-client 0.1.1.3 → 0.1.1.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/lib/github_api.rb +1 -1
- data/lib/github_api/user.rb +16 -1
- metadata +2 -2
data/lib/github_api.rb
CHANGED
data/lib/github_api/user.rb
CHANGED
@@ -45,6 +45,7 @@ module GitHub
|
|
45
45
|
# @param [Array<Symbol>] things Things to fetch for GitHub::User
|
46
46
|
# @option things [Symbol] :self Sync with GitHub Database
|
47
47
|
# @option things [Symbol] :followers Map followers from GitHub Database
|
48
|
+
# @option things [Symbol] :followings Map user's followings from GitHub
|
48
49
|
# @return [GitHub::User] Chainable, updated User
|
49
50
|
# @see GitHub::User#get
|
50
51
|
# @see GitHub::User#get_followers
|
@@ -53,6 +54,7 @@ module GitHub
|
|
53
54
|
case thing
|
54
55
|
when :self then get
|
55
56
|
when :followers then get_followers
|
57
|
+
when :followings then get_followings
|
56
58
|
end
|
57
59
|
end
|
58
60
|
self
|
@@ -66,7 +68,7 @@ module GitHub
|
|
66
68
|
users = YAML::load(GitHub::Browser.get "/user/show/#{login}/followers")['users']
|
67
69
|
i = 1
|
68
70
|
users.each do |user|
|
69
|
-
puts "#{users.length.to_s} / #{i.to_s} - Fetching followers"
|
71
|
+
puts "#{users.length.to_s.color(:green).bright} / #{i.to_s.color(:blue).bright} - Fetching followers"
|
70
72
|
i = i + 1
|
71
73
|
u = GitHub::User.find_or_create_by_login(user)
|
72
74
|
self.followers.find_or_create u
|
@@ -76,10 +78,23 @@ module GitHub
|
|
76
78
|
self
|
77
79
|
end
|
78
80
|
|
81
|
+
def get_followings
|
82
|
+
users = YAML::load(GitHub::Browser.get "/user/show/#{login}/following")['users']
|
83
|
+
i = 1
|
84
|
+
users.each do |user|
|
85
|
+
puts "#{users.length.to_s.color(:green).bright} / #{i.to_s.color(:blue).bright} - Fetching followings"
|
86
|
+
i = i + 1
|
87
|
+
u = GitHub::User.find_or_create_by_login(user)
|
88
|
+
self.followings.find_or_create u
|
89
|
+
end
|
90
|
+
self
|
91
|
+
end
|
92
|
+
|
79
93
|
public
|
80
94
|
# Returns an array with logins of GitHub::User followers
|
81
95
|
# @param [String] login GitHub login of which followers will be mapped
|
82
96
|
# @return [Array<GitHub::User>] Followers
|
97
|
+
# @deprecated It should not support such way, there should be objects!
|
83
98
|
def self.get_followers(login)
|
84
99
|
users = YAML::load(GitHub::Browser.get "/user/show/#{login}/followers")['users']
|
85
100
|
|