Sha256: 6050fed000f8f55a10fe0d17b9c4446f6c01befdbd082c35576bed492edbd456

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 Bytes

Contents

require 'loader'
module Loader::Utils

  extend self

  def require(file_path)
    Kernel.require(file_path)
  rescue LoadError
    Kernel.load(file_path)
  end

  def pwd
    if !!ENV['BUNDLE_GEMFILE']
      ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator)
    elsif defined?(Rails) && Rails.respond_to?(:root) && Rails.root
      Rails.root.to_s
    else
      Dir.pwd
    end
  end

  # Based on ActiveSupport, removed inflections.
  # https://github.com/rails/rails/blob/v4.1.0.rc1/activesupport/lib/active_support/inflector/methods.rb
  def underscore(camel_cased_word)
    word = camel_cased_word.to_s.gsub('::', '/')
    word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
    word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
    word.tr!("-", "_")
    word.downcase!
    word
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loader-3.0.1 lib/loader/utils.rb
loader-3.0.0 lib/loader/utils.rb