lib/semantic_logger/utils.rb in semantic_logger-4.6.1 vs lib/semantic_logger/utils.rb in semantic_logger-4.7.0
- old
+ new
@@ -1,10 +1,10 @@
module SemanticLogger
# Internal-use only utility functions for Semantic Logger.
# Not intended for public use.
module Utils
- def self.constantize_symbol(symbol, namespace = 'SemanticLogger::Appender')
+ def self.constantize_symbol(symbol, namespace = "SemanticLogger::Appender")
klass = "#{namespace}::#{camelize(symbol.to_s)}"
begin
Object.const_get(klass)
rescue NameError
raise(ArgumentError, "Could not convert symbol: #{symbol.inspect} to a class in: #{namespace}. Looking for: #{klass}")
@@ -13,12 +13,12 @@
# Borrow from Rails, when not running Rails
def self.camelize(term)
string = term.to_s
string = string.sub(/^[a-z\d]*/, &:capitalize)
- string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }
- string.gsub!('/'.freeze, '::'.freeze)
+ string.gsub!(%r{(?:_|(/))([a-z\d]*)}i) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }
+ string.gsub!("/".freeze, "::".freeze)
string
end
# Returns the visibility for an instance method
def self.method_visibility(mod, method_name)
@@ -30,11 +30,11 @@
elsif mod.protected_instance_methods.include?(method_name)
:protected
end
end
- SELF_PATTERN = File.join('lib', 'semantic_logger')
+ SELF_PATTERN = File.join("lib", "semantic_logger")
# Extract the backtrace leaving out the last few Semantic Logger lines.
def self.extract_backtrace(stack = caller)
while (first = stack.first) && first.include?(SELF_PATTERN)
stack.shift
@@ -48,13 +48,13 @@
stack.shift
end
stack
end
- GEM_ROOT = File.expand_path('../../..', __dir__) + '/'
+ GEM_ROOT = File.expand_path("../../..", __dir__) + "/"
def self.system_path?(path)
path.start_with?(GEM_ROOT) ||
- path.start_with?(RbConfig::CONFIG['rubylibdir'])
+ path.start_with?(RbConfig::CONFIG["rubylibdir"])
end
end
end