TerminalImageViewer/terminalimageviewer.rb

41 lines
3 KiB
Ruby
Raw Permalink Normal View History

2020-04-09 11:57:30 +02:00
class Terminalimageviewer < Formula
desc "Display images in a terminal using block graphic characters"
homepage "https://github.com/stefanhaustein/TerminalImageViewer"
2020-07-28 04:04:58 +02:00
url "https://github.com/stefanhaustein/TerminalImageViewer/archive/v1.1.0.tar.gz"
sha256 "727ddaa048643cb0a13e23bc308415060d99d8b1853883ad339ad7b952050d61"
2020-04-09 11:57:30 +02:00
head "https://github.com/stefanhaustein/TerminalImageViewer.git"
2021-07-21 07:29:56 +02:00
uses_from_macos "curl" => :test
depends_on "gcc" => :build unless OS.linux?
2020-04-09 11:57:30 +02:00
depends_on "imagemagick"
def install
cd "src/main/cpp" do
system "make"
if OS.mac?
2021-07-21 06:58:14 +02:00
# No expermimental/filesystem.h on mac.
2021-05-22 05:14:28 +02:00
system "/usr/local/bin/g++-#{Formula["gcc"].version_suffix}", "-std=c++17",
"-Wall",
"-fpermissive",
"-fexceptions",
"-O2", "-c",
2021-05-22 05:14:28 +02:00
"-L/usr/local/opt/gcc/lib/gcc/11/",
"tiv.cpp", "-o", "tiv.o"
2021-07-21 06:58:14 +02:00
system "/usr/local/bin/g++-#{Formula["gcc"].version_suffix}", "tiv.o", "-o", "tiv",
"-L/usr/local/opt/gcc/lib/gcc/11/", "-pthread", "-s"
else
system "make"
end
2020-04-09 11:57:30 +02:00
bin.install "tiv"
end
end
test do
# Downloads a public domain test file from wikimedia commons and displays it.
2021-07-21 07:29:56 +02:00
# NOTE: Test will fail. Will fix when I get to my mac.
system "curl -o \"test.png\" https://upload.wikimedia.org/wikipedia/commons/2/24/Cornell_box.png"
assert_equal "▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
",
shell_output("#{bin}/tiv -0 -w 400 -h 400 test.png").strip
2020-04-09 11:57:30 +02:00
end
end