homebrew-core/Formula/snappystream.rb

53 lines
1.9 KiB
Ruby

class Snappystream < Formula
desc "C++ snappy stream realization (compatible with snappy)"
homepage "https://github.com/hoxnox/snappystream"
url "https://github.com/hoxnox/snappystream/archive/0.2.7.tar.gz"
sha256 "be91c6bf304732b2d2d65c7ec57b8bf3daf1748c2ee932b852fd830db328ecc7"
head "https://github.com/hoxnox/snappystream.git"
bottle do
cellar :any_skip_relocation
sha256 "db423c970fb01ab356a559e90004e0384724e29aff1522e62743bdad164a6007" => :sierra
sha256 "6ff747fb822c8078761faaf605b7c57a9ba41fa692463595d8982352ecc1ee0a" => :el_capitan
sha256 "63313c16a57a0887063bc7a16f82502ad1f1898e848bd92af51d99562aeae496" => :yosemite
end
depends_on "cmake" => :build
depends_on "snappy"
depends_on "boost" => :optional
def install
args = std_cmake_args + %w[. -DBUILD_TESTS=ON]
args << "-DWITH_BOOST_IOSTREAMS=1" if build.with? "boost"
system "cmake", *args
system "make", "all", "test", "install"
end
test do
(testpath/"testsnappystream.cxx").write <<-EOS.undent
#include <iostream>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <snappystream.hpp>
int main()
{
{ std::ofstream ofile("snappy-file.dat");
snappy::oSnappyStream osnstrm(ofile);
std::cin >> std::noskipws;
std::copy(std::istream_iterator<char>(std::cin), std::istream_iterator<char>(), std::ostream_iterator<char>(osnstrm));
}
{ std::ifstream ifile("snappy-file.dat");
snappy::iSnappyStream isnstrm(ifile);
isnstrm >> std::noskipws;
std::copy(std::istream_iterator<char>(isnstrm), std::istream_iterator<char>(), std::ostream_iterator<char>(std::cout));
}
}
EOS
system ENV.cxx, "testsnappystream.cxx", "-lsnappy", "-lsnappystream", "-o", "testsnappystream"
system "./testsnappystream < #{__FILE__} > out.dat && diff #{__FILE__} out.dat"
end
end