Class: Twin::Job
- Inherits:
-
Struct
- Object
- Struct
- Twin::Job
- Defined in:
- lib/twin/scanner.rb
Overview
One YAML block from a sync-file, enriched with live filesystem state.
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#conflict ⇒ Object
Returns the value of attribute conflict.
-
#delete ⇒ Object
Returns the value of attribute delete.
-
#description ⇒ Object
Returns the value of attribute description.
-
#excludes ⇒ Object
Returns the value of attribute excludes.
-
#label ⇒ Object
Returns the value of attribute label.
-
#path ⇒ Object
Returns the value of attribute path.
-
#program ⇒ Object
Returns the value of attribute program.
-
#render ⇒ Object
Returns the value of attribute render.
-
#render_outdated ⇒ Object
Returns the value of attribute render_outdated.
-
#source ⇒ Object
Returns the value of attribute source.
-
#source_exists ⇒ Object
Returns the value of attribute source_exists.
-
#source_mtime ⇒ Object
Returns the value of attribute source_mtime.
-
#sync_file ⇒ Object
Returns the value of attribute sync_file.
-
#target ⇒ Object
Returns the value of attribute target.
-
#target_exists ⇒ Object
Returns the value of attribute target_exists.
-
#target_mtime ⇒ Object
Returns the value of attribute target_mtime.
-
#target_path_field ⇒ Object
Returns the value of attribute target_path_field.
-
#target_unreachable ⇒ Object
Returns the value of attribute target_unreachable.
Instance Method Summary collapse
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def active @active end |
#cmd ⇒ Object
Returns the value of attribute cmd
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def cmd @cmd end |
#conflict ⇒ Object
Returns the value of attribute conflict
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def conflict @conflict end |
#delete ⇒ Object
Returns the value of attribute delete
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def delete @delete end |
#description ⇒ Object
Returns the value of attribute description
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def description @description end |
#excludes ⇒ Object
Returns the value of attribute excludes
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def excludes @excludes end |
#label ⇒ Object
Returns the value of attribute label
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def label @label end |
#path ⇒ Object
Returns the value of attribute path
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def path @path end |
#program ⇒ Object
Returns the value of attribute program
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def program @program end |
#render ⇒ Object
Returns the value of attribute render
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def render @render end |
#render_outdated ⇒ Object
Returns the value of attribute render_outdated
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def render_outdated @render_outdated end |
#source ⇒ Object
Returns the value of attribute source
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def source @source end |
#source_exists ⇒ Object
Returns the value of attribute source_exists
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def source_exists @source_exists end |
#source_mtime ⇒ Object
Returns the value of attribute source_mtime
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def source_mtime @source_mtime end |
#sync_file ⇒ Object
Returns the value of attribute sync_file
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def sync_file @sync_file end |
#target ⇒ Object
Returns the value of attribute target
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def target @target end |
#target_exists ⇒ Object
Returns the value of attribute target_exists
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def target_exists @target_exists end |
#target_mtime ⇒ Object
Returns the value of attribute target_mtime
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def target_mtime @target_mtime end |
#target_path_field ⇒ Object
Returns the value of attribute target_path_field
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def target_path_field @target_path_field end |
#target_unreachable ⇒ Object
Returns the value of attribute target_unreachable
8 9 10 |
# File 'lib/twin/scanner.rb', line 8 def target_unreachable @target_unreachable end |
Instance Method Details
#remote? ⇒ Boolean
17 |
# File 'lib/twin/scanner.rb', line 17 def remote? = Twin::Remote.remote?(target) |
#source_path ⇒ Object
15 |
# File 'lib/twin/scanner.rb', line 15 def source_path = File.join(source, path) |
#status ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/twin/scanner.rb', line 19 def status return :disabled if active != 1 return :unreachable if target_unreachable return :both_missing if !source_exists && !target_exists return :missing_source unless source_exists return :missing_target unless target_exists # Render jobs compare by content, not mtime — a rendered target's mtime # bears no relation to the template's. return render_outdated ? :source_newer : :in_sync if render 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_path ⇒ Object
16 |
# File 'lib/twin/scanner.rb', line 16 def target_path = File.join(target, target_path_field || path) |