class Object

Public Instance Methods

check_mode(file, first, second) click to toggle source
# File lib/helpers.rb, line 32
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 38
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
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
safe_require() { || ... } click to toggle source
# File lib/helpers.rb, line 15
def safe_require(&block)
  yield
rescue Exception => e
  puts_fail %Q{This script use these gems: fog, slop.
    Make sure that you have them all.
    If you don't have, you may install them: $ gem install fog slop ruby-progressbar
  }
end
try_create_dir(dir) click to toggle source
# File lib/helpers.rb, line 24
def try_create_dir(dir)
  begin
    FileUtils.mkdir_p dir unless Dir.exists? dir
  rescue Errno::EACCES
    puts_fail "Permission denied for #{dir.dark_green}"
  end
end