Module: Jackchop::GithubAPI

Included in:
TravisAPI
Defined in:
lib/jackchop/api/github_api.rb

Constant Summary collapse

GIT_REGEX =
%r{^(?:https://|git://|git@)github\.com[:/](.*/.+?)(\.git)?$}

Instance Method Summary collapse

Instance Method Details

#find_repo_nameObject



8
9
10
11
# File 'lib/jackchop/api/github_api.rb', line 8

def find_repo_name
  git_info = `git config --get remote.origin.url 2>&1`
  $1 if git_info =~ GIT_REGEX
end

#githubObject



13
14
15
16
17
18
19
# File 'lib/jackchop/api/github_api.rb', line 13

def github
	@github ||= begin
	github_username = ask("github username:")
	github_password = ::HighLine.ask("github password: ") { |q| q.echo = false }
	Github.new :login => github_username, :password => github_password
	end
end

#github_auth_tokenObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jackchop/api/github_api.rb', line 21

def github_auth_token
	@github_token || begin
		auth = github.oauth.all.find { |auth| auth.note == 'Jackchop' }
		if auth
			auth.token
		else
			auth = github.oauth.create "scopes" => ["user:email", "public_repo"], "note" => "Jackchop"
			auth.token
		end
	end
end