class Desktop::CLI

Public Instance Methods

set(path, already_failed = false) click to toggle source
# File lib/desktop/cli.rb, line 21
def set(path, already_failed = false)
  osx = OSX.new(options)
  image = HTTP.uri?(path) ? WebImage.new(path) : LocalImage.new(path)

  begin
    osx.desktop_image = image
  rescue OSX::DesktopImagePermissionsError => e
    fail_with_permissions_error if already_failed

    print_permissions_message
    osx.update_desktop_image_permissions
    puts
    set path, true
  rescue OSX::DesktopImageMissingError
    fail_with_missing_image_error image
  end
end
version() click to toggle source
# File lib/desktop/cli.rb, line 40
def version
  puts Desktop::VERSION
end

Private Instance Methods

fail_with_missing_image_error(image) click to toggle source
# File lib/desktop/cli.rb, line 56
def fail_with_missing_image_error(image)
  puts "Sorry, but it looks like the image you provided does not exist:"
  puts
  puts image.path
  puts
  print_issues_message
  abort
end
fail_with_permissions_error() click to toggle source
# File lib/desktop/cli.rb, line 46
def fail_with_permissions_error
  print "Sorry, but I was unable to change your desktop image. "
  puts  "The permissions are still incorrect."
  puts
  puts  "Did you type your password incorrectly?"
  puts
  print_issues_message
  abort
end
print_issues_message() click to toggle source
print_permissions_message() click to toggle source