Sha256: 2bb59ee04c2c0e04ca78e664637833b985d5cf2fe240ca7eeb62d0c68074a93d

Contents?: true

Size: 801 Bytes

Versions: 42

Compression:

Stored size: 801 Bytes

Contents

module DeployGate
  module Config
    class Base
      class << self
        def file_path
          # Please override this method
          raise NotImplementedError.new("You must implement #{self.class}##{__method__}")
        end

        # @param [Hash] config
        # @return [void]
        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

        # @return [Hash]
        def read
          file = File.open(file_path)
          data = file.read
          file.close
          JSON.parse(data)
        end

        # @return [Boolean]
        def exist?
          File.exist?(file_path)
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
deploygate-0.0.5 lib/deploygate/config/base.rb
deploygate-0.0.4 lib/deploygate/config/base.rb