module Aerosol::Util

Public Instance Methods

git_repo() click to toggle source
# File lib/aerosol/util.rb, line 34
def git_repo
  @git_repo ||= MiniGit.new('.')
end
git_sha() click to toggle source
# File lib/aerosol/util.rb, line 38
def git_sha
  @git_sha ||= git_repo.capturing.rev_parse('HEAD').chomp[0..6] rescue 'unknown'
end
is_gzip?(path) click to toggle source
# File lib/aerosol/util.rb, line 18
def is_gzip?(path)
  if File.size(path) < 2
    return false
  end
  magic = nil
  File.open(path, "r") do |f|
    magic = f.read(2)
  end
  magic = magic.unpack('H*')[0]
  magic == "1f8b"
end
is_tar?(path) click to toggle source
# File lib/aerosol/util.rb, line 6
def is_tar?(path)
  if File.size(path) < 262
    return false
  end
  magic = nil
  File.open(path, "r") do |f|
    f.read(257)
    magic = f.read(5)
  end
  magic == "ustar"
end
strip_heredoc(str) click to toggle source
# File lib/aerosol/util.rb, line 30
def strip_heredoc(str)
  str.gsub(/^#{str[/\A\s*/]}/, '')
end