Module: CodeReviewLeaderboard::Config

Extended by:
Config
Includes:
ActiveSupport::Configurable
Included in:
Config
Defined in:
lib/code_review_leaderboard/config.rb

Instance Method Summary collapse

Instance Method Details

#initialize!Object



20
21
22
23
# File 'lib/code_review_leaderboard/config.rb', line 20

def initialize!
  initialize_from_args!
  initialize_from_env!
end

#initialize_from_args!Object



25
26
27
28
29
30
31
32
# File 'lib/code_review_leaderboard/config.rb', line 25

def initialize_from_args!
  options = ArgumentParser.parse!

  self.access_token = options[:access_token]
  self.organization = options[:organization]
  self.repositories = options[:repositories] if options[:repositories].present?
  self.log_level = options[:log_level]
end

#initialize_from_env!Object



34
35
36
37
38
39
# File 'lib/code_review_leaderboard/config.rb', line 34

def initialize_from_env!
  self.access_token ||= ENV["ACCESS_TOKEN"]
  self.organization ||= ENV["ORGANIZATION"]
  self.repositories = repositories.presence || ENV["REPOSITORY"].to_s.split(",")
  self.log_level ||= ENV["LOG_LEVEL"]
end