Sha256: 439f58c2a7c4b3ab6066119c50196b8b0cf2fae0f884e93c2921e283c9e122cd
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
require 'cmds' module StateMate; end module StateMate::Adapters; end # adapter to set global git config options module StateMate::Adapters::SCUtil # @api adapter # # adapter API call that reads a value from scutil. # # @param key [String] the key to read. from `man scutil`: # # Supported preferences include: # # ComputerName The user-friendly name for the system. # # LocalHostName The local (Bonjour) host name. # # HostName The name associated with hostname(1) and gethostname(3). # # @param options [Hash] unused options to conform to adapter API # # @return [String, nil] the scutil value, or `nil` if not set. # # @raise [SystemCallError] if the command failed. # def self.read key, options = {} result = Cmds "scutil --get %{key}", key: key if result.ok? result.out.chomp else if result.err.match /^#{ key }\:\ not set/ nil else result.assert end end end # ::read # @api adapter # # adapter API call that writes a value to the git global config. # # @param key [String] the key to write # @param value [String] the value to write # @param options [Hash] unused options to conform to adapter API # # @return nil # def self.write key, value, options = {} Cmds! "sudo scutil --set %{key} %{value}", key: key, value: value nil end # ::write end # SCUtil
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
state_mate-0.0.5 | lib/state_mate/adapters/scutil.rb |
state_mate-0.0.4 | lib/state_mate/adapters/scutil.rb |