32 lines
994 B
Ruby
32 lines
994 B
Ruby
|
class Libxlsxwriter < Formula
|
||
|
desc "C library for creating Excel XLSX files"
|
||
|
homepage "https://libxlsxwriter.github.io/"
|
||
|
url "https://github.com/jmcnamara/libxlsxwriter/archive/RELEASE_0.7.4.tar.gz"
|
||
|
sha256 "4a1143e4d9532468305fe7553792ab01274febdf715175a89c7ab8296378fa14"
|
||
|
|
||
|
def install
|
||
|
system "make", "install", "INSTALL_DIR=#{prefix}", "V=1"
|
||
|
end
|
||
|
|
||
|
test do
|
||
|
(testpath/"test.c").write <<-EOS.undent
|
||
|
#include "xlsxwriter.h"
|
||
|
|
||
|
int main() {
|
||
|
lxw_workbook *workbook = workbook_new("myexcel.xlsx");
|
||
|
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||
|
int row = 0;
|
||
|
int col = 0;
|
||
|
|
||
|
worksheet_write_string(worksheet, row, col, "Hello me!", NULL);
|
||
|
|
||
|
return workbook_close(workbook);
|
||
|
}
|
||
|
EOS
|
||
|
|
||
|
system ENV.cc, "test.c", "-L#{lib}", "-I#{include}", "-lxlsxwriter", "-o", "test"
|
||
|
system "./test"
|
||
|
assert_predicate testpath/"myexcel.xlsx", :exist?, "Failed to create xlsx file"
|
||
|
end
|
||
|
end
|