Class: DokkuClient::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dokku_client/base.rb

Constant Summary collapse

GIT_DIR =
'.git'
KEYS_AND_QUESTIONS =
{
  "dokku-client.project-name"  => "Enter project name:",
  "dokku-client.project-host"  => "Enter dokku host:",
  "dokku-client.plugins"  => "Active commands (comma separated):"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.

Raises:

  • (DokkuClient::Errors::NoGitRepoFound)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dokku_client/base.rb', line 14

def initialize(options={})
  options = {}
  @options = options
  @current_dir = Dir.pwd

  raise DokkuClient::Errors::NoGitRepoFound, "No git repository found" unless git_directory_present?

  @git_dir = File.join(@current_dir, GIT_DIR)
  @options[:repository] = Grit::Repo.new(@git_dir)

  git_config_ok? ? parse_git_config : add_git_config
  run
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/dokku_client/base.rb', line 4

def options
  @options
end

Instance Method Details

#dokku(arg) ⇒ Object



42
43
44
45
# File 'lib/dokku_client/base.rb', line 42

def dokku arg
  no_argument_error if arg.nil?
  exec "ssh", "-t", "dokku@#{@options["project-host"]}", arg
end

#git_directory_present?Boolean



28
29
30
# File 'lib/dokku_client/base.rb', line 28

def git_directory_present?
  File.directory?(File.join(@current_dir, GIT_DIR))
end

#plugin_enabled(plugin) ⇒ Object



47
48
49
# File 'lib/dokku_client/base.rb', line 47

def plugin_enabled plugin
  @options["plugins"].include?(plugin) ||  @options["plugins"].include?('all')
end

#reconfigObject



35
36
37
38
39
40
# File 'lib/dokku_client/base.rb', line 35

def reconfig
  KEYS_AND_QUESTIONS.each do |key, question|
    ask_question_and_force_update_config(question, key)
  end
  config_update_success
end

#runObject



32
33
# File 'lib/dokku_client/base.rb', line 32

def run
end