Module: TestBoosters::Shell

Defined in:
lib/test_boosters/shell.rb

Class Method Summary collapse

Class Method Details

.display_files(title, files) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/test_boosters/shell.rb', line 38

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

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

  puts "\n"
end

.display_title(title) ⇒ Object



32
33
34
35
36
# File 'lib/test_boosters/shell.rb', line 32

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

.evaluate(command) ⇒ Object



24
25
26
# File 'lib/test_boosters/shell.rb', line 24

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
# 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

  exited      = $?.exited?
  exit_status = $?.exitstatus

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

  exit_status
end

.with_clean_envObject



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

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