Class: Jekyll::LiquidRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/liquid_renderer.rb,
lib/jekyll/liquid_renderer/file.rb

Defined Under Namespace

Classes: File, Table

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ LiquidRenderer

Returns a new instance of LiquidRenderer.



6
7
8
9
# File 'lib/jekyll/liquid_renderer.rb', line 6

def initialize(site)
  @site = site
  reset
end

Instance Method Details

#file(filename) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/jekyll/liquid_renderer.rb', line 15

def file(filename)
  filename = @site.in_source_dir(filename).sub(/\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



25
26
27
28
# File 'lib/jekyll/liquid_renderer.rb', line 25

def increment_bytes(filename, bytes)
  @stats[filename][:bytes] ||= 0
  @stats[filename][:bytes] += bytes
end

#increment_time(filename, time) ⇒ Object



30
31
32
33
# File 'lib/jekyll/liquid_renderer.rb', line 30

def increment_time(filename, time)
  @stats[filename][:time] ||= 0.0
  @stats[filename][:time] += time
end

#resetObject



11
12
13
# File 'lib/jekyll/liquid_renderer.rb', line 11

def reset
  @stats = {}
end

#stats_table(n = 50) ⇒ Object



35
36
37
# File 'lib/jekyll/liquid_renderer.rb', line 35

def stats_table(n = 50)
  LiquidRenderer::Table.new(@stats).to_s(n)
end