Class: Drydocker::Config

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

Overview

Configuration file reader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Config

Returns a new instance of Config.



22
23
24
25
26
27
28
29
30
31
# File 'lib/drydocker.rb', line 22

def initialize(params = {})
  config = Config.default_config.merge(params)
  @image = config[:image]
  @name = config[:name] || name_from_image
  @entrypoint = config[:entrypoint]
  @command = config[:command].shellescape
  @path = config[:path]
  @logger = Logger.new(STDERR)
  @logger.level = Logger::DEBUG if config[:verbose]
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



9
10
11
# File 'lib/drydocker.rb', line 9

def command
  @command
end

#entrypointObject (readonly)

Returns the value of attribute entrypoint.



9
10
11
# File 'lib/drydocker.rb', line 9

def entrypoint
  @entrypoint
end

#imageObject (readonly)

Returns the value of attribute image.



9
10
11
# File 'lib/drydocker.rb', line 9

def image
  @image
end

#loggerObject (readonly)

Returns the value of attribute logger.



9
10
11
# File 'lib/drydocker.rb', line 9

def logger
  @logger
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/drydocker.rb', line 9

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/drydocker.rb', line 9

def path
  @path
end

#verboseObject (readonly)

Returns the value of attribute verbose.



9
10
11
# File 'lib/drydocker.rb', line 9

def verbose
  @verbose
end

Class Method Details

.default_configObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/drydocker.rb', line 11

def self.default_config
  {
    name: nil,
    image: "silarsis/drydocker",
    command: "rspec spec",
    entrypoint: nil,
    path: `pwd`.strip,
    verbose: false
  }
end