Method: HookApp#delete_all_hooks

Defined in:
lib/hook/hookapp.rb

#delete_all_hooks(url, force: false) ⇒ Object

Delete all hooked files/urls from target file



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/hook/hookapp.rb', line 403

def delete_all_hooks(url, force: false)
  unless force
    STDERR.print "Are you sure you want to delete ALL hooks from #{url} (y/N)? "
    res = STDIN.gets.strip
  end

  if res =~ /^y/i || force
    get_hooks(url).each do |hook|
      `osascript <<'APPLESCRIPT'
        tell application "#{HOOK_APP}"
          set _mark1 to make bookmark with data "#{hook[:url]}"
          set _mark2 to make bookmark with data "#{url}"
          unhook _mark1 and _mark2
          return true
        end tell
      APPLESCRIPT`
    end
    "Removed all hooks from #{url}"
  end
end