Force user to require the profiler themselves

This commit is contained in:
Justin Li
2014-12-04 17:48:26 -05:00
parent 8c70682d6b
commit dd455a6361
4 changed files with 7 additions and 16 deletions

View File

@@ -73,5 +73,3 @@ require 'liquid/token'
# Load all the tags of the standard library
#
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
require 'liquid/profiler'

View File

@@ -1,9 +1,12 @@
require 'liquid/profiler/hooks'
module Liquid
# Profiler enables support for profiling template rendering to help track down performance issues.
#
# To enable profiling, pass the <tt>profile: true</tt> option to <tt>Liquid::Template.parse</tt>. Then, after
# <tt>Liquid::Template#render</tt> is called, the template object makes available an instance of this
# To enable profiling, first require 'liquid/profiler'.
# Then, to profile a parse/render cycle, pass the <tt>profile: true</tt> option to <tt>Liquid::Template.parse</tt>.
# After <tt>Liquid::Template#render</tt> is called, the template object makes available an instance of this
# class via the <tt>Liquid::Template#profiler</tt> method.
#
# template = Liquid::Template.parse(template_content, profile: true)
@@ -70,16 +73,6 @@ module Liquid
end
end
def self.hooks_loaded
@hooks_loaded
end
def self.load_hooks
return if @hooks_loaded
require 'liquid/profiler/hooks'
@hooks_loaded = true
end
def self.profile_token_render(token)
if Profiler.current_profile && token.respond_to?(:render)
Profiler.current_profile.start_token(token)

View File

@@ -250,7 +250,7 @@ module Liquid
def with_profiling
if @profiling && !@options[:included]
raise "Profiler hooks not loaded, call Liquid::Profiler.load_hooks first" unless Profiler.hooks_loaded
raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Profiler)
@profiler = Profiler.new
@profiler.start

View File

@@ -5,6 +5,7 @@ require 'spy/integration'
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
require 'liquid.rb'
require 'liquid/profiler'
mode = :strict
if env_mode = ENV['LIQUID_PARSER_MODE']
@@ -12,7 +13,6 @@ if env_mode = ENV['LIQUID_PARSER_MODE']
mode = env_mode.to_sym
end
Liquid::Template.error_mode = mode
Liquid::Profiler.load_hooks
if Minitest.const_defined?('Test')
# We're on Minitest 5+. Nothing to do here.