Sha256: e5671cc83d89747a6b5348cfc16a019f55e12ec5b05afd98cbc34738361a7da2

Contents?: true

Size: 1.55 KB

Versions: 60

Compression:

Stored size: 1.55 KB

Contents

#--
# Copyright (c) 2008 Jeremy Hinegardner
# All rights reserved.  See LICENSE and/or COPYING for details.
#++
#
module Hitimes
  #
  # Access to various paths inside the project programatically
  #
  module Paths
    #   
    # :call-seq:
    #    Hitimes::Paths.root_dir -> String
    #
    # Returns The full expanded path of the parent directory of +lib+
    # going up the path from the current file.  A trailing File::SEPARATOR 
    # is guaranteed.
    #   
    def self.root_dir
      @root_dir ||=(
        path_parts = ::File.expand_path(__FILE__).split(::File::SEPARATOR)
        lib_index  = path_parts.rindex("lib")
        @root_dir = path_parts[0...lib_index].join(::File::SEPARATOR) + ::File::SEPARATOR
      )
    end 

    # 
    # :call-seq:
    #   Hitimes::Paths.lib_path( *args ) -> String
    #
    # Returns The full expanded path of the +lib+ directory below
    # _root_dir_.  All parameters passed in are joined onto the 
    # result. A trailing File::SEPARATOR is guaranteed if 
    # _args_ are *not* present.
    #   
    def self.lib_path(*args)
      self.sub_path("lib", *args)
    end 

    #
    # :call-seq:
    #   Hitimes::Paths.sub_path( sub, *args ) -> String
    #
    # Returns the full expanded path of the +sub+ directory below _root_dir.  All
    # _arg_ parameters passed in are joined onto the result.  A trailing
    # File::SEPARATOR is guaranteed if _args_ are *not* present.
    #
    def self.sub_path(sub,*args)
      sp = ::File.join(root_dir, sub) + File::SEPARATOR
      sp = ::File.join(sp, *args) if args
    end
  end
end

Version data entries

60 entries across 58 versions & 4 rubygems

Version Path
hitimes-2.0.0 lib/hitimes/paths.rb
hitimes-1.3.1-x64-mingw32 lib/hitimes/paths.rb
hitimes-1.3.1-x86-mingw32 lib/hitimes/paths.rb
hitimes-1.3.1-java lib/hitimes/paths.rb
hitimes-1.3.1 lib/hitimes/paths.rb
hitimes-1.3.0-x64-mingw32 lib/hitimes/paths.rb
hitimes-1.3.0-x86-mingw32 lib/hitimes/paths.rb
hitimes-1.3.0-java lib/hitimes/paths.rb
hitimes-1.3.0 lib/hitimes/paths.rb
hitimes-1.2.6-x86-mingw32 lib/hitimes/paths.rb
hitimes-1.2.6-java lib/hitimes/paths.rb
hitimes-1.2.6 lib/hitimes/paths.rb
hitimes-1.2.5-java lib/hitimes/paths.rb
hitimes-1.2.5-x86-mingw32 lib/hitimes/paths.rb
hitimes-1.2.5 lib/hitimes/paths.rb
hitimes-1.2.4-java lib/hitimes/paths.rb
hitimes-1.2.4-x86-mingw32 lib/hitimes/paths.rb
hitimes-1.2.4 lib/hitimes/paths.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/hitimes-1.2.2/lib/hitimes/paths.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/hitimes-1.2.2/lib/hitimes/paths.rb