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`.

"dockerfile: |-\n  RUN apk add --no-cache build-base yaml-dev openssl-dev git\n  RUN gem update --system\n  RUN gem install bundler gem_hadar\n\nscript: &script |-\n  echo -e \"\\e[1m\"\n  ruby -v\n  echo -e \"\\e[0m\"\n  bundle update\n  bundle install --jobs=$(getconf _NPROCESSORS_ONLN)\n  rake spec\n\nfail_fast: true\n\nimages:\n  ruby:3.4-alpine: *script\n  ruby:3.3-alpine: *script\n  ruby:3.2-alpine: *script\n"

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



63
64
65
# File 'lib/all_images/config.rb', line 63

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



50
51
52
53
54
# File 'lib/all_images/config.rb', line 50

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