Sha256: 6ac23ecf5bb158d766e8d33244058a309815f757d4b06de0dc5bf15a66f65071

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

require 'singleton'

class SpecConfig
  include Singleton

  def initialize
    if ENV['MONGODB_URI']
      @uri_str = ENV['MONGODB_URI']
      @uri = Mongo::URI.new(@uri_str)
    end
  end

  attr_reader :uri_str
  attr_reader :uri

  def addresses
    if @uri
      @uri.servers
    else
      ['127.0.0.1']
    end
  end

  def mri?
    !jruby?
  end

  def jruby?
    RUBY_PLATFORM =~ /\bjava\b/
  end

  def platform
    RUBY_PLATFORM
  end

  def client_debug?
    %w(1 true yes).include?(ENV['CLIENT_DEBUG'] && ENV['CLIENT_DEBUG'].downcase)
  end

  def app_tests?
    %w(1 true yes).include?(ENV['APP_TESTS'] && ENV['APP_TESTS'].downcase)
  end

  def ci?
    !!ENV['CI']
  end

  def rails_version
    v = ENV['RAILS']
    if v == ''
      v = nil
    end
    v || '6.1'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-7.0.13 spec/support/spec_config.rb