Sha256: 33727fb189e7ee2e6b180bf5aff40f6bc6e0f710507c1e82b93fbb865c8c7ebf

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

module Sct
    class Config

        def self.dir
            user = ENV["SUDO_USER"] || ENV["USER"]

            if `uname -a`.match?("Darwin")
                home = "/Users"
            else
                home = "/home"
            end

            return "#{home}/#{user}/.config/sct"
        end

        def self.path
            return File.expand_path(File.join(self.dir, 'config'))
        end

        def self.exists
            return File.exists?(Config.path)
        end

        def self.get(key)
            config = self.read

            if !config.key?(key)
                return nil
            end

            return config[key]
        end

        def self.read
            if !self.exists
                return {}
            end

            contents = File.read(self.path)

            return Sct::Helpers.to_hash(contents)
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sct-0.1.6 lib/sct/config.rb
sct-0.1.5 lib/sct/config.rb
sct-0.1.4 lib/sct/config.rb