Class: Twin::Job

Inherits:
Struct
  • Object
show all
Defined in:
lib/twin/scanner.rb

Overview

One YAML block from a sync-file, enriched with live filesystem state.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#activeObject

Returns the value of attribute active

Returns:

  • (Object)

    the current value of active



6
7
8
# File 'lib/twin/scanner.rb', line 6

def active
  @active
end

#cmdObject

Returns the value of attribute cmd

Returns:

  • (Object)

    the current value of cmd



6
7
8
# File 'lib/twin/scanner.rb', line 6

def cmd
  @cmd
end

#conflictObject

Returns the value of attribute conflict

Returns:

  • (Object)

    the current value of conflict



6
7
8
# File 'lib/twin/scanner.rb', line 6

def conflict
  @conflict
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



6
7
8
# File 'lib/twin/scanner.rb', line 6

def description
  @description
end

#excludesObject

Returns the value of attribute excludes

Returns:

  • (Object)

    the current value of excludes



6
7
8
# File 'lib/twin/scanner.rb', line 6

def excludes
  @excludes
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



6
7
8
# File 'lib/twin/scanner.rb', line 6

def label
  @label
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



6
7
8
# File 'lib/twin/scanner.rb', line 6

def path
  @path
end

#programObject

Returns the value of attribute program

Returns:

  • (Object)

    the current value of program



6
7
8
# File 'lib/twin/scanner.rb', line 6

def program
  @program
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



6
7
8
# File 'lib/twin/scanner.rb', line 6

def source
  @source
end

#source_existsObject

Returns the value of attribute source_exists

Returns:

  • (Object)

    the current value of source_exists



6
7
8
# File 'lib/twin/scanner.rb', line 6

def source_exists
  @source_exists
end

#source_mtimeObject

Returns the value of attribute source_mtime

Returns:

  • (Object)

    the current value of source_mtime



6
7
8
# File 'lib/twin/scanner.rb', line 6

def source_mtime
  @source_mtime
end

#sync_fileObject

Returns the value of attribute sync_file

Returns:

  • (Object)

    the current value of sync_file



6
7
8
# File 'lib/twin/scanner.rb', line 6

def sync_file
  @sync_file
end

#targetObject

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



6
7
8
# File 'lib/twin/scanner.rb', line 6

def target
  @target
end

#target_existsObject

Returns the value of attribute target_exists

Returns:

  • (Object)

    the current value of target_exists



6
7
8
# File 'lib/twin/scanner.rb', line 6

def target_exists
  @target_exists
end

#target_mtimeObject

Returns the value of attribute target_mtime

Returns:

  • (Object)

    the current value of target_mtime



6
7
8
# File 'lib/twin/scanner.rb', line 6

def target_mtime
  @target_mtime
end

Instance Method Details

#source_pathObject



12
# File 'lib/twin/scanner.rb', line 12

def source_path = File.join(source, path)

#statusObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/twin/scanner.rb', line 15

def status
  return :disabled if active != 1
  return :both_missing if !source_exists && !target_exists
  return :missing_source unless source_exists
  return :missing_target unless target_exists
  return :target_newer if conflict
  return :in_sync if source_mtime.nil? || target_mtime.nil?
  delta = source_mtime - target_mtime
  return :in_sync if delta.abs < 60
  delta > 0 ? :source_newer : :target_newer
end

#target_pathObject



13
# File 'lib/twin/scanner.rb', line 13

def target_path = File.join(target, path)