Sha256: 482333a6429b8524777c61e32cf17c4c77e6080c8b6bda4ab6737b186441574b

Contents?: true

Size: 1.87 KB

Versions: 4

Compression:

Stored size: 1.87 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);
    run_script(R"(
p Couchbase::VERSION
)");

    run_script(R"(
B = Couchbase::Backend.new
#B.open("192.168.42.101", "Administrator", "password")
B.open("localhost", "Administrator", "password")
)");

    run_script(R"(
p B.open_bucket("default")
p B.document_increment("default", "_default._default", "foo", {:initial_value => 32, :expiration => 42})
p B.document_get("default", "_default._default", "foo")
p B.document_decrement("default", "_default._default", "foo", {:initial_value => 32, :expiration => 42})
)");

    run_script(R"(
B.close
)");

    ruby_finalize();
    return 0;
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couchbase-3.0.0.alpha.2-x86_64-linux ext/test/main.cxx
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/test/main.cxx
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/test/main.cxx
couchbase-3.0.0.alpha.2 ext/test/main.cxx