From b2153db79fde47d1c41236525a8b8f4e3bde1aa9 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sat, 20 Aug 2011 17:52:05 -0700 Subject: [PATCH] extract livereload into gem --- CHANGELOG | 4 ++++ lib/middleman/guard.rb | 45 ++++++++++++++++++++-------------------- lib/middleman/version.rb | 2 +- middleman.gemspec | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0b726427..f846e768 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +2.0.6 +===== +- Pulled out livereload feature into its own extension, still installed by default. + 2.0.5 ===== - Vendored Padrino 0.10.0 diff --git a/lib/middleman/guard.rb b/lib/middleman/guard.rb index eede5603..59810dc3 100644 --- a/lib/middleman/guard.rb +++ b/lib/middleman/guard.rb @@ -1,6 +1,5 @@ require "guard" require "guard/guard" -require "guard/livereload" require "rbconfig" if Config::CONFIG['host_os'].downcase =~ %r{mswin|mingw} @@ -8,34 +7,34 @@ if Config::CONFIG['host_os'].downcase =~ %r{mswin|mingw} require 'win32console' end -module Middleman::Guard - def self.start(options={}, livereload={}) - options_hash = "" - options.each do |k,v| - options_hash << ", :#{k} => '#{v}'" +module Middleman + module Guard + def self.add_guard(&block) + @additional_guards ||= [] + @additional_guards << block end - - guardfile_contents = %Q{ - guard 'middleman'#{options_hash} do - watch("config.rb") - watch(%r{^lib/^[^\.](.*)\.rb$}) + + def self.start(options={}, livereload={}) + options_hash = "" + options.each do |k,v| + options_hash << ", :#{k} => '#{v}'" end - } - if livereload - livereload_options_hash = "" - livereload.each do |k,v| - livereload_options_hash << ", :#{k} => '#{v}'" - end - - guardfile_contents << %Q{ - guard 'livereload'#{livereload_options_hash} do - watch(%r{^source/([^\.].*)$}) + guardfile_contents = %Q{ + guard 'middleman'#{options_hash} do + watch("config.rb") + watch(%r{^lib/^[^\.](.*)\.rb$}) end } - end - ::Guard.start({ :guardfile_contents => guardfile_contents }) + (@additional_guards || []).each do |block| + result = block.call(options, livereload) + guardfile_contents << result unless result.nil? + end + + $stderr.puts guardfile_contents + ::Guard.start({ :guardfile_contents => guardfile_contents }) + end end end diff --git a/lib/middleman/version.rb b/lib/middleman/version.rb index ec829b21..2a9c6105 100644 --- a/lib/middleman/version.rb +++ b/lib/middleman/version.rb @@ -1,3 +1,3 @@ module Middleman - VERSION = "2.0.5" + VERSION = "2.0.6" end diff --git a/middleman.gemspec b/middleman.gemspec index 472c94ad..704cc3f0 100644 --- a/middleman.gemspec +++ b/middleman.gemspec @@ -69,7 +69,7 @@ eos end s.add_runtime_dependency("guard", ["~> 0.6.2"]) - s.add_runtime_dependency("guard-livereload", ["~> 0.3.0"]) + s.add_runtime_dependency("middleman-livereload", ["~> 0.2.0"]) s.add_development_dependency("coffee-filter", ["~> 0.1.1"]) s.add_development_dependency("cucumber", ["~> 1.0.2"]) s.add_development_dependency("rake", ["0.8.7"])