Sha256: ef56442eb883f6f84703d3ad1f266c87e20eb1ccc357d7ad7310e74b397cdb52

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

module VagrantPlugins
  module Unison
    class ShellCommand
      def initialize machine, paths, ssh_command
        @machine = machine
        @paths = paths
        @ssh_command = ssh_command
      end

      attr_accessor :batch, :repeat, :terse

      def to_a
        args.map do |arg|
          arg = arg[1...-1] if arg =~ /\A"(.*)"\z/
          arg
        end
      end

      def to_s
        args.join(' ')
      end

      private

      def args
        [
          'unison',
          @paths.host,
          @ssh_command.uri,
          batch_arg,
          terse_arg,
          repeat_arg,
          ignore_arg,
          ['-sshargs', %("#{@ssh_command.command}")],
        ].flatten.compact
      end

      def batch_arg
        '-batch' if batch
      end

      def ignore_arg
        ['-ignore', %("#{@machine.config.unison.ignore}")] if @machine.config.unison.ignore
      end

      def repeat_arg
        ['-repeat', @machine.config.unison.repeat] if repeat && @machine.config.unison.repeat
      end

      def terse_arg
        '-terse' if terse
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-unison2-1.0.3 lib/vagrant-unison2/shell_command.rb
vagrant-unison2-1.0.2 lib/vagrant-unison2/shell_command.rb
vagrant-unison2-1.0.1 lib/vagrant-unison2/shell_command.rb
vagrant-unison2-1.0.0 lib/vagrant-unison/shell_command.rb