Module: DTR::SyncCodebase::SyncService

Includes:
DTR::Service::File, Package
Included in:
WorkingEnvExt
Defined in:
lib/dtr/shared/sync_codebase/sync_service.rb

Instance Method Summary collapse

Methods included from DTR::Service::File

#lookup_file, #provide_file

Methods included from DTR::Service::Rinda

#lookup, #lookup_ring, #start_service, #stop_service

Methods included from Package

#do_work, #package_cmd, #package_copy_file, #package_dir, #package_dir_path, #package_file, #package_name, #unpackage_cmd

Instance Method Details

#sync_codebase(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dtr/shared/sync_codebase/sync_service.rb', line 21

def sync_codebase(&block)
  DTR.info("Start sync codebase, clean #{File.expand_path(Dir.pwd)}")
  Dir.glob('*').each { |f| FileUtils.rm_rf(f) }

  DTR.info("Lookup codebase package file")
  package = lookup_file
  DTR.info("Receiving package file and writing to #{package_copy_file}")
  File.open(package_copy_file, 'w') do |f|
    package.copy_into(f)
  end

  block.call

  DTR.info("sync codebase finished, clean #{package_copy_file}")
  FileUtils.rm_f(package_copy_file)
end