Class: FileTreeProfiler::Merge

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

Defined Under Namespace

Classes: Pairing

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_profile, target_profile) ⇒ Merge

Returns a new instance of Merge.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/file_tree_profiler/merge.rb', line 5

def initialize source_profile, target_profile
  @source_profile = source_profile
  @target_profile = target_profile
  @pairings = {}
  merge :source, source_profile.root
  merge :target, target_profile.root
  
  pairings.each do |relative_path, f|
    FileTreeProfiler.monitor_report :merge_finalize, relative_path
    if parent_relative_path = f.parent_relative_path
      if parent = self[parent_relative_path]
        f.status_leaf = parent.status != f.status
      end
    end
  end
end

Instance Attribute Details

#pairingsObject (readonly)

Returns the value of attribute pairings.



3
4
5
# File 'lib/file_tree_profiler/merge.rb', line 3

def pairings
  @pairings
end

#source_profileObject (readonly)

Returns the value of attribute source_profile.



3
4
5
# File 'lib/file_tree_profiler/merge.rb', line 3

def source_profile
  @source_profile
end

#target_profileObject (readonly)

Returns the value of attribute target_profile.



3
4
5
# File 'lib/file_tree_profiler/merge.rb', line 3

def target_profile
  @target_profile
end

Instance Method Details

#[](relative_path) ⇒ Object



40
41
42
# File 'lib/file_tree_profiler/merge.rb', line 40

def [](relative_path)
  pairings[relative_path]
end

#add(scope, file) ⇒ Object



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

def add scope, file
  key = file.relative_path
  pairings[key] ||= Pairing.new
  pairings[key].add scope, file
end

#merge(scope, dir_file) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/file_tree_profiler/merge.rb', line 28

def merge scope, dir_file
  FileTreeProfiler.monitor_report :merge_map, :dir, dir_file.path
  add scope, dir_file
  dir_file.children.each do |child|
    if child.class == DirFile
      merge scope, child
    else
      add scope, child
    end
  end
end

#sizeObject



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

def size
  pairings.size
end