Top Level Namespace

Defined Under Namespace

Modules: Backup, Crypto Classes: String

Instance Method Summary collapse

Instance Method Details

#check_mode(file, first, second) ⇒ Object



32
33
34
35
36
# 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) ⇒ Object



38
39
40
41
42
# 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


11
12
13
# File 'lib/helpers.rb', line 11

def print_verbose(msg)
  print msg if $PRINT_VERBOSE
end

#puts_fail(msg) ⇒ Object



1
2
3
4
5
# File 'lib/helpers.rb', line 1

def puts_fail(msg)
  STDERR.puts "#{"Error: ".red}#{msg}"

  exit msg.length
end

#puts_verbose(msg) ⇒ Object



7
8
9
# File 'lib/helpers.rb', line 7

def puts_verbose(msg)
  puts msg if $PRINT_VERBOSE
end

#safe_require(&block) ⇒ Object



15
16
17
18
19
20
21
22
# 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) ⇒ Object



24
25
26
27
28
29
30
# 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