Sha256: a044207e9d82cd51b6e38577b3844c1a68d3ee8f23fbf0acd325b026e849ea17

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'time'
require 'bundler'

require 'get_process_mem'

module DerailedBenchmarks
  def self.gem_is_bundled?(name)
    specs = ::Bundler.locked_gems.specs.each_with_object({}) {|spec, hash| hash[spec.name] = spec }
    specs[name]
  end

  class << self
    attr_accessor :auth
  end

  def self.rails_path_on_disk
    require 'rails/version'
    rails_version_file = Rails.method(:version).source_location[0]
    path = Pathname.new(rails_version_file).expand_path.parent.parent

    while path != Pathname.new("/")
      basename = path.expand_path.basename.to_s

      break if basename.start_with?("rails") && basename != "railties"
      path = path.parent
    end
    raise "Could not find rails folder on a folder in #{rails_version_file}"  if path == Pathname.new("/")
    path.expand_path
  end

  def self.add_auth(app)
    if use_auth = ENV['USE_AUTH']
      puts "Auth: #{use_auth}"
      auth.add_app(app)
    else
      app
    end
  end
end

require 'derailed_benchmarks/require_tree'
require 'derailed_benchmarks/auth_helper'

require 'derailed_benchmarks/stats_in_file'
require 'derailed_benchmarks/stats_from_dir'

if DerailedBenchmarks.gem_is_bundled?("devise")
  DerailedBenchmarks.auth = DerailedBenchmarks::AuthHelpers::Devise.new
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
derailed_benchmarks-1.7.0 lib/derailed_benchmarks.rb
gitlab-derailed_benchmarks-1.6.1 lib/derailed_benchmarks.rb
derailed_benchmarks-1.6.0 lib/derailed_benchmarks.rb
derailed_benchmarks-1.5.0 lib/derailed_benchmarks.rb
derailed_benchmarks-1.4.3 lib/derailed_benchmarks.rb
derailed_benchmarks-1.4.2 lib/derailed_benchmarks.rb
derailed_benchmarks-1.4.1 lib/derailed_benchmarks.rb
derailed_benchmarks-1.4.0 lib/derailed_benchmarks.rb