class MergetrainCheck::Config

Public Class Methods

new(file = DEFAULT_CONFIG_FILE) click to toggle source
# File lib/mergetrain_check/config.rb, line 80
def initialize(file = DEFAULT_CONFIG_FILE)
  if File.exist?(file)
    @config = YAML.load(File.read(file))
    @config = {} if @config.nil?
  else
    @config = {}
  end
  @tokenStorage = AuthTokenStorage.new(gitlab_host)
end

Public Instance Methods

auth_token() click to toggle source
# File lib/mergetrain_check/config.rb, line 58
def auth_token
  @tokenStorage.password
end
auth_token=(value) click to toggle source
# File lib/mergetrain_check/config.rb, line 62
def auth_token=(value)
  @tokenStorage.password = value
end
gitlab_host() click to toggle source
# File lib/mergetrain_check/config.rb, line 33
def gitlab_host
  @config[:host] || "www.gitlab.com"
end
gitlab_host=(value) click to toggle source
# File lib/mergetrain_check/config.rb, line 45
def gitlab_host=(value)
  @config[:host] = value
  @tokenStorage = AuthTokenStorage.new(value)
end
limit() click to toggle source
# File lib/mergetrain_check/config.rb, line 50
def limit
  @config[:limit] || 10
end
limit=(value) click to toggle source
# File lib/mergetrain_check/config.rb, line 54
def limit=(value)
  @config[:limit] = value
end
merge!(config_hash) click to toggle source
# File lib/mergetrain_check/config.rb, line 74
def merge!(config_hash)
  @config.merge! config_hash.reject { |k,v| k == :token }
  @tokenStorage = AuthTokenStorage.new(gitlab_host)
  @tokenStorage.password = config_hash[:token] unless config_hash[:token].nil?
end
project_id() click to toggle source
# File lib/mergetrain_check/config.rb, line 66
def project_id
  @config[:project_id]
end
project_id=(value) click to toggle source
# File lib/mergetrain_check/config.rb, line 70
def project_id=(value)
  @config[:project_id] = value
end
save!(file = DEFAULT_CONFIG_FILE) click to toggle source
# File lib/mergetrain_check/config.rb, line 90
def save!(file = DEFAULT_CONFIG_FILE)
        File.open(file, 'w') { |f| f.write(config_to_persist.to_yaml) }
  @tokenStorage.save!
end
verbose() click to toggle source
# File lib/mergetrain_check/config.rb, line 37
def verbose
  @config[:verbose]
end
verbose=(value) click to toggle source
# File lib/mergetrain_check/config.rb, line 41
def verbose=(value)
  @confing[:verbose] = value
end

Private Instance Methods

config_to_persist() click to toggle source
# File lib/mergetrain_check/config.rb, line 96
def config_to_persist
  @config.reject { |k,v| ![:project_id, :host].include?(k) }
end