Class: Sumcli::Commands::Add::Service

Inherits:
Sumcli::Command show all
Defined in:
lib/sumcli/commands/add/service.rb

Constant Summary collapse

DOCKER_FILE =
'docker-compose.yml'

Instance Method Summary collapse

Methods inherited from Sumcli::Command

#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(name, options) ⇒ Service

Returns a new instance of Service.



12
13
14
15
# File 'lib/sumcli/commands/add/service.rb', line 12

def initialize(name, options)
  @name = name
  @options = options
end

Instance Method Details

#add_postgresObject



23
24
25
26
# File 'lib/sumcli/commands/add/service.rb', line 23

def add_postgres()
  generator.inject_into_file DOCKER_FILE, 
  "  db:\n" + "    image: 'postgres:9.6.3'\n" + "    ports:\n" + "      - '5432'", after: "services:\n" 
end

#execute(input: $stdin, output: $stdout) ⇒ Object



17
18
19
20
21
# File 'lib/sumcli/commands/add/service.rb', line 17

def execute(input: $stdin, output: $stdout)
  self.send("add_#{@name}")

  output.puts @name + ' added to docker-compose'
end