Sha256: be69d781689a094f93f2bbb640d59d8dd9730931462efa28a45eb70154197690

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

# Attach configuration to the KConfig module
module KExt
  module Github
    # GitHub configuration extension for attachment to KConfig::Configuration
    module GitHubConfigurationExtension
      def github
        @github ||= GitHubConfiguration.new
      end

      def github_debug
        github.debug
      end
    end

    # GitHub Configuration
    class GitHubConfiguration
      include KUtil::Data::InstanceVariablesToH
      include KLog::Logging

      attr_accessor :user
      attr_accessor :personal_access_token
      attr_accessor :personal_access_token_delete

      def initialize
        @user = ENV['GH_USER'] || ENV['GITHUB_USER']
        @personal_access_token = ENV['GITHUB_PERSONAL_ACCESS_TOKEN']
        @personal_access_token_delete = ENV['GITHUB_PERSONAL_ACCESS_TOKEN_DELETE']
      end

      def debug
        log.section_heading 'GitHub Configuration'
        log.kv 'user', user
        log.kv 'personal_access_token', '***'
        log.kv 'personal_access_token_delete', '***'
      end
    end
  end
end

KConfig::Configuration.register(:github, KExt::Github::GitHubConfigurationExtension)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
k_ext-github-0.0.8 lib/k_ext/github/github_configuration.rb