Module: CodeownerValidator::UtilityHelper

Included in:
CodeOwners, Tasks::Base
Defined in:
lib/codeowner_validator/helpers/utility_helper.rb

Overview

Public: A utility helper to provide common methods for reuse across multiple classes

Instance Method Summary collapse

Instance Method Details

#in_folder(folder) ⇒ Object

Provides a way to change the current working directory to a different folder location. This ability can ease the reference of file references when working with multiple repository locations.

Raises:

  • (RuntimeError)

    if the folder location does not exist.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/codeowner_validator/helpers/utility_helper.rb', line 13

def in_folder(folder)
  raise "The folder location '#{folder}' does not exists" unless File.directory?(folder)

  if defined?(Bundler)
    Bundler.with_clean_env do
      Dir.chdir folder do
        yield
      end
    end
  else
    Dir.chdir folder do
      yield
    end
  end
end