Module: Middleman::DeployWithNotifications

Defined in:
lib/middleman-deploy-with-notifications/pkg-info.rb,
lib/middleman-deploy-with-notifications/extension.rb

Defined Under Namespace

Modules: Helpers Classes: Options

Constant Summary collapse

PACKAGE =
"middleman-deploy-with-notifications"
VERSION =
"0.0.32"

Class Method Summary collapse

Class Method Details

.optionsObject



12
13
14
# File 'lib/middleman-deploy-with-notifications/extension.rb', line 12

def options
  @@options
end

.registered(app, options_hash = {}) {|options| ... } ⇒ Object Also known as: included

Yields:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/middleman-deploy-with-notifications/extension.rb', line 16

def registered(app, options_hash={}, &block)
  options = Options.new(options_hash)
  yield options if block_given?

  options.port ||= 22
  options.clean ||= false
  options.remote ||= "origin"
  options.branch ||= "gh-pages"

  options.after_build ||= false

  options.revision        = `git rev-parse HEAD`.gsub( /\s*$/, '' ).chomp
  options.revision_short  = `git rev-parse --short HEAD`.gsub( /\s*$/, '' ).chomp
  options.deploy_user     = `git config --get github.user`.chomp
  options.github_user, options.github_project = `git remote -v | grep "/" | head -n1`.gsub( /.*:([\w_-]+)\/([\w_\.-]+).git.*/, '\1/\2' ).split( "/" )
  options.github_project.chomp!

  options.git_branch          = `git rev-parse --abbrev-ref HEAD`.gsub( /\s*/, '' ).chomp
  options.git_comment         = `git log -1 --pretty=%B`.gsub( /\s*$/, '' ).chomp

  app.after_build do |builder|
    ::Middleman::Cli::DeployWithNotifications.new.deploy if options.after_build
  end

  @@options = options

  app.send :include, Helpers
end