Sha256: 7091a79dd9cee91526dc80eb2d90dac3b7cf9c6906f43efdc11395f211578ba8

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 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.sync.ignore}")] if @machine.config.sync.ignore
      end

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

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

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
vagrant-unison-morroni-0.0.25 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.24 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.23 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.22 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.21 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.20 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.19 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.18 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.17 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-morroni-0.0.16 lib/vagrant-unison-morroni/shell_command.rb
vagrant-unison-latest-0.0.16 lib/vagrant-unison/shell_command.rb