Module: Git::Hub

Defined in:
lib/git/hub.rb

Class Method Summary collapse

Class Method Details

.connected?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/git/hub.rb', line 30

def connected?
  @connected ||= begin
    client.validate_credentials
    true
  rescue Faraday::ConnectionFailed
    false
  end
end

.loginObject

FIXME: update login as part of ‘–refresh`



41
42
43
44
45
46
47
# File 'lib/git/hub.rb', line 41

def 
  @login ||= begin
    client.user.
  rescue Octokit::Unauthorized, Faraday::ConnectionFailed
    nil
  end
end

.org_repositories(org, type = :owner) ⇒ Object



102
103
104
105
# File 'lib/git/hub.rb', line 102

def org_repositories(org, type = :owner)
  # type can be one of: all, public, private, forks, sources, member
  @org_repositories[[org, type]]
end

.orgsObject

FIXME: update orgs as part of ‘–refresh`



51
52
53
54
55
56
57
# File 'lib/git/hub.rb', line 51

def orgs
  @orgs ||= begin
    client.organizations.map(&:login)
  rescue Octokit::Unauthorized, Faraday::ConnectionFailed
    []
  end
end

.query_argsObject



65
66
67
68
69
70
71
# File 'lib/git/hub.rb', line 65

def query_args
  # rubocop:disable Style/FormatStringToken
  repository_fields.sort.each_slice(3).map { |foo, bar, qux|
    format('%-20s %-20s %-20s', foo, bar, qux).rstrip
  }.join("\n    ")
  # rubocop:enable Style/FormatStringToken
end

.repository_fieldsObject

pick a (semi-)random repo from GitHub



61
62
63
# File 'lib/git/hub.rb', line 61

def repository_fields
  client.repo('git/git').fields
end

.user_repositories(user, type = :owner) ⇒ Object



85
86
87
88
# File 'lib/git/hub.rb', line 85

def user_repositories(user, type = :owner)
  # type can be one of: all, owner, member
  @user_repositories[[user, type]]
end