From 142e6b9f2438ab812b1abdf434cb75a9b35399a0 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Sun, 10 Jul 2011 15:13:00 -0700 Subject: [PATCH] use build? helper --- lib/middleman/features/cache_buster.rb | 2 +- lib/middleman/features/live_reload.rb | 2 +- lib/middleman/features/minify_javascript.rb | 2 +- lib/middleman/renderers/sass.rb | 2 +- lib/middleman/server.rb | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/middleman/features/cache_buster.rb b/lib/middleman/features/cache_buster.rb index 926e0c7d..921d5220 100755 --- a/lib/middleman/features/cache_buster.rb +++ b/lib/middleman/features/cache_buster.rb @@ -16,7 +16,7 @@ module Middleman::Features::CacheBuster if File.readable?(real_path_static) http_path << "?" + File.mtime(real_path_static).strftime("%s") - elsif app.environment == :build + elsif app.build? real_path_dynamic = File.join(app.root, app.build_dir, prefix, path) http_path << "?" + File.mtime(real_path_dynamic).strftime("%s") if File.readable?(real_path_dynamic) end diff --git a/lib/middleman/features/live_reload.rb b/lib/middleman/features/live_reload.rb index 11b0b1f2..9d4a04b2 100644 --- a/lib/middleman/features/live_reload.rb +++ b/lib/middleman/features/live_reload.rb @@ -1,7 +1,7 @@ module Middleman::Features::LiveReload class << self def registered(app) - return unless Middleman::Server.environment == :development + return unless Middleman::Server.development? begin require 'livereload' diff --git a/lib/middleman/features/minify_javascript.rb b/lib/middleman/features/minify_javascript.rb index a2670a56..1b364829 100755 --- a/lib/middleman/features/minify_javascript.rb +++ b/lib/middleman/features/minify_javascript.rb @@ -2,7 +2,7 @@ module Middleman::Features::MinifyJavascript class << self def registered(app) # Only do minification on build or prod mode - return unless [:build, :production].include? app.environment + return unless app.build? || app.production? require "middleman/features/minify_javascript/rack" app.use Middleman::Rack::MinifyJavascript diff --git a/lib/middleman/renderers/sass.rb b/lib/middleman/renderers/sass.rb index 4ac42e8e..bd0eee9b 100644 --- a/lib/middleman/renderers/sass.rb +++ b/lib/middleman/renderers/sass.rb @@ -14,7 +14,7 @@ module Middleman::Renderers::Sass def sass_options return super if basename.nil? - location_of_sass_file = if Middleman::Server.environment == :build + location_of_sass_file = if Middleman::Server.build? File.join(Middleman::Server.root, Middleman::Server.build_dir) else Middleman::Server.views diff --git a/lib/middleman/server.rb b/lib/middleman/server.rb index 481ff9c4..88527c90 100644 --- a/lib/middleman/server.rb +++ b/lib/middleman/server.rb @@ -14,6 +14,7 @@ module Middleman super(option, value, &nil) end + # Convenience method to check if we're in build mode def build?; environment == :build; end end