module Glue::Util

Public Instance Methods

fingerprint(text) click to toggle source
# File lib/glue/util.rb, line 23
def fingerprint text
  Digest::SHA2.new(256).update(text).to_s
end
relative_path(path, pwd) click to toggle source
# File lib/glue/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) click to toggle source
# File lib/glue/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) click to toggle source
# File lib/glue/util.rb, line 27
def strip_archive_path path, delimeter
  path.split(delimeter).last.split('/')[1..-1].join('/')
end