Module: AllImages::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/all_images/config.rb

Overview

Configuration handling for AllImages

Provides functionality for loading, initializing, and accessing example configuration files used by the AllImages application to define Docker image build and execution parameters.

Constant Summary collapse

EXAMPLE =

Example configuration for ‘all_images`.

<<~EOT
  dockerfile: |-
    RUN apk add --no-cache build-base yaml-dev git
    RUN gem install gem_hadar

  script: &script |-
    echo -e "\\e[1m"
    ruby -v
    bundle
    echo -e "\\e[0m"
    rake test

  images:
    ruby:3.4-alpine: *script
    ruby:3.3-alpine: *script
    ruby:3.2-alpine: *script
EOT

Instance Method Summary collapse

Instance Method Details

#exampleString

Returns the example configuration content

This method provides access to the predefined example configuration that can be used to initialize a new configuration file.

Returns:

  • (String)

    the multi-line string containing the example configuration structure and default settings



59
60
61
# File 'lib/all_images/config.rb', line 59

def example
  EXAMPLE
end

#init(filename) ⇒ Object

Initializes a configuration file with example content

Creates a new configuration file at the specified path and writes example configuration content to it. This method is typically used when no existing configuration file is found, providing a starting point for users to customize.

will be created

Parameters:

  • filename (String)

    the path where the example configuration file



46
47
48
49
50
# File 'lib/all_images/config.rb', line 46

def init(filename)
  File.open(filename, ?w) do |output|
    output.print EXAMPLE
  end
end

#load(filename) ⇒ Object

Loads and parses a YAML configuration file

Parameters:

  • filename (String)

    the path to the YAML file to load

Returns:

  • (Object)

    the parsed YAML content as a Ruby object



14
15
16
# File 'lib/all_images/config.rb', line 14

def load(filename)
  YAML.unsafe_load_file(filename)
end