Class: DokkuClient::Base
- Inherits:
-
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.
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
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/dokku_client/base.rb', line 4
def options
@options
end
|
Instance Method Details
#common_description(name, opts) ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/dokku_client/base.rb', line 51
def common_description name, opts
if plugin_enabled(name)
opts.separator "\n #{name.capitalize} commands:"
opts.separator " #{name}:create create a #{name} container"
opts.separator " #{name}:delete delete #{name} container"
opts.separator " #{name}:info display container informations"
opts.separator " #{name}:link <container> link an app to a #{name} container"
opts.separator " #{name}:logs display last logs from #{name} container"
end
end
|
#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
|
#reconfig ⇒ Object
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
|
#run ⇒ Object
32
33
|
# File 'lib/dokku_client/base.rb', line 32
def run
end
|