module TestProf
def activate(env_var, val = nil)
equal to the provided value (if any).
Run block only if provided env var is present and
def activate(env_var, val = nil) if defined?(::Spring::Application) ::Spring.after_fork { activate!(env_var, val) { yield } } else activate!(env_var, val) { yield } end end
def activate!(env_var, val)
def activate!(env_var, val) yield if ENV[env_var] && (val.nil? || ENV[env_var] == val) end
def artifact_path(filename)
def artifact_path(filename) create_artifact_dir with_timestamps( ::File.join( config.output_dir, filename ) ) end
def asset_path(filename)
def asset_path(filename) ::File.expand_path(filename, ::File.join(::File.dirname(__FILE__), "..", "assets")) end
def config
def config @config ||= Configuration.new end
def configure
def configure yield config end
def create_artifact_dir
def create_artifact_dir FileUtils.mkdir_p(config.output_dir)[0] end
def require(gem_name, msg = nil)
Require gem and shows a custom
def require(gem_name, msg = nil) Kernel.require gem_name block_given? ? yield : true rescue LoadError log(:error, msg) if msg false end
def with_timestamps(path)
def with_timestamps(path) return path unless config.timestamps? timestamps = "-#{now.to_i}" "#{path.sub(/\.\w+$/, '')}#{timestamps}#{::File.extname(path)}" end