Class: DeployGate::Config::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/deploygate/config/base.rb

Direct Known Subclasses

CacheVersion, Credential

Class Method Summary collapse

Class Method Details

.exist?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/deploygate/config/base.rb', line 30

def exist?
  File.exist?(file_path)
end

.file_pathObject

Raises:

  • (NotImplementedError)


5
6
7
8
# 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

.readHash

Returns:

  • (Hash)


22
23
24
25
26
27
# 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) ⇒ void

This method returns an undefined value.

Parameters:

  • config (Hash)


12
13
14
15
16
17
18
19
# 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