Sha256: 420d3abfd0257b9aef4b6d9a040dbcacd968a8319118da9940deecf8bd41b74d

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

module VagrantWindows
  module Communication
   
    # Handles loading all available Linix command filters and applying them
    # to specified command
    class LinuxCommandFilter

      # Filter the given Vagrant command to ensure compatibility with Windows
      #
      # @param [String] The Vagrant shell command
      # @returns [String] Windows runnable command or empty string
      def filter(command)
        win_friendly_cmd = command
        command_filters.each do |cmd_filter|
          win_friendly_cmd = cmd_filter.filter(win_friendly_cmd) if cmd_filter.accept?(win_friendly_cmd)
        end
        win_friendly_cmd
      end


      # All the available Linux command filters
      #
      # @returns [Array] All Linux command filter instances
      def command_filters
        @command_filters ||= create_command_filters()
      end

      # Creates all the available Linux command filters
      #
      # @returns [Array] All Linux command filter instances
      def create_command_filters
        filters = []
        Dir[File.join(File.dirname(__FILE__), '/command_filters/*.rb')].each do |file|
          require file
          clazz = File.basename(file, '.*').capitalize
          filters << Module.const_get("VagrantWindows::Communication::CommandFilters::#{clazz}").new
        end
        filters
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-windows-1.7.0.pre.2 lib/vagrant-windows/communication/linux_command_filter.rb
vagrant-windows-1.7.0.pre.1 lib/vagrant-windows/communication/linux_command_filter.rb