module Dockland

Constants

VERSION

Private Class Methods

dokku_exec(command, options='') click to toggle source
# File lib/dockland.rb, line 24
def self.dokku_exec(command, options='')
  remote = parse_git_remote
  lines = `ssh -t #{remote[:username]}@#{remote[:host]} #{command} #{remote[:app_name] if is_require_app_name?(command)} #{options} 2> /dev/null`
  lines.strip
end
is_require_app_name?(command) click to toggle source
# File lib/dockland.rb, line 18
def self.is_require_app_name?(command)
  remote = parse_git_remote
  line = `ssh -t #{remote[:username]}@#{remote[:host]} help 2> /dev/null | grep '    #{command}'`
  line.include?('<app>')
end
parse_git_remote() click to toggle source
# File lib/dockland.rb, line 7
def self.parse_git_remote
  dokku_uri = `git config remote.dokku.url`.strip || `git config remote.deploy.url`.strip
  if dokku_uri.empty?
    puts "dokku url not given. please run > $ git remote add dokku dokku@<host>:<app_name>"
    exit
  end

  username, host, app_name = dokku_uri.scan(/\A(.+?)@(.+?):(.+?)\z/).first
  return { username: username, host: host, app_name: app_name }
end