class Multisync::Definition::Entity

Attributes

members[R]

All members (groups or syncs) of this group

name[R]

The name of the group

parent[R]

The parent of the group

result[R]

Collected results after run as Hash

{
  cmd: 'rsync --stats -v source destination',
  action: :run,
  status: #<Process::Status: pid 65416 exit 0>,
  stdout: '',
  stderr: '',
  skip_message: 'host not reachable',
}

Public Class Methods

new(parent, name, &block) click to toggle source
# File lib/multisync/definition/entity.rb, line 27
def initialize parent, name, &block
  @members = []
  @name = name.to_s
  @parent = parent
  parent.register self
  instance_eval(&block) if block_given?
  @result = {}
end

Public Instance Methods

accept(visitor, level=0) click to toggle source

Make the definition visitable

# File lib/multisync/definition/entity.rb, line 56
def accept visitor, level=0
  visitor.visit self, level
  members.map do |member|
    member.accept visitor, level+1
  end
end
check_destination?() click to toggle source

Should destination's host or path be checked before sync?

# File lib/multisync/definition/entity.rb, line 113
def check_destination?
  @to_check.nil? ? parent.check_destination? : @to_check
end
check_source?() click to toggle source

Should source's host or path be checked before sync?

# File lib/multisync/definition/entity.rb, line 108
def check_source?
  @from_check.nil? ? parent.check_source? : @from_check
end
checks() click to toggle source

All checks from parent to child

# File lib/multisync/definition/entity.rb, line 103
def checks
  (parent.checks + [@check]).compact
end
default?() click to toggle source

Is this group/sync defined as default

# File lib/multisync/definition/entity.rb, line 98
def default?
  @default || parent.default?
end
destination() click to toggle source

rsync destination

# File lib/multisync/definition/entity.rb, line 82
def destination
  @to_value || parent.destination
end
destination_description() click to toggle source
# File lib/multisync/definition/entity.rb, line 86
def destination_description
  @to_description || @to_value || parent.destination_description
end
fullname() click to toggle source

The name including all parents separated by “/”

# File lib/multisync/definition/entity.rb, line 68
def fullname
  [parent.fullname, name].join '/'
end
register(member) click to toggle source
# File lib/multisync/definition/entity.rb, line 63
def register member
  members << member
end
rsync_options() click to toggle source

rsync options

# File lib/multisync/definition/entity.rb, line 91
def rsync_options
  opts = @rsync_options || []
  return opts if @rsync_options_mode == :override
  parent.rsync_options + opts
end
source() click to toggle source

rsync source

# File lib/multisync/definition/entity.rb, line 73
def source
  @from_value || parent.source
end
source_description() click to toggle source
# File lib/multisync/definition/entity.rb, line 77
def source_description
  @from_description || @from_value || parent.source_description
end
to_h() click to toggle source
# File lib/multisync/definition/entity.rb, line 36
def to_h
  {
    fullname: fullname,
    default: default?,
    source: {
      path: source,
      description: source_description,
      check: check_source?,
    },
    destination: {
      path: destination,
      description: destination_description,
      check: check_destination?,
    },
    checks: checks,
    rsync_options: rsync_options,
  }
end