1
0

Cleanup code

This commit is contained in:
2013-12-15 00:47:11 +07:00
parent 5940fce015
commit 72089c5d4b
6 changed files with 117 additions and 116 deletions
+28
View File
@@ -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
+9
View File
@@ -0,0 +1,9 @@
module Wrappers
class Base
attr_reader :tpl
def initialize path
@tpl = File.read(path)
end
end
end
+7
View File
@@ -0,0 +1,7 @@
module Wrappers
class Mustache < Base
def render context, args = {}
::Mustache.render(tpl, args)
end
end
end