Sha256: 9252a35c83cb5d8d010c9b5a81fa5aebb813026764489e0c702e82cf77f5dc7a
Contents?: true
Size: 843 Bytes
Versions: 9
Compression:
Stored size: 843 Bytes
Contents
require 'cmds' require 'nrser' require 'state_mate' using NRSER module StateMate::Adapters::NVRAM include StateMate::Adapters register 'nvram' def self.read key, options = {} result = Cmds "nvram %{key}", key: key if result.error? if result.err.start_with? "nvram: Error getting variable" return nil end result.assert end if m = /^#{ key }\t(.*)\n$/.match(result.out) m[1] else raise binding.erb <<-BLOCK can't parse output for key <%= key.inspect %>: cmd: <%= result.cmd %> output: <%= result.out.inspect %> BLOCK end end def self.write key, value, options = {} unless value.is_a? String raise "value must be a String, not #{ value.inspect }" end Cmds! "sudo nvram #{ key }='#{ value }'" end end # NVRAM
Version data entries
9 entries across 9 versions & 1 rubygems