re-order some callbacks

This commit is contained in:
Thomas Reynolds 2011-11-27 22:04:19 -08:00
parent 0ef8de6106
commit 9ac114406f
8 changed files with 25 additions and 31 deletions

View file

@ -168,7 +168,7 @@ module Middleman
:AccessLog => []
}
app_class = options[:app] ||= ::Middleman.server.new
app_class = options[:app] ||= ::Middleman.server.inst
opts[:app] = app_class
opts[:server] = 'thin'

View file

@ -23,9 +23,6 @@ class Middleman::Base
# Ready (all loading and parsing of extensions complete) hook
define_hook :ready
# Initialized (after initialized() runs)
define_hook :initialized
class << self
# Reset Rack setup
@ -49,7 +46,11 @@ class Middleman::Base
# @private
# @return [Middleman::Base]
def inst(&block)
@inst ||= new(&block)
@inst ||= begin
mm = new(&block)
mm.run_hook :ready
mm
end
end
# Return built Rack app
@ -243,9 +244,6 @@ class Middleman::Base
set :source_dir, File.join(root, source)
super
# Run initialized callbacks
run_hook :initialized
end
# Shared cache instance

View file

@ -23,7 +23,7 @@ module Middleman::CoreExtensions::DefaultHelpers
app.helpers Helpers
app.initialized do
app.ready do
::I18n.load_path = Dir["#{File.join(root, 'locales', '*.yml')}"]
end
end

View file

@ -40,6 +40,7 @@ module Middleman::CoreExtensions::Extensions
app.define_hook :before_configuration
app.define_hook :build_config
app.define_hook :development_config
app.extend ClassMethods
app.send :include, InstanceMethods
@ -164,8 +165,6 @@ module Middleman::CoreExtensions::Extensions
puts "== Extension: #{ext}"
end
end
run_hook :ready
end
end
end

View file

@ -11,6 +11,8 @@ module Middleman::CoreExtensions::FrontMatter
module InstanceMethods
def initialize
super
file_changed FrontMatter.matcher do |file|
frontmatter.touch_file(file)
end
@ -40,7 +42,6 @@ module Middleman::CoreExtensions::FrontMatter
{ :options => data }
end
super
end
def frontmatter

View file

@ -26,12 +26,12 @@ module Middleman::CoreExtensions::Rendering
module InstanceMethods
def initialize
super
file_changed %r{^source/} do |file|
path = File.expand_path(file, root)
cache.remove(:raw_template, path)
end
super
end
def render_template(path, locs={}, opts={})

View file

@ -11,6 +11,8 @@ module Middleman::CoreExtensions::Sitemap
module InstanceMethods
def initialize
super
file_changed do |file|
sitemap.touch_file(file)
end
@ -18,8 +20,6 @@ module Middleman::CoreExtensions::Sitemap
file_deleted do |file|
sitemap.remove_file(file)
end
super
end
def sitemap

View file

@ -3,15 +3,11 @@ module Middleman::Renderers::Haml
def registered(app)
require "haml"
app.send :include, ::Haml::Helpers
app.send :include, InstanceMethods
end
alias :included :registered
end
module InstanceMethods
def initialize
super
app.ready do
init_haml_helpers
end
end
alias :included :registered
end
end