Cleanup code
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
$:.unshift File.dirname(__FILE__)
|
||||
|
||||
require 'rubygems'
|
||||
require 'bundler/setup'
|
||||
require 'benchmark'
|
||||
require 'yaml'
|
||||
require 'ostruct'
|
||||
|
||||
require 'erubis'
|
||||
require 'haml'
|
||||
require 'slim'
|
||||
require 'liquid'
|
||||
require 'mustache'
|
||||
require 'tilt/erb'
|
||||
require 'tilt/erubis'
|
||||
require 'tilt/haml'
|
||||
require 'tilt/liquid'
|
||||
|
||||
require 'workbench/benchmark'
|
||||
require 'workbench/wrappers/base'
|
||||
require 'workbench/wrappers/mustache'
|
||||
@@ -0,0 +1,28 @@
|
||||
module Workbench
|
||||
class Benchmark
|
||||
class << self
|
||||
def describe_engines engines
|
||||
@@engines = engines
|
||||
end
|
||||
end
|
||||
|
||||
TERMINAL_WIDTH = 60
|
||||
BM_WIDTH = 46
|
||||
|
||||
def initialize args, &block
|
||||
puts '#' * TERMINAL_WIDTH
|
||||
puts '##' + args[:title].center(TERMINAL_WIDTH - 4) + '##'
|
||||
puts '#' * TERMINAL_WIDTH
|
||||
|
||||
::Benchmark.bm(TERMINAL_WIDTH - BM_WIDTH) do |benchmark|
|
||||
@@engines.each do |name, attrs|
|
||||
benchmark.report(name) do
|
||||
args[:loops].times{ yield(name, attrs) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module Wrappers
|
||||
class Base
|
||||
attr_reader :tpl
|
||||
|
||||
def initialize path
|
||||
@tpl = File.read(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
module Wrappers
|
||||
class Mustache < Base
|
||||
def render context, args = {}
|
||||
::Mustache.render(tpl, args)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user