Class: FileTreeProfiler::Merge::Pairing

Inherits:
Object
  • Object
show all
Defined in:
lib/file_tree_profiler/merge/pairing.rb

Constant Summary collapse

EQUAL =
1
DIFFERENT =
2
ONLY_SOURCE =
3
ONLY_TARGET =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePairing

Returns a new instance of Pairing.



11
12
13
# File 'lib/file_tree_profiler/merge/pairing.rb', line 11

def initialize
  @status_leaf = false
end

Instance Attribute Details

#status_leafObject

Returns the value of attribute status_leaf.



9
10
11
# File 'lib/file_tree_profiler/merge/pairing.rb', line 9

def status_leaf
  @status_leaf
end

Instance Method Details

#add(scope, file) ⇒ Object



15
16
17
18
# File 'lib/file_tree_profiler/merge/pairing.rb', line 15

def add scope, file
  @files ||= {}
  @files[scope] = file
end

#anyObject



44
45
46
# File 'lib/file_tree_profiler/merge/pairing.rb', line 44

def any
  (source || target)
end

#nameObject



28
29
30
# File 'lib/file_tree_profiler/merge/pairing.rb', line 28

def name
  any.name
end

#parent_relative_pathObject



36
37
38
39
40
41
42
# File 'lib/file_tree_profiler/merge/pairing.rb', line 36

def parent_relative_path
  if relative_path == '/'
    nil
  else
    ::File.dirname(relative_path)
  end
end

#relative_pathObject



32
33
34
# File 'lib/file_tree_profiler/merge/pairing.rb', line 32

def relative_path
  any.relative_path
end

#sourceObject



20
21
22
# File 'lib/file_tree_profiler/merge/pairing.rb', line 20

def source
  @files[:source]
end

#statusObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/file_tree_profiler/merge/pairing.rb', line 48

def status
  @status ||= begin
    if source && target
      if source.checksum == target.checksum
        EQUAL
      else
        DIFFERENT
      end
    elsif source
      ONLY_SOURCE
    else
      ONLY_TARGET
    end
  end
end

#targetObject



24
25
26
# File 'lib/file_tree_profiler/merge/pairing.rb', line 24

def target
  @files[:target]
end