File: command.rb

package info (click to toggle)
ruby-rsync 1.0.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 140 kB
  • sloc: ruby: 348; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 479 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Rsync
  # An rsync command to be run
  class Command
    # Runs the rsync job and returns the results
    #
    # @param args {Array}
    # @return {Result}
    def self.run(*args)
      output = run_command("rsync --itemize-changes #{args.join(" ")}")
      Result.new(output, $?.exitstatus)
    end

private

    def self.run_command(cmd, &block)
      if block_given?
        IO.popen("#{cmd} 2>&1", &block)
      else
        `#{cmd} 2>&1`
      end
    end
  end
end