Sha256: 73b8658b4ef82205d6a3fecf4e234d3c23932c2b30cae7c4dd8e2d21ecbfd771

Contents?: true

Size: 819 Bytes

Versions: 13

Compression:

Stored size: 819 Bytes

Contents

module Berkshelf::Mixin
  # @author Jamie Winsor <reset@riotgames.com>
  module PathHelpers
    # Converts a path to a path usable for your current platform
    #
    # @param [String] path
    #
    # @return [String]
    def platform_specific_path(path)
      if RUBY_PLATFORM =~ /mswin|mingw|windows/
        system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : ""
        path         = win_slashify File.join(system_drive, path.split('/')[2..-1])
      end

      path
    end

    # Convert a unixy filepath to a windowsy filepath. Swaps forward slashes for
    # double backslashes
    #
    # @param [String] path
    #   filepath to convert
    #
    # @return [String]
    #   converted filepath
    def win_slashify(path)
      path.gsub(File::SEPARATOR, (File::ALT_SEPARATOR || '\\'))
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
berkshelf-1.4.6 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.5 lib/berkshelf/mixin/path_helpers.rb
berkshelf-2.0.0.beta lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.4 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.3 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.2 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.1 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.0 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.4.0.rc1 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.3.1 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.3.0.rc1 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.2.1 lib/berkshelf/mixin/path_helpers.rb
berkshelf-1.2.0.rc1 lib/berkshelf/mixin/path_helpers.rb