Method: MetaRecordRunner#update_files

Defined in:
lib/metarecord/runner.rb

#update_filesObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/metarecord/runner.rb', line 30

def update_files
  `cp "#{@tmpdir}/#{manifest_path}" "#{manifest_path}"`

  Dir["#{@tmpdir}/**/*"].each do |tmp_file|
    next if File.directory? tmp_file
    new_path = "#{@output}/#{tmp_file[@tmpdir.size + 1..tmp_file.size]}"
    if (not File.exists?(new_path)) || File.read(new_path) != File.read(tmp_file)
      puts "[metarecord] generated #{new_path}"
      `mkdir -p '#{File.dirname new_path}'`
      `cp '#{tmp_file}' '#{new_path}'`
    elsif @verbose == true
      puts "[metarecord] no updates required for #{new_path}"
    end
  end

  @input.each do |input|
    Dir["#{@output}/#{input}/**/*"].each do |actual_file|
      next if File.directory? actual_file
      tmp_path = "#{@tmpdir}/#{@output[@output.size + 1..@output.size]}"
      if not File.exists?(tmp_path)
        puts "[metarecord] removed #{actual_file}"
        `rm '#{actual_file}'`
      end
    end
  end
end