split out monkey patching

This commit is contained in:
tdreyno 2009-10-08 11:04:50 -07:00
parent cf1166038a
commit 6e0f12f3a5
2 changed files with 33 additions and 4 deletions

View file

@ -0,0 +1,30 @@
# Monkey-patch to use a dynamic renderer
class Templater::Actions::File
def identical?
if exists?
return true if File.mtime(source) < File.mtime(destination)
FileUtils.identical?(source, destination)
else
false
end
end
end
class Templater::Actions::Template
def render
# The default render just requests the page over Rack and writes the response
request_path = destination.gsub(File.join(Dir.pwd, Middleman::Base.build_dir), "")
browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman::Base))
browser.get(request_path)
browser.last_response.body
end
def identical?
if File.exists?(destination)
return true if File.exists?(source) && File.mtime(source) < File.mtime(destination)
File.read(destination) == render
else
false
end
end
end

View file

@ -5,7 +5,7 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{middleman} s.name = %q{middleman}
s.version = "0.9.9" s.version = "0.9.10"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Thomas Reynolds"] s.authors = ["Thomas Reynolds"]
@ -69,12 +69,11 @@ Gem::Specification.new do |s|
"spec/relative_assets_spec.rb", "spec/relative_assets_spec.rb",
"spec/spec_helper.rb" "spec/spec_helper.rb"
] ]
s.has_rdoc = true
s.homepage = %q{http://wiki.github.com/tdreyno/middleman} s.homepage = %q{http://wiki.github.com/tdreyno/middleman}
s.rdoc_options = ["--charset=UTF-8"] s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.rubyforge_project = %q{middleman} s.rubyforge_project = %q{middleman}
s.rubygems_version = %q{1.3.1} s.rubygems_version = %q{1.3.5}
s.summary = %q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting} s.summary = %q{A static site generator utilizing Haml, Sass and providing YUI compression and cache busting}
s.test_files = [ s.test_files = [
"spec/builder_spec.rb", "spec/builder_spec.rb",
@ -87,7 +86,7 @@ Gem::Specification.new do |s|
if s.respond_to? :specification_version then if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 2 s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<templater>, [">= 0"]) s.add_runtime_dependency(%q<templater>, [">= 0"])