Sha256: 987c07dd4c7df6d4fdc3c1f60235ae1f5544b76a9a790ca592cfdebe3c1202d6

Contents?: true

Size: 444 Bytes

Versions: 6

Compression:

Stored size: 444 Bytes

Contents

require 'json'

module Hyhyhy
  module Config
    extend self

    @filename = './.hyhyhy'
    @settings = {}

    def load(filename)
      @filename = filename
      @settings = JSON.parse(File.read(@filename))
    end

    def all
      @settings
    end

    def [](key)
      all[key]
    end

    def []=(key, value)
      all[key] = value

      File.open(@filename, 'w') { |f| f.write(JSON.pretty_generate(@settings)) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyhyhy-0.0.9 lib/hyhyhy/config.rb
hyhyhy-0.0.8 lib/hyhyhy/config.rb
hyhyhy-0.0.7 lib/hyhyhy/config.rb
hyhyhy-0.0.6 lib/hyhyhy/config.rb
hyhyhy-0.0.5 lib/hyhyhy/config.rb
hyhyhy-0.0.4 lib/hyhyhy/config.rb