Module: TestBoosters::Shell

Defined in:
lib/test_boosters/shell.rb

Class Method Summary collapse

Class Method Details

.display_files(title, files) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/test_boosters/shell.rb', line 41

def display_files(title, files)
  puts "#{title} (#{files.count} files):"
  puts

  files.each { |file| puts "- #{file}" }

  puts "\n"
end

.display_title(title) ⇒ Object



35
36
37
38
39
# File 'lib/test_boosters/shell.rb', line 35

def display_title(title)
  puts
  puts "=== #{title} ===="
  puts
end

.evaluate(command) ⇒ Object



27
28
29
# File 'lib/test_boosters/shell.rb', line 27

def evaluate(command)
  with_clean_env { `#{command}` }
end

.execute(command, options = {}) ⇒ Object

:reek:TooManyStatements



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/test_boosters/shell.rb', line 6

def execute(command, options = {})
  TestBoosters::Logger.info("Running command: #{command}")

  puts command unless options[:silent] == true

  with_clean_env do
    system(command)
  end

  signaled    = $?.signaled?
  termsig     = $?.termsig
  exited      = $?.exited?
  exit_status = $?.exitstatus

  TestBoosters::Logger.info("Command signaled with: #{termsig}") if signaled
  TestBoosters::Logger.info("Command exited : #{exited}")
  TestBoosters::Logger.info("Command finished, exit status : #{exit_status}")

  exit_status
end

.with_clean_envObject



31
32
33
# File 'lib/test_boosters/shell.rb', line 31

def with_clean_env
  defined?(Bundler) ? Bundler.with_clean_env { yield } : yield
end