From f1051d8c5967a18cab1f3e07ee835e3cb223a118 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Tue, 13 Mar 2012 23:00:02 -0700 Subject: [PATCH] Load extensions even when only using middleman-core. Also, use Bundler.require when available rather than scanning gems for extensions. --- middleman-core/bin/middleman | 5 ++++- middleman-core/lib/middleman-core.rb | 14 +++++++++----- middleman/lib/middleman.rb | 3 --- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/middleman-core/bin/middleman b/middleman-core/bin/middleman index e37fd292..51e12112 100755 --- a/middleman-core/bin/middleman +++ b/middleman-core/bin/middleman @@ -46,9 +46,12 @@ rescue LoadError end end +# Automatically discover extensions in RubyGems +Middleman.load_extensions_in_path + # Change directory to the root Dir.chdir(ENV["MM_ROOT"] || Dir.pwd) do # Start the CLI Middleman::Cli::Base.start -end \ No newline at end of file +end diff --git a/middleman-core/lib/middleman-core.rb b/middleman-core/lib/middleman-core.rb index c017cf69..759a7974 100755 --- a/middleman-core/lib/middleman-core.rb +++ b/middleman-core/lib/middleman-core.rb @@ -196,12 +196,16 @@ module Middleman # # @private def load_extensions_in_path - extensions = rubygems_latest_specs.select do |spec| - spec_has_file?(spec, EXTENSION_FILE) - end + if defined?(Bundler) + Bundler.require + else + extensions = rubygems_latest_specs.select do |spec| + spec_has_file?(spec, EXTENSION_FILE) + end - extensions.each do |spec| - require spec.name + extensions.each do |spec| + require spec.name + end end end diff --git a/middleman/lib/middleman.rb b/middleman/lib/middleman.rb index 0116732c..8d795478 100644 --- a/middleman/lib/middleman.rb +++ b/middleman/lib/middleman.rb @@ -3,6 +3,3 @@ require "middleman-more" # Make the VERSION string available require "middleman-core/version" - -# Automatically discover extensions in RubyGems -Middleman.load_extensions_in_path \ No newline at end of file