Sha256: d23e09742fb3dac58c3e658f6cffcbfa1f654dbca7b7d1db7c7542fff7d68aba

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

require 'singleton'

module ConfCtl
  class Settings
    include Singleton

    def initialize
      @settings = nil
    end

    def list_columns
      read_settings { |s| s['list']['columns'] }
    end

    def max_jobs
      read_settings { |s| s['nix']['maxJobs'] }
    end

    def nix_paths
      read_settings { |s| s['nix']['nixPath'] }
    end

    def core_swpin_channels
      read_settings { |s| s['swpins']['core']['channels'] }
    end

    def core_swpin_pins
      read_settings { |s| s['swpins']['core']['pins'] }
    end

    def build_generations
      read_settings { |s| s['buildGenerations'] }
    end

    def host_generations
      read_settings { |s| s['hostGenerations'] }
    end

    protected

    def read_settings
      if @settings.nil?
        nix = Nix.stateless
        @settings = nix.confctl_settings
      end

      yield(@settings)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
confctl-2.0.0 lib/confctl/settings.rb
confctl-1.0.0 lib/confctl/settings.rb