Class: NanDoc::SiteDiff

Inherits:
Object
  • Object
show all
Includes:
Config::Accessors, PathTardo, Treebis::Capture3, Treebis::DirAsHash
Defined in:
lib/nandoc/support/site-diff.rb

Instance Method Summary collapse

Methods included from PathTardo

#hash_to_paths, #path_tardo, tardo_array_index

Methods included from Config::Accessors

#file_utils

Constructor Details

#initialize(src_path, dest_path) ⇒ SiteDiff

Returns a new instance of SiteDiff.



20
21
22
23
24
25
26
27
28
29
# File 'lib/nandoc/support/site-diff.rb', line 20

def initialize src_path, dest_path
  @skip_these = %w(
    output
    tmp
    **/*.orig.rb
    **/*.diff
    treebis-task.rb
  )
  @src_path, @dst_path = src_path, dest_path
end

Instance Method Details

#get_diff_objectObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/nandoc/support/site-diff.rb', line 31

def get_diff_object
  file_utils.notice('comparing these:',
    "#{@src_path.inspect} -> #{@dst_path.inspect}"
  )
  src_hash = dir_as_hash(@src_path, :skip => @skip_these)
  dst_hash = dir_as_hash(@dst_path, :skip => @skip_these)
  dir = empty_tmpdir('site-diff')
  src_path = dir + '/a'
  dst_path = dir + '/b'
  hash_to_dir src_hash, src_path, file_utils
  hash_to_dir dst_hash, dst_path, file_utils
  diff = NanDoc::DiffProxy.diff(src_path, dst_path, :relative_to=>dir)
  diff
end