hubmaster 0.0.07 → 0.0.08
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hubmaster.rb +16 -0
- data/lib/hubmaster/repo.rb +31 -23
- data/lib/version.rb +1 -1
- metadata +1 -1
data/lib/hubmaster.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require "highline"
|
2
3
|
require 'highline/import'
|
3
4
|
require 'json'
|
4
5
|
require 'net/http'
|
@@ -10,3 +11,18 @@ require File.expand_path(File.join(File.dirname(__FILE__), "hubmaster", "base.rb
|
|
10
11
|
require File.expand_path(File.join(File.dirname(__FILE__), "hubmaster", "repo.rb"))
|
11
12
|
require File.expand_path(File.join(File.dirname(__FILE__), "hubmaster", "cipher.rb"))
|
12
13
|
|
14
|
+
def putLess(array)
|
15
|
+
string = array.join("\n")
|
16
|
+
|
17
|
+
if RUBY_PLATFORM =~ /win32/
|
18
|
+
puts string
|
19
|
+
else
|
20
|
+
windowHeight = HighLine::SystemExtensions.terminal_size[1]
|
21
|
+
|
22
|
+
if array.count >= windowHeight
|
23
|
+
IO.popen("less", "w") { |f| f.puts string}
|
24
|
+
else
|
25
|
+
puts string
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/hubmaster/repo.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Github
|
2
2
|
class Repos
|
3
3
|
def self.list(user = nil)
|
4
|
+
|
5
|
+
toput = []
|
4
6
|
if user.nil?
|
5
7
|
request = Github.makeGetRequest("/user/repos?sort=pushed")
|
6
8
|
else
|
@@ -11,25 +13,27 @@ module Github
|
|
11
13
|
|
12
14
|
if response.kind_of?(Array)
|
13
15
|
response.each do |repo|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
toput << "#{repo['name']} (#{repo['ssh_url']})"
|
17
|
+
toput << " - Description: #{repo['description']}"
|
18
|
+
toput << " - Owner: #{repo['owner']['login']}"
|
19
|
+
toput << " - Language: #{repo['language']}"
|
18
20
|
created_at = repo['created_at'].split("T")
|
19
21
|
created_at_date = created_at[0].split("-")
|
20
22
|
created_at_date = "#{created_at_date[1]}/#{created_at_date[2]}/#{created_at_date[0]}"
|
21
|
-
|
23
|
+
toput << " - Created At: #{created_at[1]} on #{created_at_date}"
|
22
24
|
updated_at = repo['updated_at'].split("T")
|
23
25
|
updated_at_date = updated_at[0].split("-")
|
24
26
|
updated_at_date = "#{updated_at_date[1]}/#{updated_at_date[2]}/#{updated_at_date[0]}"
|
25
|
-
|
26
|
-
|
27
|
+
toput << " - Last Updated: #{updated_at[1]} on #{updated_at_date}"
|
28
|
+
toput << ""
|
27
29
|
end
|
28
30
|
elsif !response["errors"].nil?
|
29
31
|
puts "ERROR: #{response['errors'][0]['message']}"
|
30
32
|
elsif !response["message"].nil?
|
31
33
|
puts "ERROR: #{response["message"]}"
|
32
34
|
end
|
35
|
+
|
36
|
+
putLess toput unless toput == []
|
33
37
|
end
|
34
38
|
|
35
39
|
def self.create(name, description)
|
@@ -120,6 +124,8 @@ module Github
|
|
120
124
|
def self.get(owner, name, operator, branch = nil)
|
121
125
|
owner = Github.user if owner == "self"
|
122
126
|
|
127
|
+
toput = []
|
128
|
+
|
123
129
|
if owner.nil?
|
124
130
|
print "Name of owner: "
|
125
131
|
owner = STDIN.gets.chomp
|
@@ -137,10 +143,10 @@ module Github
|
|
137
143
|
|
138
144
|
if response.kind_of?(Array)
|
139
145
|
response.each do |contributer|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
146
|
+
toput << "User #{contributer["login"]}"
|
147
|
+
toput << " - URL: #{contributer["url"]}"
|
148
|
+
toput << " - Contributions #{contributer["contributions"]}"
|
149
|
+
toput << ""
|
144
150
|
end
|
145
151
|
elsif !response["errors"].nil?
|
146
152
|
puts "ERROR: #{response['errors'][0]['message']}"
|
@@ -155,8 +161,8 @@ module Github
|
|
155
161
|
|
156
162
|
if response["errors"].nil? && response["message"].nil?
|
157
163
|
response.each do |language, bytes|
|
158
|
-
|
159
|
-
|
164
|
+
toput << "#{bytes} bytes written in #{language}."
|
165
|
+
toput << ""
|
160
166
|
end
|
161
167
|
elsif !response["errors"].nil?
|
162
168
|
puts "ERROR: #{response['errors'][0]['message']}"
|
@@ -171,8 +177,8 @@ module Github
|
|
171
177
|
|
172
178
|
if response.kind_of?(Array)
|
173
179
|
response.each do |team|
|
174
|
-
|
175
|
-
|
180
|
+
toput << "Team: #{team["name"]}"
|
181
|
+
toput << " - URL: #{team["url"]}"
|
176
182
|
puts ""
|
177
183
|
end
|
178
184
|
elsif !response["errors"].nil?
|
@@ -188,10 +194,10 @@ module Github
|
|
188
194
|
|
189
195
|
if response.kind_of?(Array)
|
190
196
|
response.each do |tag|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
197
|
+
toput << "Tag Name: #{tag["name"]}"
|
198
|
+
toput << " - Commit URL: #{tag["commit"]["url"]}"
|
199
|
+
toput << " - Commit SHA: #{tag["commit"]["sha"]}"
|
200
|
+
toput << ""
|
195
201
|
end
|
196
202
|
elsif !response["errors"].nil?
|
197
203
|
puts "ERROR: #{response['errors'][0]['message']}"
|
@@ -206,9 +212,9 @@ module Github
|
|
206
212
|
|
207
213
|
if response.kind_of?(Array)
|
208
214
|
response.each do |branch|
|
209
|
-
|
210
|
-
|
211
|
-
|
215
|
+
toput << "Branch Name: #{branch["name"]}"
|
216
|
+
toput << " - Commit URL: #{branch["commit"]["url"]}"
|
217
|
+
toput << " - Commit SHA: #{branch["commit"]["sha"]}"
|
212
218
|
puts ""
|
213
219
|
end
|
214
220
|
elsif !response["errors"].nil?
|
@@ -280,7 +286,9 @@ module Github
|
|
280
286
|
puts "ERROR: #{response["message"]}"
|
281
287
|
end
|
282
288
|
puts ""
|
283
|
-
end
|
289
|
+
end
|
290
|
+
|
291
|
+
putLess toput unless toput == []
|
284
292
|
end
|
285
293
|
end
|
286
294
|
end
|
data/lib/version.rb
CHANGED