class Bicho::Plugins::User

Plugin to get preferences from the user home directory .config/bicho/config.yml

Constants

DEFAULT_CONFIG_PATH

Attributes

config_path[W]

Public Class Methods

config_path() click to toggle source
# File lib/bicho/plugins/user.rb, line 17
def self.config_path
  @config_path ||= DEFAULT_CONFIG_PATH
end
new() click to toggle source
# File lib/bicho/plugins/user.rb, line 21
def initialize
  @config = {}
  @config = YAML.load_file(Bicho::Plugins::User.config_path) if File.exist?(Bicho::Plugins::User.config_path)
end

Public Instance Methods

default_site_url_hook(logger) click to toggle source
# File lib/bicho/plugins/user.rb, line 26
def default_site_url_hook(logger)
  if @config.key?('default')
    ret = @config['default']
    logger.debug "Default url set to '#{ret}'"
    ret
  else
    logger.warn 'Use .config/bicho/config.yaml to setup a default bugzilla site'
  end
end
transform_site_url_hook(url, logger) click to toggle source
# File lib/bicho/plugins/user.rb, line 36
def transform_site_url_hook(url, logger)
  if @config['aliases']&.key?(url.to_s)
    ret = @config['aliases'][url.to_s]
    logger.debug "Transformed '#{url}' to '#{ret}'"
    ret
  else
    url
  end
end