class DeployGate::Config::Base

Public Class Methods

exist?() click to toggle source

@return [Boolean]

# File lib/deploygate/config/base.rb, line 30
def exist?
  File.exist?(file_path)
end
file_path() click to toggle source
# File lib/deploygate/config/base.rb, line 5
def file_path
  # Please override this method
  raise NotImplementedError.new("You must implement #{self.class}##{__method__}")
end
read() click to toggle source

@return [Hash]

# File lib/deploygate/config/base.rb, line 22
def read
  file = File.open(file_path)
  data = file.read
  file.close
  JSON.parse(data)
end
write(config) click to toggle source

@param [Hash] config @return [void]

# File lib/deploygate/config/base.rb, line 12
def write(config)
  FileUtils.mkdir_p(File.dirname(file_path))

  data = JSON.generate(config)
  file = File.open(file_path, "w+")
  file.print data
  file.close
end