Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 23 lines (20 sloc) 0.664 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
action :write do
  execute "#{new_resource.description} - #{new_resource.domain} - #{new_resource.key}" do
    command "defaults write #{new_resource.domain} #{new_resource.key} #{type_flag} #{value}"
    user WS_USER
    not_if "defaults read #{new_resource.domain} #{new_resource.key} | grep ^#{value}$"
  end
end

def type_flag
  return '-int' if new_resource.integer
  return '-string' if new_resource.string
  return '-float' if new_resource.float
  return '-boolean' unless new_resource.boolean.nil?
  ''
end

def value
  new_resource.integer ||
    new_resource.string ||
    (new_resource.float && new_resource.float.to_f) ||
    new_resource.boolean
end
Something went wrong with that request. Please try again.