2011-03-10 05:11:03 +00:00
|
|
|
class Apgdiff < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Another PostgreSQL diff tool"
|
2015-01-05 11:19:22 +00:00
|
|
|
homepage "http://www.apgdiff.com/"
|
|
|
|
url "http://www.apgdiff.com/download/apgdiff-2.4-bin.zip"
|
2015-08-03 12:55:31 +00:00
|
|
|
sha256 "12d95fbb0b8188d7f90e7aaf8bdd29d0eecac26e08d6323624b5b7e3f7c7a3f7"
|
2015-01-05 11:19:22 +00:00
|
|
|
|
|
|
|
head do
|
|
|
|
url "https://github.com/fordfrog/apgdiff.git"
|
|
|
|
depends_on "ant" => :build
|
|
|
|
end
|
2010-06-11 22:30:49 +00:00
|
|
|
|
|
|
|
def install
|
2015-01-05 11:19:22 +00:00
|
|
|
jar = "apgdiff-#{version}.jar"
|
|
|
|
|
|
|
|
if build.head?
|
|
|
|
system "ant"
|
|
|
|
cd "dist" do
|
|
|
|
jar = Dir["apgdiff-*.jar"].first
|
|
|
|
mv jar, ".."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
libexec.install jar
|
|
|
|
bin.write_jar_script libexec/jar, "apgdiff"
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
sql_orig = testpath/"orig.sql"
|
|
|
|
sql_new = testpath/"new.sql"
|
|
|
|
|
|
|
|
sql_orig.write <<-EOS.undent
|
|
|
|
SET search_path = public, pg_catalog;
|
|
|
|
SET default_tablespace = '';
|
|
|
|
CREATE TABLE testtable (field1 integer);
|
|
|
|
ALTER TABLE public.testtable OWNER TO fordfrog;
|
|
|
|
EOS
|
|
|
|
|
|
|
|
sql_new.write <<-EOS.undent
|
|
|
|
SET search_path = public, pg_catalog;
|
|
|
|
SET default_tablespace = '';
|
|
|
|
CREATE TABLE testtable (field1 integer,
|
|
|
|
field2 boolean DEFAULT false NOT NULL);
|
|
|
|
ALTER TABLE public.testtable OWNER TO fordfrog;
|
|
|
|
EOS
|
|
|
|
|
|
|
|
expected = <<-EOS.undent.strip
|
|
|
|
ALTER TABLE testtable
|
|
|
|
\tADD COLUMN field2 boolean DEFAULT false NOT NULL;
|
|
|
|
EOS
|
|
|
|
|
|
|
|
result = pipe_output("#{bin}/apgdiff #{sql_orig} #{sql_new}").strip
|
|
|
|
|
|
|
|
assert_equal result, expected
|
2010-06-11 22:30:49 +00:00
|
|
|
end
|
|
|
|
end
|