hubmaster 0.0.06 → 0.0.07

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,19 @@
1
1
  # Hubmaster
2
2
 
3
- Hubmaster is a rubygem that allows GitHub API interaction in Terminal. The current version only permit repository interactions (list, create, delete), but feel free to fork and contribute!
3
+ Hubmaster is a rubygem that allows GitHub API interaction in Terminal. The current version only permits repository interactions, but feel free to fork and contribute!
4
4
 
5
+ ## Table of Contents
6
+
7
+ * [Installation](#install)
8
+ * [Overview](#overview)
9
+ * [Repository Documentation](#repos)
10
+ * [List](#reposList)
11
+ * [Get](#reposGet)
12
+ * [Create](#reposCreate)
13
+ * [Edit](#reposEdit)
14
+ * [Delete](#reposDelete)
15
+
16
+ <a name="install"/>
5
17
  ## Installation
6
18
 
7
19
  To use as a library, add this line to your application's Gemfile:
@@ -16,39 +28,48 @@ To use as a command line tool, run:
16
28
 
17
29
  sudo gem install hubmaster
18
30
 
19
- ## Usage
31
+ <a name="overview"/>
32
+ ## Overview
33
+
34
+ Hubmaster is a library written in ruby that makes interfacing with github a snap! In adition to being a library, hubmaster also includes an executable
35
+ command line tool that allows github web operations to be carried out in terminal. The rest of the document details how hubmaster should be used, but there are a few things to note beforehand.
20
36
 
21
- The general form for executing commands is `hub repos --modifier [params]`. All parameters that include spaces must be encased in quotes.
37
+ 1. The general form for executing commands is `hub repos --modifier [params]`. All parameters that include spaces must be encased in quotes.
22
38
 
23
- **BEWARE:** For the purposes of this document, when words are surrounded by brackets, the indicated value should be placed there **without brackets**.
39
+ 2. **BEWARE:** For the purposes of this document, when words are surrounded by brackets, the indicated value should be placed there **without brackets**.
24
40
 
25
- ***
41
+ <a name="repos"/>
42
+ ## Repository Documentation
43
+
44
+ This section of the documentation includes all the necessary information on interfacing with repositories through hubmaster.
45
+ There are five main functions that will be described in further detail: List, Get, Create, Edit, and Delete.
46
+
47
+ <a name="reposList"/>
48
+ ### List
26
49
 
27
50
  To list all repositories under your account:
28
51
 
29
52
  hub repos --list
30
53
 
31
- ***
32
54
 
33
55
  To list all repositories under someone elses account:
34
56
 
35
57
  hub repos --list [username]
36
58
 
37
- ***
59
+ <a name="reposGet">
60
+ ### Get
61
+
62
+
63
+ <a name="reposCreate"/>
64
+ ### Create
38
65
 
39
66
  To create a new repository:
40
67
 
41
68
  hub repos --create [name] "[description]"
42
69
  *Additionaly this command can be run with no parameters and you will be prompted for them later.*
43
70
 
44
- ***
45
-
46
- To delete an existing repository:
47
-
48
- hub repos --delete [name]
49
- *Andy you will be asked to confirm by typing the name of the repository specified.*
50
-
51
- ***
71
+ <a name="reposEdit"/>
72
+ ### Edit
52
73
 
53
74
  To edit an existing repository:
54
75
 
@@ -60,3 +81,13 @@ To edit an existing repository:
60
81
  Finally, you can either specify the change now or be prompted for it later.*
61
82
 
62
83
  **REMEMBER: IF ANY PARAMETERS INCLUDE SPACES, THEY MUST BE ENCASED IN QUOTES**
84
+
85
+ <a name="reposDelete"/>
86
+ ### Delete
87
+
88
+ To delete an existing repository:
89
+
90
+ hub repos --delete [name]
91
+ *Andy you will be asked to confirm by typing the name of the repository specified.*
92
+
93
+
data/bin/hub CHANGED
@@ -17,7 +17,25 @@ if ARGV.length > 0
17
17
  Github::Repos.delete(ARGV[2])
18
18
  when "--get"
19
19
  Github.connect
20
- Github::Repos.get(ARGV[2], ARGV[3])
20
+
21
+ case ARGV[2]
22
+ when "-contributers", "-contribs"
23
+ Github::Repos.get(ARGV[3], ARGV[4], :contributers)
24
+ when "-repo", "-repository"
25
+ Github::Repos.get(ARGV[3], ARGV[4], :repository)
26
+ when "-langs", "-languages"
27
+ Github::Repos.get(ARGV[3], ARGV[4], :languages)
28
+ when "-teams"
29
+ Github::Repos.get(ARGV[3], ARGV[4], :teams)
30
+ when "-tags"
31
+ Github::Repos.get(ARGV[3], ARGV[4], :tags)
32
+ when "-branches"
33
+ Github::Repos.get(ARGV[3], ARGV[4], :branches)
34
+ when "-branch"
35
+ Github::Repos.get(ARGV[3], ARGV[4], :branch, ARGV[5])
36
+ else
37
+ puts "Unknown modifier for get '#{ARGV[2]}'. Tyle hub help for assistance."
38
+ end
21
39
  when "--edit"
22
40
  Github.connect
23
41
  case ARGV[3]
@@ -10,28 +10,3 @@ require File.expand_path(File.join(File.dirname(__FILE__), "hubmaster", "base.rb
10
10
  require File.expand_path(File.join(File.dirname(__FILE__), "hubmaster", "repo.rb"))
11
11
  require File.expand_path(File.join(File.dirname(__FILE__), "hubmaster", "cipher.rb"))
12
12
 
13
- def run_pager
14
- return if RUBY_PLATFORM =~ /win32/
15
- return unless STDOUT.tty?
16
-
17
- read, write = IO.pipe
18
-
19
- unless Kernel.fork # Child process
20
- STDOUT.reopen(write)
21
- STDERR.reopen(write) if STDERR.tty?
22
- read.close
23
- write.close
24
- return
25
- end
26
-
27
- STDIN.reopen(read)
28
- read.close
29
- write.close
30
-
31
- ENV['LESS'] = 'FSRX' # Don't page if the input is short enough
32
-
33
- Kernel.select [STDIN] # Wait until we have input before we start the pager
34
- pager = ENV['PAGER'] || 'less'
35
- exec pager rescue exec "/bin/sh", "-c", pager
36
- end
37
-
@@ -1,6 +1,5 @@
1
1
  module Github
2
2
  def self.connect
3
- run_pager
4
3
  if File.exists? "#{Dir.home}/.hubmaster"
5
4
  content = []
6
5
  File.open("#{Dir.home}/.hubmaster", "rb") do |fileC|
@@ -117,14 +117,142 @@ module Github
117
117
  puts ""
118
118
  end
119
119
 
120
- def self.get(owner, name)
121
- if !name.nil?
122
- if owner == "self"
123
- request = Github.makeGetRequest("/repos/#{Github.user}/#{name}")
124
- else
125
- request = Github.makeGetRequest("/repos/#{owner}/#{name}")
120
+ def self.get(owner, name, operator, branch = nil)
121
+ owner = Github.user if owner == "self"
122
+
123
+ if owner.nil?
124
+ print "Name of owner: "
125
+ owner = STDIN.gets.chomp
126
+ end
127
+
128
+ if name.nil?
129
+ print "Name of repository: "
130
+ name = STDIN.gets.chomp
131
+ end
132
+
133
+ case operator
134
+ when :contributers
135
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}/contributors")
136
+ response = JSON.parse(request)
137
+
138
+ if response.kind_of?(Array)
139
+ response.each do |contributer|
140
+ puts "User #{contributer["login"]}"
141
+ puts " - URL: #{contributer["url"]}"
142
+ puts " - Contributions #{contributer["contributions"]}"
143
+ puts ""
144
+ end
145
+ elsif !response["errors"].nil?
146
+ puts "ERROR: #{response['errors'][0]['message']}"
147
+ puts ""
148
+ elsif !response["message"].nil?
149
+ puts "ERROR: #{response["message"]}"
150
+ puts ""
126
151
  end
152
+ when :languages
153
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}/languages")
154
+ response = JSON.parse(request)
127
155
 
156
+ if response["errors"].nil? && response["message"].nil?
157
+ response.each do |language, bytes|
158
+ puts "#{bytes} bytes written in #{language}."
159
+ puts ""
160
+ end
161
+ elsif !response["errors"].nil?
162
+ puts "ERROR: #{response['errors'][0]['message']}"
163
+ puts ""
164
+ elsif !response["message"].nil?
165
+ puts "ERROR: #{response["message"]}"
166
+ puts ""
167
+ end
168
+ when :teams #UNTESTED METHOD BECAUSE I DONT KNOW ANY EXAMPLES
169
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}/teams")
170
+ response = JSON.parse(request)
171
+
172
+ if response.kind_of?(Array)
173
+ response.each do |team|
174
+ puts "Team: #{team["name"]}"
175
+ puts " - URL: #{team["url"]}"
176
+ puts ""
177
+ end
178
+ elsif !response["errors"].nil?
179
+ puts "ERROR: #{response['errors'][0]['message']}"
180
+ puts ""
181
+ elsif !response["message"].nil?
182
+ puts "ERROR: #{response["message"]}"
183
+ puts ""
184
+ end
185
+ when :tags
186
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}/tags")
187
+ response = JSON.parse(request)
188
+
189
+ if response.kind_of?(Array)
190
+ response.each do |tag|
191
+ puts "Tag Name: #{tag["name"]}"
192
+ puts " - Commit URL: #{tag["commit"]["url"]}"
193
+ puts " - Commit SHA: #{tag["commit"]["sha"]}"
194
+ puts ""
195
+ end
196
+ elsif !response["errors"].nil?
197
+ puts "ERROR: #{response['errors'][0]['message']}"
198
+ puts ""
199
+ elsif !response["message"].nil?
200
+ puts "ERROR: #{response["message"]}"
201
+ puts ""
202
+ end
203
+ when :branches
204
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}/branches")
205
+ response = JSON.parse(request)
206
+
207
+ if response.kind_of?(Array)
208
+ response.each do |branch|
209
+ puts "Branch Name: #{branch["name"]}"
210
+ puts " - Commit URL: #{branch["commit"]["url"]}"
211
+ puts " - Commit SHA: #{branch["commit"]["sha"]}"
212
+ puts ""
213
+ end
214
+ elsif !response["errors"].nil?
215
+ puts "ERROR: #{response['errors'][0]['message']}"
216
+ puts ""
217
+ elsif !response["message"].nil?
218
+ puts "ERROR: #{response["message"]}"
219
+ puts ""
220
+ end
221
+ when :branch
222
+ if branch.nil?
223
+ print "Branch to view: "
224
+ branch = STDIN.gets.chomp
225
+ end
226
+
227
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}/branches/#{branch}")
228
+ response = JSON.parse(request)
229
+
230
+ if response["errors"].nil? && response["message"].nil?
231
+ puts "Branch Name: #{response['name']}"
232
+ puts " - Commit SHA: #{response["commit"]["sha"]}"
233
+ puts " - Message: #{response["commit"]["commit"]["message"]}"
234
+ puts " - Author: #{response["commit"]["author"]["login"]}"
235
+ puts " - Author Name: #{response["commit"]["commit"]["author"]["name"]}"
236
+ puts " - Author Email: #{response["commit"]["commit"]["author"]["email"]}"
237
+
238
+ if response["commit"]["committer"]["login"] != response["commit"]["author"]["login"]
239
+ puts " - Commiter: #{response["commit"]["committer"]["login"]}"
240
+ puts " - Commiter Name: #{response["commit"]["commit"]["committer"]["name"]}"
241
+ puts " - Commiter Email: #{response["commit"]["commit"]["committer"]["email"]}"
242
+ end
243
+
244
+ puts " - Parents:"
245
+ response["commit"]["parents"].each do |parent|
246
+ puts " - Parent SHA: #{parent["sha"]}"
247
+ end
248
+ elsif !response["errors"].nil?
249
+ puts "ERROR: #{response['errors'][0]['message']}"
250
+ elsif !response["message"].nil?
251
+ puts "ERROR: #{response["message"]}"
252
+ end
253
+ puts ""
254
+ when :repository
255
+ request = Github.makeGetRequest("/repos/#{owner}/#{name}")
128
256
  response = JSON.parse(request)
129
257
 
130
258
  if response["errors"].nil? && response["message"].nil?
@@ -151,9 +279,6 @@ module Github
151
279
  elsif !response["message"].nil?
152
280
  puts "ERROR: #{response["message"]}"
153
281
  end
154
- puts ""
155
- else
156
- puts "A repository name must be specified."
157
282
  puts ""
158
283
  end
159
284
  end
@@ -1,3 +1,3 @@
1
1
  class Github
2
- VERSION = "0.0.06"
2
+ VERSION = "0.0.07"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.06
4
+ version: 0.0.07
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline