Class: Bunto::LiquidRenderer
- Inherits:
-
Object
- Object
- Bunto::LiquidRenderer
- Defined in:
- lib/bunto/liquid_renderer.rb,
lib/bunto/liquid_renderer/file.rb
Defined Under Namespace
Class Method Summary collapse
Instance Method Summary collapse
- #file(filename) ⇒ Object
- #increment_bytes(filename, bytes) ⇒ Object
- #increment_time(filename, time) ⇒ Object
-
#initialize(site) ⇒ LiquidRenderer
constructor
A new instance of LiquidRenderer.
- #reset ⇒ Object
- #stats_table(n = 50) ⇒ Object
Constructor Details
#initialize(site) ⇒ LiquidRenderer
Returns a new instance of LiquidRenderer.
6 7 8 9 10 |
# File 'lib/bunto/liquid_renderer.rb', line 6 def initialize(site) @site = site Liquid::Template.error_mode = @site.config["liquid"]["error_mode"].to_sym reset end |
Class Method Details
.format_error(e, path) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/bunto/liquid_renderer.rb', line 43 def self.format_error(e, path) if e.is_a? Tags::IncludeTagError return "#{e.} in #{e.path}, included in #{path}" end "#{e.} in #{path}" end |
Instance Method Details
#file(filename) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bunto/liquid_renderer.rb', line 16 def file(filename) filename = @site.in_source_dir(filename).sub( %r!\A#{Regexp.escape(@site.source)}/!, "" ) LiquidRenderer::File.new(self, filename).tap do @stats[filename] ||= {} @stats[filename][:count] ||= 0 @stats[filename][:count] += 1 end end |
#increment_bytes(filename, bytes) ⇒ Object
29 30 31 32 |
# File 'lib/bunto/liquid_renderer.rb', line 29 def increment_bytes(filename, bytes) @stats[filename][:bytes] ||= 0 @stats[filename][:bytes] += bytes end |
#increment_time(filename, time) ⇒ Object
34 35 36 37 |
# File 'lib/bunto/liquid_renderer.rb', line 34 def increment_time(filename, time) @stats[filename][:time] ||= 0.0 @stats[filename][:time] += time end |
#reset ⇒ Object
12 13 14 |
# File 'lib/bunto/liquid_renderer.rb', line 12 def reset @stats = {} end |
#stats_table(n = 50) ⇒ Object
39 40 41 |
# File 'lib/bunto/liquid_renderer.rb', line 39 def stats_table(n = 50) LiquidRenderer::Table.new(@stats).to_s(n) end |