Sha256: 83bf0aaeccb988f45fbe61d077e60ae8cc53c48b327161bf9c64eeee53455b79

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 Bytes

Contents

module RsyncCron
  class Options
    BW_LIMIT = 5*1024
    DEFAULT_FLAGS = %W[verbose archive compress rsh=ssh bwlimit=#{BW_LIMIT} exclude='DfsrPrivate']

    def initialize(flags = DEFAULT_FLAGS)
      @flags = Array(flags.dup)
    end

    def to_s
      return if @flags.empty?
      @flags.map { |flag| "--#{flag}" }.join(" ")
    end

    def <<(flags)
      flags.split(",").each do |flag|
        @flags << flag if supported?(flag)
      end
      self
    end

    private def supported?(flag)
      %x[rsync --#{flag} 2>&1].match(/unknown option/).nil?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rsync_cron-1.1.2 lib/rsync_cron/options.rb
rsync_cron-1.1.1 lib/rsync_cron/options.rb
rsync_cron-1.1.0 lib/rsync_cron/options.rb