Class: Wip::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/wip/initializer.rb

Overview

Builds a starter wip.yml. Detects an existing compose file next to the target (the same filenames ComposeBridge auto-detects) to decide between mode: compose and mode: container, since that's the one decision wip init can't leave to a placeholder.

Constant Summary collapse

CONTAINER_TEMPLATE =
<<~YAML
  version: 1
  mode: container

  dependencies:
    app: # TODO: this is the container wip creates, execs into, and runs commands in
      image: your/image:tag # TODO: image to run
      workdir: /app # TODO: adjust to match your image, or delete this line

  sync: {} # optional; mirrors the source into a named volume instead of bind-mounting it live
YAML

Instance Method Summary collapse

Constructor Details

#initialize(dir: Dir.pwd) ⇒ Initializer

Returns a new instance of Initializer.



23
24
25
# File 'lib/wip/initializer.rb', line 23

def initialize(dir: Dir.pwd)
  @dir = dir
end

Instance Method Details

#callObject



29
30
31
# File 'lib/wip/initializer.rb', line 29

def call
  compose? ? compose_template : CONTAINER_TEMPLATE
end

#compose?Boolean

Returns:

  • (Boolean)


27
# File 'lib/wip/initializer.rb', line 27

def compose? = !!compose_file