Sha256: 0771f8e82b370f55410b3e048ee8a364d7bc185f723211df69b11eef0db441fa

Contents?: true

Size: 453 Bytes

Versions: 3

Compression:

Stored size: 453 Bytes

Contents

require "json"

module Obst
  class Config
    def initialize(dir)
      @cfg = nil
      location = File.join(dir, '.obst.json')
      return @cfg = {} unless File.exist?(location)

      File.open(location) do |f|
        @cfg = JSON.parse(f.read)
      end
    end

    def dig(*path)
      @cfg.dig(*path)
    end

    def dig_any(*paths)
      paths.each do |path|
        v = dig(*path)
        return v if v
      end
      nil
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
obst-0.1.10 lib/obst/config.rb
obst-0.1.9 lib/obst/config.rb
obst-0.1.8 lib/obst/config.rb