class WhatsupGithub::Config

Creates readable objects from confirurarion files

Attributes

config[R]

Public Class Methods

new() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 13
def initialize
  @file = '.whatsup.yml'
  @config = {}
end

Public Instance Methods

base_branch() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 33
def base_branch
  read['base_branch']
end
labels() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 41
def labels
  required_labels + optional_labels
end
magic_word() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 63
def magic_word
  read['magic_word']
end
membership() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 59
def membership
  read['membership']
end
optional_labels() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 52
def optional_labels
  res = read.dig 'labels', 'optional'
  return [] unless res

  res
end
output_format() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 37
def output_format
  read['output_format']
end
read() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 18
def read
  unless File.exist?(@file)
    dist_file = File.expand_path("../template/#{@file}", __dir__)
    FileUtils.cp dist_file, @file
  end
  @config = YAML.load_file @file
  return {} unless @config

  @config
end
repos() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 29
def repos
  read['repos']
end
required_labels() click to toggle source
# File lib/whatsup_github/config_reader.rb, line 45
def required_labels
  res = read.dig 'labels', 'required'
  return [] unless res

  res
end