From 5f5450720414e6d3f16f9b19b48c62e5608f3207 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Fri, 12 Apr 2013 19:35:46 +0200 Subject: [PATCH] Remove code duplication --- lib/jekyll/command.rb | 11 +++++++++++ lib/jekyll/commands/build.rb | 20 ++------------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/jekyll/command.rb b/lib/jekyll/command.rb index ea513e0d..ff3d5eb3 100644 --- a/lib/jekyll/command.rb +++ b/lib/jekyll/command.rb @@ -8,5 +8,16 @@ module Jekyll dirs += ['*'] end end + def self.process_site(site) + begin + site.process + rescue Jekyll::FatalException => e + puts + puts "ERROR: YOUR SITE COULD NOT BE BUILT:" + puts "------------------------------------" + puts e.message + exit(1) + end + end end end diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index 1a23e49b..2ee78d22 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -20,15 +20,7 @@ module Jekyll puts " Source: #{source}" puts " Destination: #{destination}" print " Generating... " - begin - site.process - rescue Jekyll::FatalException => e - puts - puts "ERROR: YOUR SITE COULD NOT BE BUILT:" - puts "------------------------------------" - puts e.message - exit(1) - end + self.process_site(site) puts "done." end @@ -52,15 +44,7 @@ module Jekyll dw.add_observer do |*args| t = Time.now.strftime("%Y-%m-%d %H:%M:%S") print " Regenerating: #{args.size} files at #{t} " - begin - site.process - rescue Jekyll::FatalException => e - puts - puts "ERROR: YOUR SITE COULD NOT BE BUILT:" - puts "------------------------------------" - puts e.message - exit(1) - end + self.process_site(site) puts "...done." end