Method: HookApp#link_files

Defined in:
lib/hook/hookapp.rb

Link 2 or more files/urls with bi-directional hooks.



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/hook/hookapp.rb', line 357

def link_files(args)
  target = args.pop
  target.valid_hook!
  raise "Invalid target: #{target}" unless target

  args.each do |file|
    file.valid_hook!
    raise "Invalid target: #{file}" unless file

    puts "Linking #{file} and #{target}..."
    `osascript <<'APPLESCRIPT'
      tell application "#{HOOK_APP}"
        set _mark1 to make bookmark with data "#{file}"
        set _mark2 to make bookmark with data "#{target}"
        hook _mark1 and _mark2
        return true
      end tell
    APPLESCRIPT`
  end
  "Linked #{args.length} files to #{target}"
end