diff options
| author | Alex Dunn | 2015-04-21 17:44:52 -0700 |
|---|---|---|
| committer | Xu Cheng | 2015-04-22 15:02:24 +0800 |
| commit | 4f8e418d211c55e5425d39f3de0145929697f555 (patch) | |
| tree | 902d9ad0d9e90da2fc382ef14d0254e38985bce8 /Library/Formula | |
| parent | 7912ac06458326514c81c49ac2cc991e8d88aaa6 (diff) | |
| download | homebrew-4f8e418d211c55e5425d39f3de0145929697f555.tar.bz2 | |
ejdb 1.2.6
Closes #38917.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Formula')
| -rw-r--r-- | Library/Formula/ejdb.rb | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/Library/Formula/ejdb.rb b/Library/Formula/ejdb.rb index 04a0385dc..32f0d8b72 100644 --- a/Library/Formula/ejdb.rb +++ b/Library/Formula/ejdb.rb @@ -1,16 +1,71 @@ class Ejdb < Formula homepage "http://ejdb.org" - url "https://github.com/Softmotions/ejdb/archive/v1.2.5.tar.gz" - sha256 "31bbfefed5f892be84aa7748e84ffa0f5645654d4919d2be0f0e25f3fe62638b" + url "https://github.com/Softmotions/ejdb/archive/v1.2.6.tar.gz" + sha256 "50baee93b2815c1b9c45973eda4a03e36fabd1bc6987122dd391f16e43c88a9d" + + head "https://github.com/Softmotions/ejdb.git" depends_on "cmake" => :build def install - cmake_args = std_cmake_args - %w{-DCMAKE_BUILD_TYPE=None} - cmake_args << "-DCMAKE_BUILD_TYPE=Release" mkdir "build" do - system "cmake", "..", *cmake_args - system "make install" + system "cmake", "..", *std_cmake_args + system "make", "install" end end + + test do + (testpath/"test.c").write <<-EOS.undent + #include <ejdb/ejdb.h> + + static EJDB *jb; + int main() { + jb = ejdbnew(); + if (!ejdbopen(jb, "addressbook", JBOWRITER | JBOCREAT | JBOTRUNC)) { + return 1; + } + EJCOLL *coll = ejdbcreatecoll(jb, "contacts", NULL); + + bson bsrec; + bson_oid_t oid; + + bson_init(&bsrec); + bson_append_string(&bsrec, "name", "Bruce"); + bson_append_string(&bsrec, "phone", "333-222-333"); + bson_append_int(&bsrec, "age", 58); + bson_finish(&bsrec); + + ejdbsavebson(coll, &bsrec, &oid); + bson_destroy(&bsrec); + + bson bq1; + bson_init_as_query(&bq1); + bson_append_start_object(&bq1, "name"); + bson_append_string(&bq1, "$begin", "Bru"); + bson_append_finish_object(&bq1); + bson_finish(&bq1); + + EJQ *q1 = ejdbcreatequery(jb, &bq1, NULL, 0, NULL); + + uint32_t count; + TCLIST *res = ejdbqryexecute(coll, q1, &count, 0, NULL); + + for (int i = 0; i < TCLISTNUM(res); ++i) { + void *bsdata = TCLISTVALPTR(res, i); + bson_print_raw(bsdata, 0); + } + tclistdel(res); + + ejdbquerydel(q1); + bson_destroy(&bq1); + + ejdbclose(jb); + ejdbdel(jb); + return 0; + } + EOS + system ENV.cc, "-I#{include}", "-L#{lib}", "-lejdb", + "test.c", "-o", testpath/"test" + system "./test" + end end |
