class Redmine::Commands::List

Public Instance Methods

execute() click to toggle source
# File lib/redmine/commands/list.rb, line 16
def execute
  Redmine::Commands::ListPrinter.new.print(results)
end
results() click to toggle source
# File lib/redmine/commands/list.rb, line 12
def results
  parse(Redmine::Utils::System.new.execute_and_return('docker ps'))
end

Private Instance Methods

parse(docker_ps_output) click to toggle source
# File lib/redmine/commands/list.rb, line 22
def parse(docker_ps_output)
  results = docker_ps_output.split("\n")[1..-1].map do |line|
    process_line(line)
  end
  results.select { |result| result.name =~ /^redmine-run__/ }
end
process_line(line) click to toggle source
# File lib/redmine/commands/list.rb, line 29
def process_line(line)
  line_tokens = line.split(/\s{2,}/)
  OpenStruct.new(
    container_id: line_tokens[0],
    image: line_tokens[1],
    command: line_tokens[2],
    created: line_tokens[3],
    status: line_tokens[4],
    ports: line_tokens[5],
    name: line_tokens[6]
  )
end