Module: StateMate::Adapters::NVRAM
- Defined in:
- lib/state_mate/adapters/nvram.rb
Class Method Summary collapse
Class Method Details
.read(key, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/state_mate/adapters/nvram.rb', line 10 def self.read key, = {} 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 |
.write(key, value, options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/state_mate/adapters/nvram.rb', line 33 def self.write key, value, = {} unless value.is_a? String raise "value must be a String, not #{ value.inspect }" end Cmds! "sudo nvram #{ key }='#{ value }'" end |