Tom Vaughan 2012-08-20 14:24:17 -07:00
parent c80787e434
commit 8b62a0a873
1 changed files with 21 additions and 7 deletions

View File

@ -4,12 +4,15 @@ require "middleman-core"
# Extension namespace
module Middleman
module Deploy
class Options < Struct.new(:host, :port, :user, :path); end
class << self
# Called when user `activate`s your extension
def registered(app, options={})
# Setup extension-specific config
app.set :config_variable, false
def registered(app, options_hash={}, &block)
options = Options.new(options_hash)
yield options if block_given?
options.port ||= 22
# Include class methods
# app.extend ClassMethods
@ -18,10 +21,21 @@ module Middleman
# app.send :include, InstanceMethods
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
alias :included :registered