lib/hook/hookapp.rb
# Delete hooks between two files/urls
Delete hooks between two files/urls
Delete hooks between two files / urls
def delete_hooks(args, opts)
    urls = args.map(&:valid_hook).delete_if { |url| !url }
    output = []
    if opts[:all]
      urls.each_with_index do |url, i|
        raise "Invalid target: #{args[i]}" unless url
        output.push(delete_all_hooks(url, force: opts[:force]))
      end
      return output.join("\n")
    end
    if urls.length == 2
      source = urls[0]
      target = urls[1]
      `osascript <<'APPLESCRIPT'
        tell application "Hook"
          set _mark1 to make bookmark with data "#{source}"
          set _mark2 to make bookmark with data "#{target}"
          unhook _mark1 and _mark2
          return true
        end tell
      APPLESCRIPT`
      "Hook removed between #{source} and #{target}"
    else
      raise 'Invalid number of URLs or files specified'
    end
  end
def delete_hooks ( args , opts ) urls = args . map ( & :valid_hook ) . delete_if { | url | ! url } output = [ ] if opts [ :all ] urls . each_with_index do | url , i | raise "Invalid target: #{args[i]}" unless url output . push ( delete_all_hooks ( url , force : opts [ :force ] ) ) end return output . join ( "\n" ) end if urls . length == 2 source = urls [ 0 ] target = urls [ 1 ] ` osascript <<'APPLESCRIPT'
        tell application "Hook"
          set _mark1 to make bookmark with data " #{ source } "
          set _mark2 to make bookmark with data " #{ target } "
          unhook _mark1 and _mark2
          return true
        end tell
      APPLESCRIPT ` "Hook removed between #{source} and #{target}" else raise 'Invalid number of URLs or files specified' end end
Delete hooks between two files/urls
Delete hooks between two files / urls
args
<not_specific>
opts
<not_specific>