Module: Pipeline::Util

Instance Method Summary collapse

Instance Method Details

#fingerprint(text) ⇒ Object



23
24
25
# File 'lib/pipeline/util.rb', line 23

def fingerprint text
  Digest::SHA2.new(256).update(text).to_s
end

#relative_path(path, pwd) ⇒ Object



31
32
33
34
35
# File 'lib/pipeline/util.rb', line 31

def relative_path path, pwd
  pathname = Pathname.new(path)
  return path if pathname.relative?
  pathname.relative_path_from(Pathname.new pwd)
end

#runsystem(report, *splat) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pipeline/util.rb', line 8

def runsystem(report, *splat)
  Open3.popen3(*splat) do |stdin, stdout, stderr, wait_thr|

    Thread.new do
      if $logfile and report
        while line = stderr.gets do
          $logfile.puts line
        end
      end
    end

    return stdout.read.chomp
  end
end

#strip_archive_path(path, delimeter) ⇒ Object



27
28
29
# File 'lib/pipeline/util.rb', line 27

def strip_archive_path path, delimeter
  path.split(delimeter).last.split('/')[1..-1].join('/')
end