Class: Docker::Rails::Config

Inherits:
Dry::Config::Base
  • Object
show all
Defined in:
lib/docker/rails/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config



5
6
7
8
9
10
11
12
13
# File 'lib/docker/rails/config.rb', line 5

def initialize(options = {})
  super({
            default_configuration: {
                verbose: false

            },
            prune: [:development, :test, :parallel_tests, :staging, :production]
        }.merge(options))
end

Instance Method Details

#load!(environment, *filenames) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/docker/rails/config.rb', line 15

def load!(environment, *filenames)

  # reject nil target environments
  raise 'Target environment unspecified.' if environment.nil?

  # default the filename if unspecified
  if filenames.empty?
    puts 'Using docker-rails.yml'
    filenames = ['docker-rails.yml']
  end

  # reject unknown target environments
  config = load_unpruned(environment, *filenames)
  raise "Unknown target environment '#{environment.to_sym}'" if config[environment.to_sym].nil?

  # finally, load the config as internal state
  super(environment, *filenames)
end

#to_yaml(config = @configuration) ⇒ Object



38
39
40
41
42
# File 'lib/docker/rails/config.rb', line 38

def to_yaml(config = @configuration)
  yaml = super(config)
  yaml = yaml.gsub(/command: .$/, 'command: >')
  yaml
end

#write_docker_compose_file(output_filename = 'docker-compose.yml') ⇒ Object



34
35
36
# File 'lib/docker/rails/config.rb', line 34

def write_docker_compose_file(output_filename = 'docker-compose.yml')
  write_yaml_file(output_filename, self[:'compose'])
end