Class: GemDock::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gem_dock/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/gem_dock/cli.rb', line 21

def exit_on_failure?
  true
end

.is_thor_reserved_word?(word, type) ⇒ Boolean

Hackery. Take the run method away from Thor so that we can redefine it. https://github.com/ddollar/foreman/issues/655#issuecomment-263188152

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/gem_dock/cli.rb', line 15

def is_thor_reserved_word?(word, type)
  return false if word == "run"

  super
end

Instance Method Details

#init(ruby_version = options[:ruby_version]) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/gem_dock/cli.rb', line 28

def init(ruby_version = options[:ruby_version])
  ruby_version = default_ruby_version if ruby_version.nil?

  create_gemdock_directory
  create_dip_yml
  create_docker_compose_yml(ruby_version: ruby_version)
  puts "GemDock initialized successfully with Ruby version #{ruby_version}!"
end

#lsObject



58
59
60
# File 'lib/gem_dock/cli.rb', line 58

def ls
  system("DIP_FILE=#{dip_file_path} dip ls")
end

#provisionObject



46
47
48
# File 'lib/gem_dock/cli.rb', line 46

def provision
  system("DIP_FILE=#{dip_file_path} dip provision")
end

#run(*commands) ⇒ Object

Parameters:

  • commands (Array)

    command and parameters to run



52
53
54
55
# File 'lib/gem_dock/cli.rb', line 52

def run(*commands)
  escaped_commands = commands.map { |cmd| Shellwords.escape(cmd) }.join(' ')
  system("DIP_FILE=#{Shellwords.escape(dip_file_path)} dip run #{escaped_commands}")
end

#update(ruby_version = options[:ruby_version]) ⇒ Object



39
40
41
42
43
# File 'lib/gem_dock/cli.rb', line 39

def update(ruby_version = options[:ruby_version])
  ruby_version = default_ruby_version if ruby_version.nil?
  create_docker_compose_yml(ruby_version: ruby_version)
  puts "docker-compose.yml updated successfully!"
end