Sha256: 0c3d993e4af034dd6ed793980bea3284a1003d6621f856e98ffa8396458ef6b3
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 KB
Contents
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2020 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <generated_config.hxx> #include <spdlog/spdlog.h> #include <ruby.h> void run_script(const char* script) { spdlog::info("run script:\n----------------------------------------{}---------------------------------------\n", script); int status = 0; rb_eval_string_protect(script, &status); if (status != 0) { VALUE rbError = rb_funcall(rb_gv_get("$!"), rb_intern("message"), 0); spdlog::critical("ruby execution failure: {}", StringValuePtr(rbError)); exit(EXIT_FAILURE); } } int main() { ruby_init(); ruby_init_loadpath(); rb_require(LIBCOUCHBASE_EXT_PATH); rb_require("json"); run_script(R"( p Couchbase::VERSION )"); run_script(R"( B = Couchbase::Backend.new B.open("localhost", "Administrator", "password") )"); run_script(R"( query = { query: "hello" } p B.document_search("beers", JSON.generate(query), {}) )"); run_script(R"( B.close )"); ruby_finalize(); return 0; }
Version data entries
4 entries across 4 versions & 1 rubygems