Sha256: b3f8360215ab58c0524b9f9ef20648301ad0ea0b9162eb820ff1b77592c17bfb

Contents?: true

Size: 1.57 KB

Versions: 47

Compression:

Stored size: 1.57 KB

Contents

class Step
  def self.link_job(path, target_dir, task = nil, workflow = nil)
    Path.setup(target_dir)

    name = File.basename(path)
    task = File.basename(File.dirname(path)) if task.nil?
    workflow = File.basename(File.dirname(File.dirname(path))) if workflow.nil?

    FileUtils.mkdir_p target_dir[workflow][task]
    FileUtils.ln_s path, target_dir[workflow][task][name].find
    FileUtils.ln_s path + '.files', target_dir[workflow][task][name].find + '.files' if File.exists?(path + '.files')
    FileUtils.ln_s path + '.info', target_dir[workflow][task][name].find + '.info' if File.exists?(path + '.info')
  end

  def archive(target = nil)
    target = self.path + '.tar.gz' if target.nil?
    target = File.expand_path(target)
    TmpFile.with_file do |tmpdir|
      Step.link_job self.path, tmpdir
      rec_dependencies = Set.new
      deps = [self.path]
      seen = Set.new
      while deps.any?
        path = deps.shift
        dep = Step.new path
        seen << dep.path
        dep.info[:dependencies].each do |task, name, path|
          dep = Step.new path
          next if seen.include? dep.path
          deps << dep.path
          rec_dependencies << dep.path
        end if dep.info[:dependencies]
      end

      rec_dependencies.each do |path|
        Step.link_job path, tmpdir
      end

      Misc.in_dir(tmpdir) do
        io = CMD.cmd("tar cvhzf '#{target}'  ./*", :pipe => true)
        while line = io.gets
          Log.debug line
        end
        io.join if io.respond_to? :join
      end
      Log.debug "Archive finished at: #{target}"
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
rbbt-util-5.23.30 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.29 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.28 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.27 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.26 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.25 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.24 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.23 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.22 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.21 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.20 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.19 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.18 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.17 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.16 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.15 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.14 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.13 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.12 lib/rbbt/workflow/archive.rb
rbbt-util-5.23.11 lib/rbbt/workflow/archive.rb