Tom Vaughan 2012-08-20 14:24:17 -07:00
parent c80787e434
commit 8b62a0a873

View file

@ -4,12 +4,15 @@ require "middleman-core"
# Extension namespace # Extension namespace
module Middleman module Middleman
module Deploy module Deploy
class Options < Struct.new(:host, :port, :user, :path); end
class << self class << self
# Called when user `activate`s your extension def registered(app, options_hash={}, &block)
def registered(app, options={}) options = Options.new(options_hash)
# Setup extension-specific config yield options if block_given?
app.set :config_variable, false
options.port ||= 22
# Include class methods # Include class methods
# app.extend ClassMethods # app.extend ClassMethods
@ -18,10 +21,21 @@ module Middleman
# app.send :include, InstanceMethods # app.send :include, InstanceMethods
app.after_configuration do app.after_configuration do
# Do something if (!options.host || !options.user || !options.path)
raise <<EOF
# config_variable is now either the default or the user's
# setting from config.rb ERROR: middleman-deploy is not setup correctly. host, user, and path
*must* be set in config.ru. For example:
activate :deploy do |deploy|
deploy.user = "tvaughan"
deploy.host = "www.example.com"
deploy.path = "/srv/www/site"
end
EOF
end
end end
end end
alias :included :registered alias :included :registered