Sha256: 626723630312acffd8a62fe77bf1ffce16e979020f54641e1943971f6fabfbaa

Contents?: true

Size: 498 Bytes

Versions: 10

Compression:

Stored size: 498 Bytes

Contents

module Cp8Cli
  class ConfigStore
    def initialize(path)
      @path = path
    end

    def [](key)
      data[key]
    end

    def save(key, value)
      data[key] = value
      File.new(path, "w") unless File.exists?(path)
      File.open(path, "w") { |f| f.write(data.to_yaml) }
      value
    end

    private

      attr_reader :path

      def data
        @_data ||= load_data
      end

      def load_data
        YAML.load File.read(path)
      rescue
        {}
      end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cp8_cli-6.0.1 lib/cp8_cli/config_store.rb
cp8_cli-6.0.0 lib/cp8_cli/config_store.rb
cp8_cli-5.0.0 lib/cp8_cli/config_store.rb
cp8_cli-4.2.1 lib/cp8_cli/config_store.rb
cp8_cli-4.2.0 lib/cp8_cli/config_store.rb
cp8_cli-4.1.3 lib/cp8_cli/config_store.rb
cp8_cli-4.1.2 lib/cp8_cli/config_store.rb
cp8_cli-4.1.1 lib/cp8_cli/config_store.rb
cp8_cli-4.1.0 lib/cp8_cli/config_store.rb
cp8_cli-4.0.1 lib/cp8_cli/config_store.rb