class Object

Public Instance Methods

check_mode(file, first, second) click to toggle source
# File lib/helpers.rb, line 23
def check_mode(file, first, second)
  unless first == second
    puts_fail "Permission wasn't changed for #{file.dark_green}"
  end
end
check_rights(file, first_uid, first_gid, second_uid, second_gid) click to toggle source
# File lib/helpers.rb, line 29
def check_rights(file, first_uid, first_gid, second_uid, second_gid)
  unless first_uid == second_uid and first_gid == second_gid
    puts_fail "Group and user wasn't change for #{file.dark_green}"
  end
end
create_lock() click to toggle source
# File lib/helpers.rb, line 35
def create_lock
  open("/tmp/encbs.lock", "w") do |f|
    f.print Process.pid
  end
end
lock_exists?() click to toggle source
# File lib/helpers.rb, line 45
def lock_exists?
  File.exists? "/tmp/encbs.lock"
end
print_verbose(msg) click to toggle source
puts_fail(msg) click to toggle source
# File lib/helpers.rb, line 1
def puts_fail(msg)
  STDERR.puts "#{"Error! ".red}#{msg}"

  exit msg.length
end
puts_verbose(msg) click to toggle source
# File lib/helpers.rb, line 7
def puts_verbose(msg)
  puts msg if $PRINT_VERBOSE
end
remove_lock() click to toggle source
# File lib/helpers.rb, line 41
def remove_lock
  FileUtils.rm "/tmp/encbs.lock" if File.exists? "/tmp/encbs.lock"
end
try_create_dir(dir) click to toggle source
# File lib/helpers.rb, line 15
def try_create_dir(dir)
  begin
    FileUtils.mkdir_p dir unless File.directory? dir
  rescue Errno::EACCES
    puts_fail "Permission denied for #{dir.dark_green}"
  end
end