module Cany
Public Class Methods
create_logger()
click to toggle source
# File lib/cany.rb, line 38 def self.create_logger logger = Logger.new(STDOUT) logger.level = Logger::INFO org_formatter = Logger::Formatter.new logger.formatter = proc do |severity, datetime, progname, msg| if severity == "INFO" " #{msg}\n" else org_formatter.call severity, datetime, progname, msg end end logger end
hash_with_array_as_default()
click to toggle source
This methods creates a hash that returns an array as default value and also stores it directly inside the hash, so that the return value can be changed without additional actions. @example
hash = hash_with_array_as_default hash[:hans] << 'otto' hash[:hash] == ['otto']
# File lib/cany.rb, line 24 def self.hash_with_array_as_default {}.tap do |hash| hash.default_proc = Proc.new do |_, key| hash[key] = [] end end end
logger()
click to toggle source
@api public @return [Logger]
# File lib/cany.rb, line 34 def self.logger @logger ||= create_logger end
setup(directory='.')
click to toggle source
@raise [MissingSpecification] if no canspec is found in the directory @raise [MultipleSpecifications] if multiple canspec files are found inside
the directory
# File lib/cany.rb, line 7 def self.setup(directory='.') specs = Dir[directory + '/*.' + Specification::EXT] raise MissingSpecification.new(directory) if specs.size == 0 raise MultipleSpecifications.new(directory) if specs.size > 1 file = specs.first spec = eval File::read(file), binding, file spec.base_dir = directory spec end