module TerminalShare

Constants

VERSION

Public Class Methods

share(service, items = {}) click to toggle source
# File lib/terminal-share/share.rb, line 8
def share(service, items = {})
  raise UnavailableException unless available?

  arguments = ["-service #{service}"]
  [:text, :image, :video, :url].each do |type|
    arguments << %{-#{type} "#{items[type]}"} if items[type]
  end

  command = "terminal-share #{Shellwords.shelljoin(arguments)}"

  system command
end

Private Class Methods

available?() click to toggle source
# File lib/terminal-share/share.rb, line 23
def available?
  @available ||= `uname`.strip == 'Darwin' && `sw_vers -productVersion`.strip >= '10.8' && !`which terminal-share`.empty?
end