Sha256: d2509b6aa0b242f240cd01a8b3d4c3425af57cd4725c32eb7acffc8053218779

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

require 'octokit'
require 'octoauth'

module Targit
  ##
  # Helper module to load a GitHub API client object
  module Client
    private

    def client
      @client ||= _client
    end

    def _client
      auth = Octoauth.new octoauth_options
      Octokit::Client.new(
        access_token: auth.token,
        api_endpoint: @options[:api_endpoint],
        web_endpoint: @options[:api_endpoint],
        auto_paginate: true
      )
    end

    def octoauth_options
      {
        note: 'targit',
        files: authfiles,
        autosave: @options[:autosave] || true,
        scopes: ['public_repo']
      }
    end

    def authfiles
      return [:default] unless @options[:authfile]
      @authfile ||= @options[:authfile].split(',')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
targit-2.0.2 lib/targit/client.rb
targit-2.0.1 lib/targit/client.rb