Class: Etna::Clients::Metis::WalkMetisDiffWorkflow
- Inherits:
-
Struct
- Object
- Struct
- Etna::Clients::Metis::WalkMetisDiffWorkflow
- Defined in:
- lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb
Instance Attribute Summary collapse
-
#left_walker ⇒ Object
Returns the value of attribute left_walker.
-
#right_walker ⇒ Object
Returns the value of attribute right_walker.
Instance Method Summary collapse
- #compare_file_or_folder_age(l, r) ⇒ Object
- #compare_file_or_folders(l, r) ⇒ Object
-
#each(&block) ⇒ Object
Iterates entries of the form [kind, left | nil, right | nil] where kind is one of :left_unique | :right_unique | :left_is_folder | :right_is_folder :unknown | :equal | :right_older | :left_older and left / right is one of nil | Etna::Clients::Metis::File | Etna::Clients::Metis::Folder.
- #next_or_nil(enum) ⇒ Object
Instance Attribute Details
#left_walker ⇒ Object
Returns the value of attribute left_walker
4 5 6 |
# File 'lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb', line 4 def left_walker @left_walker end |
#right_walker ⇒ Object
Returns the value of attribute right_walker
4 5 6 |
# File 'lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb', line 4 def right_walker @right_walker end |
Instance Method Details
#compare_file_or_folder_age(l, r) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb', line 75 def compare_file_or_folder_age(l, r) if l.updated_at.nil? return :unknown end if r.updated_at.nil? return :unknown end if l.updated_at < r.updated_at return :left_older elsif l.updated_at > r.updated_at return :right_older else return :equal end end |
#compare_file_or_folders(l, r) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb', line 50 def compare_file_or_folders(l, r) if l.is_a?(Etna::Clients::Metis::Folder) if r.is_a?(Etna::Clients::Metis::Folder) return compare_file_or_folder_age(l, r) end return :left_is_folder end if r.is_a?(Etna::Clients::Metis::Folder) return :right_is_folder end if l.file_hash.nil? || r.file_hash.nil? return :unknown end if l.file_hash == r.file_hash return :equal end return compare_file_or_folder_age(l, r) end |
#each(&block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb', line 11 def each(&block) left_enum = self.left_walker.to_enum right_enum = self.right_walker.to_enum l, l_path = next_or_nil(left_enum) r, r_path = next_or_nil(right_enum) while l && r if l_path == r_path yield [compare_file_or_folders(l, r), l, r] l, l_path = next_or_nil(left_enum) r, r_path = next_or_nil(right_enum) elsif l_path < r_path yield [:left_unique, l, nil] l, l_path = next_or_nil(left_enum) else yield [:right_unique, nil, r] r, r_path = next_or_nil(right_enum) end end while l yield [:left_unique, l, nil] l, l_path = next_or_nil(left_enum) end while r yield [:right_unique, nil, r] r, r_path = next_or_nil(right_enum) end end |
#next_or_nil(enum) ⇒ Object
44 45 46 47 48 |
# File 'lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb', line 44 def next_or_nil(enum) enum.next rescue StopIteration [nil, nil] end |