allow extensions to pass version checks
This commit is contained in:
parent
066cc7bcb2
commit
41d5337f5b
2
Rakefile
2
Rakefile
|
@ -7,8 +7,6 @@ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
||||||
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
||||||
end
|
end
|
||||||
|
|
||||||
#$LOAD_PATH.unshift 'lib'
|
|
||||||
|
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
require 'rake/clean'
|
require 'rake/clean'
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,27 @@ module Middleman::CoreExtensions::Extensions
|
||||||
@_registered ||= {}
|
@_registered ||= {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def register(name, namespace=nil, &block)
|
def register(name, namespace=nil, version=nil, &block)
|
||||||
registered[name.to_sym] = if block_given?
|
# If we've already got a matching extension that passed the
|
||||||
|
# version check, bail out.
|
||||||
|
return if registered.has_key?(name.to_sym) &&
|
||||||
|
!registered[name.to_sym].is_a?(String)
|
||||||
|
|
||||||
|
if block_given?
|
||||||
|
version = namespace
|
||||||
|
end
|
||||||
|
|
||||||
|
passed_version_check = true
|
||||||
|
if !version.nil?
|
||||||
|
requirement = ::Gem::Requirement.create(version)
|
||||||
|
if !requirement.satisfied_by?(Middleman::GEM_VERSION)
|
||||||
|
passed_version_check = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
registered[name.to_sym] = if !passed_version_check
|
||||||
|
"== #{name} failed version check. Requested #{version}, got #{Middleman::VERSION}"
|
||||||
|
elsif block_given?
|
||||||
block
|
block
|
||||||
elsif namespace
|
elsif namespace
|
||||||
namespace
|
namespace
|
||||||
|
@ -64,7 +83,7 @@ module Middleman::CoreExtensions::Extensions
|
||||||
|
|
||||||
extension = registered[name]
|
extension = registered[name]
|
||||||
if extension.is_a?(Proc)
|
if extension.is_a?(Proc)
|
||||||
extension = extension.call(Middleman::VERSION) || nil
|
extension = extension.call() || nil
|
||||||
registered[name] = extension
|
registered[name] = extension
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,6 +121,8 @@ module Middleman::CoreExtensions::Extensions
|
||||||
|
|
||||||
if ext.nil?
|
if ext.nil?
|
||||||
puts "== Unknown Extension: #{feature}"
|
puts "== Unknown Extension: #{feature}"
|
||||||
|
elsif ext.is_a?(String)
|
||||||
|
puts ext
|
||||||
else
|
else
|
||||||
puts "== Activating: #{feature}" if logging?
|
puts "== Activating: #{feature}" if logging?
|
||||||
self.class.register(ext)
|
self.class.register(ext)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
VERSION = "3.0.0.alpha.3"
|
VERSION = "3.0.0.alpha.3"
|
||||||
|
GEM_VERSION = ::Gem::Version.create(VERSION)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue