Class: Infrastructure::Settings

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

Overview

upload and download settings

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: Infrastructure.config, formatters: Infrastructure::Formatters) ⇒ Settings

Returns a new instance of Settings.



23
24
25
26
27
# File 'lib/infrastructure/settings.rb', line 23

def initialize(config: Infrastructure.config, formatters: Infrastructure::Formatters)
  @config = config
  @loader = Loaders.build(config)
  @formatters = formatters
end

Class Method Details

.delete(*attr) ⇒ Object



18
19
20
# File 'lib/infrastructure/settings.rb', line 18

def delete(*attr)
  new.delete(*attr)
end

.pull(*attr) ⇒ Object



14
15
16
# File 'lib/infrastructure/settings.rb', line 14

def pull(*attr)
  new.pull(*attr)
end

.push(*attr) ⇒ Object



10
11
12
# File 'lib/infrastructure/settings.rb', line 10

def push(*attr)
  new.push(*attr)
end

Instance Method Details

#delete(name:) ⇒ Object



40
41
42
# File 'lib/infrastructure/settings.rb', line 40

def delete(name:)
  loader.delete(from: config.location, name: name)
end

#pull(name:, dir:) ⇒ Object



36
37
38
# File 'lib/infrastructure/settings.rb', line 36

def pull(name:, dir:)
  loader.pull(from: config.location, to: dir, name: name)
end

#push(name:, settings:, formats: %i[bash])) ⇒ Object



29
30
31
32
33
34
# File 'lib/infrastructure/settings.rb', line 29

def push(name:, settings:, formats: %i[bash])
  formats.each do |format|
    content = formatters.build(format).format(settings)
    loader.push(to: config.location, name: "#{name}/#{name}.#{format}", content: content)
  end
end