Class: FileTreeProfiler::Merge::Pairing
- Inherits:
-
Object
- Object
- FileTreeProfiler::Merge::Pairing
- 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
-
#status_leaf ⇒ Object
Returns the value of attribute status_leaf.
Instance Method Summary collapse
- #add(scope, file) ⇒ Object
- #any ⇒ Object
-
#initialize ⇒ Pairing
constructor
A new instance of Pairing.
- #name ⇒ Object
- #parent_relative_path ⇒ Object
- #relative_path ⇒ Object
- #source ⇒ Object
- #status ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize ⇒ Pairing
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_leaf ⇒ Object
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 |
#any ⇒ Object
44 45 46 |
# File 'lib/file_tree_profiler/merge/pairing.rb', line 44 def any (source || target) end |
#name ⇒ Object
28 29 30 |
# File 'lib/file_tree_profiler/merge/pairing.rb', line 28 def name any.name end |
#parent_relative_path ⇒ Object
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_path ⇒ Object
32 33 34 |
# File 'lib/file_tree_profiler/merge/pairing.rb', line 32 def relative_path any.relative_path end |
#source ⇒ Object
20 21 22 |
# File 'lib/file_tree_profiler/merge/pairing.rb', line 20 def source @files[:source] end |
#status ⇒ Object
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 |
#target ⇒ Object
24 25 26 |
# File 'lib/file_tree_profiler/merge/pairing.rb', line 24 def target @files[:target] end |