Sha256: 0ddfb7afa2485be318a4b8a82cfaaeb8739362f383008fe5f136fc7fd70d81bd

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

module Sprout::System

  # The concrete system for Cygwin and Mingw
  # We can't quite treat these users like
  # a typical *nix system, but we can't quite
  # treat them like Windows users either.
  #
  # One great thing about these users,
  # is that we get to use real processes,
  # rather than the broken processes that
  # windows normally offers.
  class WinNixSystem < WinSystem

    def clean_path(path)
      return nil if path.nil?
      if(path.index(' '))
        return %{'#{path}'}
      end
      return path
    end

    def win_home
      @win_home ||= ENV['HOMEDRIVE'] + ENV['HOMEPATH']
    end

    def home
      @home ||= win_nix_home
    end

    def win_nix_home
      path  = win_home.split('\\').join("/")
      return path if File.exists?(path)

      parts = path.split("/")
      path  = parts.shift().downcase + "/" + parts.join("/")
      path  = path.split(":").join("")
      "/cygdrive/" + path
    end

    private

    def mingw_home_exists? path
      File.exists?(path)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sprout-1.0.2.pre lib/sprout/system/win_nix_system.rb
sprout-1.0.1.pre lib/sprout/system/win_nix_system.rb