Sha256: c8a4d0efa16ab4357502ab8ace45efbad00d840a5cd3d828462d947c22dfc63e

Contents?: true

Size: 552 Bytes

Versions: 7

Compression:

Stored size: 552 Bytes

Contents

module Kernel

  # Similar to __FILE__, __DIR__ provides the directory
  # path to the current executing script.
  #
  # CREDIT: Trans

  def __DIR__(*paths)
    c = caller.first
    return nil unless c.rindex(/:\d+(:in `.*')?$/)
    file = $` # File.dirname(c)
    return nil if /\A\((.*)\)/ =~ file # eval, etc.
    #File.expand_path(File.join(File.dirname(file), paths))
    File.join(File.dirname(file), paths)
  end

  #--
  # Old defintion ...
  #
  #  def __DIR__
  #    (/^(.+)?:\d+/ =~ caller[0]) ? File.dirname($1) : nil
  #  end
  #++

end

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/kernel/__dir__.rb
facets-2.9.2 lib/core/facets/kernel/__dir__.rb
facets-2.9.2 src/core/facets/kernel/__dir__.rb
facets-2.9.1 lib/core/facets/kernel/__dir__.rb
facets-2.9.0 lib/core/facets/kernel/__dir__.rb
facets-2.9.0.pre.2 lib/core/facets/kernel/__dir__.rb
facets-2.9.0.pre.1 lib/core/facets/kernel/__dir__.rb