Sha256: 2c1d441fac77af62981719c7caf7869b1303de806885e9db7aea3d743d5ae04e

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

require 'loader'
module Loader::Helpers

  extend self

  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

3 entries across 3 versions & 1 rubygems

Version Path
loader-2.2.3 lib/loader/helpers.rb
loader-2.2.2 lib/loader/helpers.rb
loader-2.2.1 lib/loader/helpers.rb