Sha256: fe536e2608515fa5df9fa59a801e83bc1e4e4af324fd1405c16a5ec7e99294ea

Contents?: true

Size: 1.56 KB

Versions: 18

Compression:

Stored size: 1.56 KB

Contents

#--
# Copyright (c) 2007 Jeremy Hinegardner
# All rights reserved.  See LICENSE and/or COPYING for details.
#++
#
module Launchy
  #
  # Access to various paths inside the project programatically
  #
  module Paths
    #
    # :call-seq:
    #    Launchy::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:
    #   Launchy::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:
    #   Launchy::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

18 entries across 18 versions & 4 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/launchy-0.3.7/lib/launchy/paths.rb
launchy-0.4.0 lib/launchy/paths.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/launchy-0.3.7/lib/launchy/paths.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/launchy-0.3.7/lib/launchy/paths.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/launchy-0.3.7/lib/launchy/paths.rb
launchy-0.3.7 lib/launchy/paths.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/launchy-0.3.5/lib/launchy/paths.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/launchy-0.3.5/lib/launchy/paths.rb
launchy-0.3.5 lib/launchy/paths.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.10.17 vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.10.16 vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.10.15 vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
middleman-0.10.14 vendor/gems/gems/launchy-0.3.3/lib/launchy/paths.rb
launchy-0.3.3 lib/launchy/paths.rb