homebrew-core/Formula/luarocks.rb
2019-06-22 21:44:46 -04:00

62 lines
2.1 KiB
Ruby

class Luarocks < Formula
desc "Package manager for the Lua programming language"
homepage "https://luarocks.org/"
url "https://luarocks.org/releases/luarocks-3.1.3.tar.gz"
sha256 "c573435f495aac159e34eaa0a3847172a2298eb6295fcdc35d565f9f9b990513"
bottle do
cellar :any_skip_relocation
sha256 "08458e0b638f8007065b5af141ad28af3ff0962c3d60593e751d6564cb6777b6" => :mojave
sha256 "08458e0b638f8007065b5af141ad28af3ff0962c3d60593e751d6564cb6777b6" => :high_sierra
sha256 "2771ed4bb77feb1cacfb1fedcf7604482887849ff786d5fea52fa8e3a8f7264b" => :sierra
end
depends_on "lua@5.1" => :test
depends_on "lua"
def install
system "./configure", "--prefix=#{prefix}",
"--sysconfdir=#{etc}",
"--rocks-tree=#{HOMEBREW_PREFIX}"
system "make", "install"
end
def caveats; <<~EOS
LuaRocks supports multiple versions of Lua. By default it is configured
to use Lua5.3, but you can require it to use another version at runtime
with the `--lua-dir` flag, like this:
luarocks --lua-dir=#{Formula["lua@5.1"].opt_prefix} install say
EOS
end
test do
ENV["LUA_PATH"] = "#{testpath}/share/lua/5.3/?.lua"
ENV["LUA_CPATH"] = "#{testpath}/lib/lua/5.3/?.so"
(testpath/"lfs_53test.lua").write <<~EOS
require("lfs")
print(lfs.currentdir())
EOS
system "#{bin}/luarocks", "--tree=#{testpath}", "install", "luafilesystem"
system "lua", "-e", "require('lfs')"
assert_match testpath.to_s, shell_output("lua lfs_53test.lua")
ENV["LUA_PATH"] = "#{testpath}/share/lua/5.1/?.lua"
ENV["LUA_CPATH"] = "#{testpath}/lib/lua/5.1/?.so"
(testpath/"lfs_51test.lua").write <<~EOS
require("lfs")
lfs.mkdir("blank_space")
EOS
system "#{bin}/luarocks", "--tree=#{testpath}",
"--lua-dir=#{Formula["lua@5.1"].opt_prefix}",
"install", "luafilesystem"
system "lua5.1", "-e", "require('lfs')"
system "lua5.1", "lfs_51test.lua"
assert_predicate testpath/"blank_space", :directory?,
"Luafilesystem failed to create the expected directory"
end
end