Module: Glimmer::Config

Defined in:
lib/glimmer/config.rb

Constant Summary collapse

LOOP_MAX_COUNT_DEFAULT =
100
REGEX_METHODS_EXCLUDED =
/^(to_|\[|load_iseq)/

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.log_excluded_keywordsObject Also known as: log_excluded_keywords?

Returns the value of attribute log_excluded_keywords.



29
30
31
# File 'lib/glimmer/config.rb', line 29

def log_excluded_keywords
  @log_excluded_keywords
end

.loop_max_countObject



44
45
46
# File 'lib/glimmer/config.rb', line 44

def loop_max_count
  @loop_max_count ||= LOOP_MAX_COUNT_DEFAULT
end

Class Method Details

.excluded_keyword_checkersObject



32
33
34
# File 'lib/glimmer/config.rb', line 32

def excluded_keyword_checkers
  @excluded_keyword_checkers ||= reset_excluded_keyword_checkers!
end

.excluded_keyword_checkers=(checkers) ⇒ Object



36
37
38
# File 'lib/glimmer/config.rb', line 36

def excluded_keyword_checkers=(checkers)
  @excluded_keyword_checkers = checkers
end

.loggerObject

Returns Glimmer logger (standard Ruby logger)



49
50
51
52
# File 'lib/glimmer/config.rb', line 49

def logger
  reset_logger! unless defined? @@logger
  @@logger
end

.logger=(custom_logger) ⇒ Object



54
55
56
# File 'lib/glimmer/config.rb', line 54

def logger=(custom_logger)
  @@logger = custom_logger
end

.reset_excluded_keyword_checkers!Object



40
41
42
# File 'lib/glimmer/config.rb', line 40

def reset_excluded_keyword_checkers!
  @excluded_keyword_checkers = [ lambda { |method_symbol, *args| method_symbol.to_s.match(REGEX_METHODS_EXCLUDED) } ]
end

.reset_logger!Object



58
59
60
61
62
63
64
65
66
67
# File 'lib/glimmer/config.rb', line 58

def reset_logger!
  self.logger = Logger.new($stdout).tap do |logger|
    logger.level = Logger::ERROR
    begin
      logger.level = ENV['GLIMMER_LOGGER_LEVEL'].strip.downcase unless ENV['GLIMMER_LOGGER_LEVEL'].to_s.strip.empty?
    rescue => e
      puts e.message
    end
  end
end