class Getv::Package::GitHub

Getv::Package::GitHub class

Public Class Methods

new(name, opts = {}) click to toggle source
Calls superclass method Getv::Package::new
# File lib/getv/package/github.rb, line 7
def initialize(name, opts = {})
  super name, opts
end

Private Instance Methods

github() click to toggle source
# File lib/getv/package/github.rb, line 22
def github # rubocop:disable Metrics/MethodLength
  require 'octokit'
  if opts[:token]
    github = Octokit::Client.new(access_token: opts[:token])
    user = github.user
    user.login
  else
    github = Octokit::Client.new
  end
  github.auto_paginate = true
  github.proxy = opts[:proxy]
  github
end
github_defaults(name) click to toggle source
# File lib/getv/package/github.rb, line 13
def github_defaults(name)
  case name.count('/')
  when 1
    { owner: name.split('/')[0], repo: name.split('/')[1], token: nil }
  else
    { owner: name, repo: name, token: nil }
  end
end