Sha256: 466c8540236d405bea858ecec20494b79ef51528ccbadbef381c3161c9536c7b

Contents?: true

Size: 1.21 KB

Versions: 18

Compression:

Stored size: 1.21 KB

Contents

require 'octokit'
require 'hybrid_platforms_conductor/credentials'

module HybridPlatformsConductor

  # Mixin used to access Github API
  module Github

    include Credentials

    # Iterate over each Github repository
    #
    # Parameters::
    # * Proc: Code called for each Github repository:
    #   * Parameters::
    #     * *github* (Octokit::Client): The client instance accessing the Github API
    #     * *repo_info* (Hash<Symbol, Object>): The repository info:
    #       * *name* (String): Repository name.
    #       * *slug* (String): Repository slug.
    def for_each_github_repo
      @config.known_github_repos.each do |repo_info|
        Octokit.configure do |c|
          c.api_endpoint = repo_info[:url]
        end
        with_credentials_for(:github, resource: repo_info[:url]) do |_github_user, github_token|
          client = Octokit::Client.new(access_token: github_token&.to_unprotected)
          (repo_info[:repos] == :all ? client.repositories(repo_info[:user]).map { |repo| repo[:name] } : repo_info[:repos]).each do |name|
            yield client, {
              name: name,
              slug: "#{repo_info[:user]}/#{name}"
            }
          end
        end
      end
    end

  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.9.4 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.9.2 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.9.1 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.9.0 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.8.4 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.8.3 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.8.2 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.8.1 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.8.0 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.7.4 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.7.3 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.7.2 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.7.1 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.7.0 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.6.0 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.5.1 lib/hybrid_platforms_conductor/github.rb
hybrid_platforms_conductor-33.5.0 lib/hybrid_platforms_conductor/github.rb