middleman-deploy/lib/middleman-deploy/extension.rb

45 lines
1.0 KiB
Ruby
Raw Normal View History

2012-08-20 19:52:29 +02:00
# Require core library
2014-05-29 11:57:30 +02:00
require 'middleman-core'
2012-08-20 19:52:29 +02:00
# Extension namespace
2012-08-20 21:59:32 +02:00
module Middleman
module Deploy
2014-05-29 11:57:30 +02:00
class Options < Struct.new(:method, :host, :port, :user, :password, :path, :clean, :remote, :branch, :strategy, :build_before, :flags, :commit_message); end
2012-08-20 21:59:32 +02:00
class << self
2012-08-22 20:45:33 +02:00
def options
@@options
end
2012-08-22 23:15:37 +02:00
2014-05-29 11:57:30 +02:00
def registered(app, options_hash = {}, &block)
options = Options.new(options_hash)
yield options if block_given?
2013-08-09 01:44:03 +02:00
# Default options for the rsync method.
options.port ||= 22
options.clean ||= false
2013-08-09 01:44:03 +02:00
# Default options for the git method.
2014-05-29 11:57:30 +02:00
options.remote ||= 'origin'
options.branch ||= 'gh-pages'
options.strategy ||= :force_push
options.commit_message ||= nil
2012-08-20 21:59:32 +02:00
options.build_before ||= false
2012-08-22 20:45:33 +02:00
@@options = options
app.send :include, Helpers
2012-08-20 19:52:29 +02:00
end
2012-08-22 23:15:37 +02:00
2014-05-29 11:57:30 +02:00
alias_method :included, :registered
2012-08-20 19:52:29 +02:00
end
2012-08-22 20:45:33 +02:00
module Helpers
2012-08-22 21:37:37 +02:00
def options
::Middleman::Deploy.options
2012-08-22 20:45:33 +02:00
end
end
2012-08-20 21:59:32 +02:00
end
2012-08-20 19:52:29 +02:00
end