diff options
author | Alexander Borisov <alexander.borisov@nginx.com> | 2018-07-10 15:43:59 +0300 |
---|---|---|
committer | Alexander Borisov <alexander.borisov@nginx.com> | 2018-07-10 15:43:59 +0300 |
commit | a27e76779feedddee663320062b1331ca0b94e3b (patch) | |
tree | 1bd746bbae45c45686e802072e93c345e5e4019e /src/ruby | |
parent | 1abdcfb2d85a04b27ac4fc52619b63917b980839 (diff) | |
download | unit-a27e76779feedddee663320062b1331ca0b94e3b.tar.gz unit-a27e76779feedddee663320062b1331ca0b94e3b.tar.bz2 |
Ruby: added "require('bundler/setup')".
This closes #93 PR on GitHub.
Diffstat (limited to '')
-rw-r--r-- | src/ruby/nxt_ruby.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ruby/nxt_ruby.c b/src/ruby/nxt_ruby.c index e9fa01c8..ea05b133 100644 --- a/src/ruby/nxt_ruby.c +++ b/src/ruby/nxt_ruby.c @@ -31,6 +31,7 @@ static nxt_int_t nxt_ruby_init_io(nxt_task_t *task); static VALUE nxt_ruby_rack_init(nxt_ruby_rack_init_t *rack_init); static VALUE nxt_ruby_require_rubygems(VALUE arg); +static VALUE nxt_ruby_bundler_setup(VALUE arg); static VALUE nxt_ruby_require_rack(VALUE arg); static VALUE nxt_ruby_rack_parse_script(VALUE ctx); static VALUE nxt_ruby_rack_env_create(VALUE arg); @@ -196,7 +197,7 @@ static VALUE nxt_ruby_rack_init(nxt_ruby_rack_init_t *rack_init) { int state; - VALUE rack, rackup; + VALUE rack, rackup, err; rb_protect(nxt_ruby_require_rubygems, Qnil, &state); if (nxt_slow_path(state != 0)) { @@ -205,6 +206,19 @@ nxt_ruby_rack_init(nxt_ruby_rack_init_t *rack_init) return Qnil; } + rb_protect(nxt_ruby_bundler_setup, Qnil, &state); + if (state != 0) { + err = rb_errinfo(); + + if (rb_obj_is_kind_of(err, rb_eLoadError) == Qfalse) { + nxt_ruby_exception_log(rack_init->task, NXT_LOG_ALERT, + "Failed to require 'bundler/setup' package"); + return Qnil; + } + + rb_set_errinfo(Qnil); + } + rb_protect(nxt_ruby_require_rack, Qnil, &state); if (nxt_slow_path(state != 0)) { nxt_ruby_exception_log(rack_init->task, NXT_LOG_ALERT, @@ -241,6 +255,14 @@ nxt_ruby_require_rubygems(VALUE arg) static VALUE +nxt_ruby_bundler_setup(VALUE arg) +{ + return rb_funcall(rb_cObject, rb_intern("require"), 1, + rb_str_new2("bundler/setup")); +} + + +static VALUE nxt_ruby_require_rack(VALUE arg) { return rb_funcall(rb_cObject, rb_intern("require"), 1, rb_str_new2("rack")); |