Sha256: 0d969b1a86c8912ec98b43fbec1f3f108fea53459061720fcdde7930f2a5f418

Contents?: true

Size: 1.57 KB

Versions: 34

Compression:

Stored size: 1.57 KB

Contents

module Sprout::System

  # The default Windows system.
  # This is the system type for all
  # major versions and flavors of Windows
  # (except Cygwin and Mingw).
  class WinSystem < BaseSystem
    LOCAL_SETTINGS = "Local\ Settings"
    APPLICATION_DATA = "Application\ Data"

    def home
      path = super
      if(path.include? "My Documents")
        path = File.dirname(path)
      end
      return path
    end

    def get_paths
      return env_path.split(';')
    end

    def library
      # For some reason, my homepath returns inside 'My Documents'...
      application_data = File.join(home, LOCAL_SETTINGS, APPLICATION_DATA)
      if(File.exists?(application_data))
        return application_data
      else
        return super
      end
    end

    def clean_path(path)
      path = path.split('/').join("\\")
      if(path.index(' '))
        return %{"#{path}"}
      end
      return path
    end

    def format_application_name(name)
      return name.capitalize
    end

    def can_execute? platform
      [:windows, :win32].include?(platform) || super
    end

    protected

    ##
    # Gets the process runner and calls
    # platform-specific execute method
    def get_and_execute_process_runner tool, options=nil
      tool = clean_path find_tool(tool)
      runner = get_process_runner
      runner.execute_win32 tool, options
      runner
    end

    private

    def find_tool tool
      return "#{tool}.bat" if File.exists?("#{tool}.bat")
      return "#{tool}.exe" if File.exists?("#{tool}.exe")
      tool
    end

    def env_path
      ENV['PATH']
    end

  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
sprout-1.1.18.pre lib/sprout/system/win_system.rb
sprout-1.1.17.pre lib/sprout/system/win_system.rb
sprout-1.1.16.pre lib/sprout/system/win_system.rb
sprout-1.1.15.pre lib/sprout/system/win_system.rb
sprout-1.1.14.pre lib/sprout/system/win_system.rb
sprout-1.1.13.pre lib/sprout/system/win_system.rb
sprout-1.1.11.pre lib/sprout/system/win_system.rb
sprout-1.1.10.pre lib/sprout/system/win_system.rb
sprout-1.1.7.pre lib/sprout/system/win_system.rb
sprout-1.1.5.pre lib/sprout/system/win_system.rb
sprout-1.1.4.pre lib/sprout/system/win_system.rb
sprout-1.1.3.pre lib/sprout/system/win_system.rb
sprout-1.1.2.pre lib/sprout/system/win_system.rb
sprout-1.0.35.pre lib/sprout/system/win_system.rb
sprout-1.0.32.pre lib/sprout/system/win_system.rb
sprout-1.0.31.pre lib/sprout/system/win_system.rb
sprout-1.0.29.pre lib/sprout/system/win_system.rb
sprout-1.0.26.pre lib/sprout/system/win_system.rb
sprout-1.0.25.pre lib/sprout/system/win_system.rb
sprout-1.0.24.pre lib/sprout/system/win_system.rb