Class: Git2bit::GithubProxy

Inherits:
Object
  • Object
show all
Includes:
Methadone::CLILogging, Methadone::Main
Defined in:
lib/git2bit/github.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ GithubProxy

Returns a new instance of GithubProxy.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/git2bit/github.rb', line 10

def initialize(args)
	@repo = args[:repo]
	@user = args[:user]
   @org = args[:org]
   if @org
     @repo_owner = @org
   else
     @repo_owner = @user
   end
	begin
			@conn = Github.new :basic_auth => "#{@user}:#{args[:pass]}"
			@conn.repos.list user: @user
		info "Successfully connected to Github with user #{@user}"
   rescue Exception => e 
     error = ["Error: Unable to connect to Github with user #{@user}", e.message].push e.backtrace
     exit_now!(error.join("\n"))
   end
end

Instance Method Details

#each_issue(process_closed = true) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git2bit/github.rb', line 29

def each_issue(process_closed = true)
	data = Array.new
	data.push @conn.issues.list :filter => 'all', :state => 'open', :user => @repo_owner, :repo => @repo
	if process_closed
		data.push @conn.issues.list :filter => 'all', :state => 'closed', :user => @repo_owner, :repo => @repo
	end

	data.each do |result_set|
		result_set.each_page do |page|
		  page.each {|issue| yield(issue)}
		end
	end
end

#get_comments(issue_id) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/git2bit/github.rb', line 43

def get_comments(issue_id)	    
	begin
		# Get Github comments for issue ID
		comments = @conn.issues.comments.all @repo_owner, @repo, issue_id: issue_id
		debug "Github: got comments for issue ##{issue_id}: " + comments.inspect
   rescue Exception => e 
     error "Error: Unable to get comments for Github issue ##{issue_id} - " + e.message
     debug e.backtrace.join("\n")
   end
   comments
end