class Fluent::Format::BundlerInjection

Public Class Methods

new(opts = {}) click to toggle source
# File lib/fluent/format/check.rb, line 56
def initialize(opts = {})
  @opts = {
    :gemfile => opts[:gemfile],
    :gem_install_path => opts[:gem_install_path],
  }
end

Public Instance Methods

bundler_injection() click to toggle source
# File lib/fluent/format/check.rb, line 77
def bundler_injection
  # basically copy from lib/fluent/command/bundler_injection.rb
  system("bundle install")
  unless $?.success?
    exit $?.exitstatus
  end

  cmdline = [
    'bundle',
    'exec',
    RbConfig.ruby,
    File.expand_path(File.join(File.dirname(__FILE__), '../../../bin/fluent-format')),
  ] + ARGV

  exec *cmdline
  exit! 127
end
run() click to toggle source
# File lib/fluent/format/check.rb, line 63
def run
  # copy from lib/fluent/command/fluentd.rb
  if ENV['FLUENTD_DISABLE_BUNDLER_INJECTION'] != '1' && gemfile = @opts[:gemfile]
    ENV['BUNDLE_GEMFILE'] = gemfile
    if path = @opts[:gem_install_path]
      ENV['BUNDLE_PATH'] = path
    else
      ENV['BUNDLE_PATH'] = File.expand_path(File.join(File.dirname(gemfile), 'vendor/bundle'))
    end
    ENV['FLUENTD_DISABLE_BUNDLER_INJECTION'] = '1'
    bundler_injection
  end
end