# encoding: UTF-8 class Clipper < Formula desc "Share macOS clipboard with tmux and other local and remote apps" homepage "https://wincent.com/products/clipper" url "https://github.com/wincent/clipper/archive/0.4.tar.gz" sha256 "f94d898f575a974ca9658102a876b6852b58354ca445503909aeedcb3cb9964b" bottle do cellar :any_skip_relocation sha256 "8f678d622370d7f7333aeb694f682b1fc0c4bb10158cdfa979866aa0522e96b2" => :sierra sha256 "f65593291aae772f6942a1562909bfa7d07c71a6ca3ac0cd88d6a03422aa6592" => :el_capitan sha256 "ca3e71e19055a184fa4f5b3f075c443b80a5d77c0f3506d45466f69f92052765" => :yosemite end depends_on "go" => :build def install ENV["GOPATH"] = buildpath system "go", "build", "clipper.go" bin.install "clipper" end plist_options :manual => "clipper" def plist; <<-EOS.undent Label #{plist_name} RunAtLoad KeepAlive WorkingDirectory #{HOMEBREW_PREFIX} ProgramArguments #{opt_bin}/clipper EnvironmentVariables LANG en_US.UTF-8 EOS end test do TEST_DATA = "a simple string! to test clipper, with söme spéciål characters!! 🐎\n".freeze cmd = [opt_bin/"clipper", "-a", testpath/"clipper.sock", "-l", testpath/"clipper.log"].freeze ohai cmd.join " " require "open3" Open3.popen3({ "LANG" => "en_US.UTF-8" }, *cmd) do |_, _, _, clipper| sleep 0.5 # Give it a moment to launch and create its socket. begin sock = UNIXSocket.new testpath/"clipper.sock" assert_equal TEST_DATA.bytesize, sock.sendmsg(TEST_DATA) sock.close sleep 0.5 assert_equal TEST_DATA, `LANG=en_US.UTF-8 pbpaste` ensure Process.kill "TERM", clipper.pid end end end end