class Jekyll::LiquidRenderer

Public Class Methods

format_error(error, path) click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 49
def self.format_error(error, path)
  "#{error.message} in #{path}"
end
new(site) click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 13
def initialize(site)
  @site = site
  Liquid::Template.error_mode = @site.config["liquid"]["error_mode"].to_sym
  reset
end

Public Instance Methods

file(filename) click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 23
def file(filename)
  filename.match(filename_regex)
  filename =
    if Regexp.last_match(1) == theme_dir("")
      ::File.join(::File.basename(Regexp.last_match(1)), Regexp.last_match(2))
    else
      Regexp.last_match(2)
    end
  LiquidRenderer::File.new(self, filename).tap do
    @stats[filename] ||= new_profile_hash
    @stats[filename][:count] += 1
  end
end
increment_bytes(filename, bytes) click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 37
def increment_bytes(filename, bytes)
  @stats[filename][:bytes] += bytes
end
increment_time(filename, time) click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 41
def increment_time(filename, time)
  @stats[filename][:time] += time
end
measure_time() { || ... } click to toggle source
# File lib/ngage/jekyll/liquid_renderer/file.rb, line 47
def measure_time
  before = Time.now
  yield
ensure
  after = Time.now
  @renderer.increment_time(@filename, after - before)
end
reset() click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 19
def reset
  @stats = {}
end
stats_table(num_of_rows = 50) click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 45
def stats_table(num_of_rows = 50)
  LiquidRenderer::Table.new(@stats).to_s(num_of_rows)
end

Private Instance Methods

filename_regex() click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 55
def filename_regex
  @filename_regex ||= %r!\A(#{source_dir}/|#{theme_dir}/|\W*)(.*)!i
end
new_profile_hash() click to toggle source
# File lib/ngage/jekyll/liquid_renderer.rb, line 59
def new_profile_hash
  Hash.new { |hash, key| hash[key] = 0 }
end