Module: Furik::Configurable
- Defined in:
- lib/furik/configurable.rb
Class Method Summary collapse
- .default_octokit_options ⇒ Object
- .github_access_token ⇒ Object
- .github_enterprise_access_token ⇒ Object
- .github_enterprise_host ⇒ Object
- .github_enterprise_host_by_pit ⇒ Object
- .github_enterprise_octokit_options ⇒ Object
- .github_octokit_options ⇒ Object
- .hub_config_path ⇒ Object
- .token_by_hub(host = 'github.com') ⇒ Object
- .token_by_pit(host = 'github.com') ⇒ Object
- .token_generate_path ⇒ Object
Class Method Details
.default_octokit_options ⇒ Object
48 49 50 51 52 53 |
# File 'lib/furik/configurable.rb', line 48 def { auto_paginate: true, per_page: 100 } end |
.github_access_token ⇒ Object
30 31 32 |
# File 'lib/furik/configurable.rb', line 30 def github_access_token token_by_hub || token_by_pit end |
.github_enterprise_access_token ⇒ Object
44 45 46 |
# File 'lib/furik/configurable.rb', line 44 def github_enterprise_access_token token_by_hub(github_enterprise_host) || token_by_pit(github_enterprise_host) end |
.github_enterprise_host ⇒ Object
34 35 36 |
# File 'lib/furik/configurable.rb', line 34 def github_enterprise_host ENV['GITHUB_ENTERPRISE_HOST'] || github_enterprise_host_by_pit end |
.github_enterprise_host_by_pit ⇒ Object
38 39 40 41 42 |
# File 'lib/furik/configurable.rb', line 38 def github_enterprise_host_by_pit Pit.get('furik', require: { 'github_enterprise_host' => 'Github:Enterprise Host?(ex: your.domain.com)' })['github_enterprise_host'] end |
.github_enterprise_octokit_options ⇒ Object
61 62 63 64 65 66 |
# File 'lib/furik/configurable.rb', line 61 def .merge( access_token: github_enterprise_access_token, api_endpoint: "https://#{github_enterprise_host}/api/v3/" ) end |
.github_octokit_options ⇒ Object
55 56 57 58 59 |
# File 'lib/furik/configurable.rb', line 55 def .merge( access_token: github_access_token ) end |
.hub_config_path ⇒ Object
7 8 9 |
# File 'lib/furik/configurable.rb', line 7 def hub_config_path ENV['HUB_CONFIG_PATH'] || "#{Dir.home}/.config/hub" end |
.token_by_hub(host = 'github.com') ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/furik/configurable.rb', line 15 def token_by_hub(host = 'github.com') return unless File.exist?(hub_config_path) hub_config = YAML.load_file hub_config_path if !hub_config[host].nil? && !hub_config[host].empty? hub_config[host].last['oauth_token'] end end |
.token_by_pit(host = 'github.com') ⇒ Object
24 25 26 27 28 |
# File 'lib/furik/configurable.rb', line 24 def token_by_pit(host = 'github.com') Pit.get(host, require: { 'access_token' => "#{host} Access Token? (https://#{host}#{token_generate_path})" })['access_token'] end |
.token_generate_path ⇒ Object
11 12 13 |
# File 'lib/furik/configurable.rb', line 11 def token_generate_path '/settings/tokens/new' end |