class Sah::Config
Attributes
format[RW]
password[RW]
protocol[RW]
upstream_fetch_pull_request[RW]
upstream_prevent_push[RW]
upstream_remote_name[RW]
url[RW]
user[RW]
verbose[RW]
Public Class Methods
new(profile, verbose: false, format: :table)
click to toggle source
# File lib/sah/config.rb, line 10 def initialize(profile, verbose: false, format: :table) @user, @password, @url = nil, nil, nil @upstream_fetch_pull_request = false @upstream_prevent_push = false @upstream_remote_name = "upstream" @protocol = "ssh" @format = format @verbose = verbose profile_prefix = "sah\.profile\.#{profile}" config_prefix = "sah\.config" %x(git config --get-regex "^sah\.").each_line do |line| case line when /#{profile_prefix}\.user (.*)$/ @user = $1 when /#{profile_prefix}\.password (.*)$/ @password = $1 when /#{profile_prefix}\.url (.*)$/ @url = URI.parse $1 when /#{config_prefix}\.upstream-fetch-pull-request (.*)$/ @upstream_fetch_pull_request = ($1 == "true") when /#{config_prefix}\.upstream-prevent-push (.*)$/ @upstream_prevent_push = ($1 == "true") when /#{config_prefix}\.upstream-remote-name (.*)$/ @upstream_remote_name = $1 when /#{config_prefix}\.protocol (.*)$/ @protocol = $1 end end unless @user && @password && @url abort "Invalid profile: #{profile}" end unless ["ssh", "http"].include? @protocol abort "protocol must be set to ssh or http: #{@protocol}" end unless ["json", "table"].include? @format abort "format must be set to json or table: #{@format}" end end