Top Level Namespace

Defined Under Namespace

Modules: MoodeAutoDeployKit

Instance Method Summary collapse

Instance Method Details

#debug(message) ⇒ Object



3
4
5
6
7
8
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 3

def debug(message)
  logger = Logger.new(STDOUT)
  logger.debug ">>>>>>>>>>>>>>>DEBUG START<<<<<<<<<<<<<<<"
  logger.debug message
  logger.debug ">>>>>>>>>>>>>>>DEBUG ENG<<<<<<<<<<<<<<<"
end

#error(message) ⇒ Object



31
32
33
34
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 31

def error(message)
  error_to_console message
  error_to_file message
end

#error_to_console(message) ⇒ Object



14
15
16
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 14

def error_to_console(message)
  puts "Error: #{message}"
end

#error_to_file(message) ⇒ Object



22
23
24
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 22

def error_to_file(message)
  FileLog.new.error(message)
end

#info(message) ⇒ Object



26
27
28
29
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 26

def info(message)
  info_to_console message
  log_to_file message
end

#info_to_console(message) ⇒ Object



10
11
12
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 10

def info_to_console(message)
  puts message
end

#log_to_file(message) ⇒ Object



18
19
20
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 18

def log_to_file(message)
  FileLog.new.info(message)
end

#read_all(file) ⇒ Object



54
55
56
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 54

def read_all file
  IO.readlines(file).join
end

#require_dir(dir) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 45

def require_dir(dir)
  Dir.foreach(dir) do |entry|
    absolute_path = File.join(dir, entry)
    next if (entry == "." || entry == "..")
    require absolute_path if (File.file?(absolute_path) && absolute_path.end_with?("rb"))
    require_dir(absolute_path) if File.directory?(absolute_path)
  end
end

#reset_dir(dir) ⇒ Object



40
41
42
43
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 40

def reset_dir(dir)
  FileUtils.rm_rf dir if File.exist? dir
  FileUtils.mkdir_p dir  
end

#run_command(cmd) ⇒ Object



36
37
38
# File 'lib/moode_auto_deploy_kit/infra/utils.rb', line 36

def run_command(cmd)
  Process.abort "Failed to run command #{cmd}" unless system cmd
end