module TypedRb
Constants
- VERSION
Public Instance Methods
dynamic_warnings()
click to toggle source
# File lib/typed.rb, line 112 def dynamic_warnings @dynamic_warnings ||= {} end
log(client_binding, level, message)
click to toggle source
# File lib/typed.rb, line 122 def log(client_binding, level, message) client = client_binding.receiver client_id = if client.instance_of?(Class) if client.name client.name else Class.for_name(client.to_s.match(/Class:(.*)>/)[1]).name end else if client.class.name client.class.name else Class.for_name(client.class.to_s.match(/Class:(.*)>/)[1]).name end end line = client_binding.eval('__LINE__') file = client_binding.eval('__FILE__') message = "#{file}:#{line}\n #{message}\n" logger('[' + client_id.gsub('::', '/') + ']').send(level, message) end
log_dynamic_warning(node, owner, name)
click to toggle source
# File lib/typed.rb, line 143 def log_dynamic_warning(node, owner, name) if options[:dynamic_warnings] error = TypeCheckError.new("Error type checking function #{owner}##{name}: Cannot find function type information for owner.", node) print '.'.yellow register_dynamic_warning(error) end end
logger(client)
click to toggle source
# File lib/typed.rb, line 151 def logger(client) logger = Log4r::Logger[client] logger = Log4r::Logger.new(client) if logger.nil? logger.outputters = Log4r::Outputter.stdout set_level(logger) logger end
options()
click to toggle source
# File lib/typed.rb, line 104 def options @options || {} end
options=(options)
click to toggle source
# File lib/typed.rb, line 108 def options=(options) @options = options end
register_dynamic_warning(warning)
click to toggle source
# File lib/typed.rb, line 116 def register_dynamic_warning(warning) file_warnings = dynamic_warnings[$TYPECHECK_FILE] || [] file_warnings << warning dynamic_warnings[$TYPECHECK_FILE] = file_warnings end
set_level(logger)
click to toggle source
# File lib/typed.rb, line 159 def set_level(logger) logger.level = case (ENV['LOG_LEVEL'] || ENV['log_level'] || '').upcase when 'DEBUG' Log4r::DEBUG when 'INFO' Log4r::INFO when 'WARN' Log4r::WARN when 'ERROR' Log4r::ERROR when 'FATAL' Log4r::FATAL else Log4r::INFO end end