63 lines
2 KiB
Ruby
63 lines
2 KiB
Ruby
class Piknik < Formula
|
|
desc "Copy/paste anything over the network"
|
|
homepage "https://github.com/jedisct1/piknik"
|
|
url "https://github.com/jedisct1/piknik/archive/0.9.1.tar.gz"
|
|
sha256 "a682e16d937a5487eda5b0d0889ae114e228bd3c9beddd743cad40f1bad94448"
|
|
head "https://github.com/jedisct1/piknik.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
rebuild 1
|
|
sha256 "1209dc34580813c42b1075174e9f78e049f43449845c63aa3f033e761ecf0bd0" => :high_sierra
|
|
sha256 "fffe6c2329ae0840061a464162703ec7cd26649cd985d1ff4de37315059b9357" => :sierra
|
|
sha256 "40b1bdb322e89f3c955519a3156f8ab9ed7aa3833f0887f1bb1ccf6224038de8" => :el_capitan
|
|
sha256 "c1bb1b4632aca54d93490f53b9142f7f808abec1cd6761418df63f11abeb80fe" => :yosemite
|
|
end
|
|
|
|
depends_on "glide" => :build
|
|
depends_on "go" => :build
|
|
|
|
def install
|
|
ENV["GOPATH"] = buildpath
|
|
ENV["GLIDE_HOME"] = HOMEBREW_CACHE/"glide_home/#{name}"
|
|
dir = buildpath/"src/github.com/jedisct1/"
|
|
dir.install Dir["*"]
|
|
ln_s buildpath/"src", dir
|
|
cd dir do
|
|
system "glide", "install"
|
|
system "go", "build", "-o", bin/"piknik", "."
|
|
(prefix/"etc/profile.d").install "zsh.aliases" => "piknik.sh"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
def caveats; <<-EOS.undent
|
|
In order to get convenient shell aliases, put something like this in #{shell_profile}:
|
|
. #{etc}/profile.d/piknik.sh
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
conffile = testpath/"testconfig.toml"
|
|
|
|
genkeys = shell_output("#{bin}/piknik -genkeys")
|
|
lines = genkeys.lines.grep(/\s+=\s+/).map { |x| x.gsub(/\s+/, " ").gsub(/#.*/, "") }.uniq
|
|
conffile.write lines.join("\n")
|
|
pid = fork do
|
|
exec "#{bin}/piknik", "-server", "-config", conffile
|
|
end
|
|
begin
|
|
IO.popen([{}, "#{bin}/piknik", "-config", conffile, "-copy"], "w+") do |p|
|
|
p.write "test"
|
|
end
|
|
IO.popen([{}, "#{bin}/piknik", "-config", conffile, "-move"], "r") do |p|
|
|
clipboard = p.read
|
|
assert_equal clipboard, "test"
|
|
end
|
|
ensure
|
|
Process.kill("TERM", pid)
|
|
Process.wait(pid)
|
|
conffile.unlink
|
|
end
|
|
end
|
|
end
|