Sha256: 578b30b5cfb3cf10fb8bd3c8e24416809350e19fadc1e2b18708a52c83b41803

Contents?: true

Size: 426 Bytes

Versions: 2

Compression:

Stored size: 426 Bytes

Contents

module PWD

  require 'pwd/version'
  require 'pwd/core_ext'

  extend self

  def pwd

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

  end

  def join(*path_parts)
    File.join(pwd,*path_parts)
  end

  def rails_present?
    !!(defined?(Rails) && !Rails.root.nil?)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pwd-1.2.1 lib/pwd.rb
pwd-1.2.0 lib/pwd.rb