Module: Mobilis::ActionsProjectsTake

Included in:
GenericProject, Project
Defined in:
lib/mobilis/actions_projects_take.rb

Instance Method Summary collapse

Instance Method Details

#append_line(filename, line) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/mobilis/actions_projects_take.rb', line 7

def append_line filename, line
  lines = IO.readlines filename
  lines << line
  write_file filename do |f|
    f.write(lines.join("\n"))
  end
end

#oblivious_run_command(command) ⇒ Object



26
27
28
29
30
31
# File 'lib/mobilis/actions_projects_take.rb', line 26

def oblivious_run_command command
  # fixme
  #Mobilis.logger.info "$ #{command.join " "}"
  puts "-> Running --> #{command}"
  system command
end

#run_command(command) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/mobilis/actions_projects_take.rb', line 15

def run_command command
  # fixme
  #Mobilis.logger.info "$ #{command.join " "}"
  puts "-> Running --> #{command}"
  system command
  if $? then
    puts "-> Error running command!"
    exit(1)
  end
end

#run_docker(cmd) ⇒ Object



33
34
35
# File 'lib/mobilis/actions_projects_take.rb', line 33

def run_docker cmd
  oblivious_run_command "docker #{cmd}"
end

#set_file_contents(filename, contents) ⇒ Object



49
50
51
52
53
# File 'lib/mobilis/actions_projects_take.rb', line 49

def set_file_contents filename, contents
  write_file filename do |f|
    f.write contents
  end
end

#set_second_line(filename, line) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mobilis/actions_projects_take.rb', line 37

def set_second_line filename, line
  lines = IO.readlines filename
  lines.reverse!
  first_line = lines.pop
  lines << line
  lines << first_line
  lines.reverse!
  write_file filename do |f|
    f.write(lines.join("\n"))
  end
end

#write_file(filename, &block) ⇒ Object



55
56
57
58
# File 'lib/mobilis/actions_projects_take.rb', line 55

def write_file filename, &block
  puts " -> Writing --> #{ filename }"
  File.open(filename, "wb", &block)
end