Module: GemGit::Helper
Defined Under Namespace
Classes: NoGithubCredentialsError, NotOnGithubError
Instance Method Summary
collapse
Instance Method Details
#git(*args) ⇒ Object
9
10
11
|
# File 'lib/gem_git/helper.rb', line 9
def git(*args)
exec("git #{args.join(' ')}")
end
|
#github_clone_url(user, repos) ⇒ Object
46
47
48
|
# File 'lib/gem_git/helper.rb', line 46
def github_clone_url(user, repos)
"[email protected]:#{user}/#{repos}.git"
end
|
#github_info_for(gem_name) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/gem_git/helper.rb', line 27
def github_info_for(gem_name)
repository_url = repository_url_for(gem_name)
begin
parsed_url = URI.parse(repository_url)
if parsed_url.host == "github.com"
parsed_url.path.split("/").slice(1,2) else
raise NotOnGithubError.new
end
rescue URI::InvalidURIError
raise NotOnGithubError.new
end
end
|
#github_token ⇒ Object
20
21
22
23
24
25
|
# File 'lib/gem_git/helper.rb', line 20
def github_token
@github_token ||= `git config --get github.token`.chomp
raise NoGithubCredentialsError.new if @github_token.empty?
@github_token
end
|
#github_user ⇒ Object
13
14
15
16
17
18
|
# File 'lib/gem_git/helper.rb', line 13
def github_user
@github_user ||= `git config --get github.user`.chomp
raise NoGithubCredentialsError.new if @github_user.empty?
@github_user
end
|
#repository_url_for(gem_name) ⇒ Object
42
43
44
|
# File 'lib/gem_git/helper.rb', line 42
def repository_url_for(gem_name)
JSON.parse(Net::HTTP.get('rubygems.org', "/api/v1/gems/#{gem_name}.json"))['source_code_uri']
end
|