class GithubFlowCli::Config
Constants
- CONFIG_DIR
- CONFIG_FILE
- KEYS
Public Class Methods
config_path()
click to toggle source
# File lib/github_flow_cli/config.rb, line 56 def config_path FileUtils.mkdir_p(CONFIG_DIR) unless File.directory?(CONFIG_DIR) File.join(CONFIG_DIR, CONFIG_FILE) end
link_branch_to_issue(branch_name, issue)
click to toggle source
# File lib/github_flow_cli/config.rb, line 30 def link_branch_to_issue(branch_name, issue) self.branch_issue_map[branch_name] = issue.number end
link_pr_to_branch(pr, branch_name)
click to toggle source
# File lib/github_flow_cli/config.rb, line 34 def link_pr_to_branch(pr, branch_name) self.pr_branch_map[pr.number] = branch_name end
load()
click to toggle source
# File lib/github_flow_cli/config.rb, line 38 def load YAML::load_file(config_path).each { |k, v| send("#{k}=", v) } end
save!()
click to toggle source
# File lib/github_flow_cli/config.rb, line 42 def save! self.branch_issue_map ||= {} self.pr_branch_map ||= {} File.open(config_path, 'w') { |f| f.write(to_h.to_yaml) } end
setup()
click to toggle source
# File lib/github_flow_cli/config.rb, line 15 def setup if File.file?(config_path) load API.use_oauth_token(oauth_token) unless API.valid? puts "WARN: authentication failed, please retry login." File.delete(config_path) exit(1) end else puts "please login first." exit(2) end end
to_h()
click to toggle source
# File lib/github_flow_cli/config.rb, line 48 def to_h KEYS.map{ |k| [k, send(k)] }.to_h end
valid?()
click to toggle source
# File lib/github_flow_cli/config.rb, line 52 def valid? KEYS.all? { |c| send(c) } end