Method: HookApp#clone_hooks

Defined in:
lib/hook/hookapp.rb

#clone_hooks(args) ⇒ Object

Copy all hooks from source file to target file



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/hook/hookapp.rb', line 380

def clone_hooks(args)
  target = args.pop.valid_hook
  source = args[0].valid_hook

  if target && source
    hooks = get_hooks(source)
    hooks.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 "#{target}"
          hook _mark1 and _mark2
          return true
        end tell
      APPLESCRIPT`
    end
    "Hooks from #{source} cloned to #{target}"
  else
    raise 'Invalid file specified'
  end
end