Module: HybridPlatformsConductor::CommonConfigDsl::Github
- Defined in:
- lib/hybrid_platforms_conductor/common_config_dsl/github.rb
Instance Method Summary collapse
-
#for_each_github_repo ⇒ Object
Iterate over each Github repository.
-
#github_repos(url: 'https://api.github.com', user:, repos: :all) ⇒ Object
Register new Github repositories.
-
#init_github ⇒ Object
Initialize the DSL.
Instance Method Details
#for_each_github_repo ⇒ Object
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.
-
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/hybrid_platforms_conductor/common_config_dsl/github.rb', line 41 def for_each_github_repo @github_repos.each do |repo_info| Octokit.configure do |c| c.api_endpoint = repo_info[:url] end Credentials.with_credentials_for(:github, @logger, @logger_stderr, url: repo_info[:url]) do |_github_user, github_token| client = Octokit::Client.new(access_token: github_token) (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 |
#github_repos(url: 'https://api.github.com', user:, repos: :all) ⇒ Object
Register new Github repositories
- Parameters
-
url (String): URL to the Github API [default: ‘api.github.com’]
-
user (String): User or organization name, storing repositories
-
repos (Array<String> or Symbol): List of repository names from this project, or :all for all [default: :all]
24 25 26 27 28 29 30 |
# File 'lib/hybrid_platforms_conductor/common_config_dsl/github.rb', line 24 def github_repos(url: 'https://api.github.com', user:, repos: :all) @github_repos << { url: url, user: user, repos: repos } end |
#init_github ⇒ Object
Initialize the DSL
11 12 13 14 15 16 |
# File 'lib/hybrid_platforms_conductor/common_config_dsl/github.rb', line 11 def init_github # List of Github repositories definitions # Array< Hash<Symbol, Object> > # Each definition is just mapping the signature of #github_repos @github_repos = [] end |