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
-
#in_folder(folder) ⇒ Object
Provides a way to change the current working directory to a different folder location.
- #with_clean_env ⇒ Object
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.
13 14 15 16 17 18 19 20 21 |
# 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) with_clean_env do Dir.chdir folder do yield end end end |
#with_clean_env ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/codeowner_validator/helpers/utility_helper.rb', line 23 def with_clean_env return yield unless defined?(Bundler) if Bundler.respond_to?(:with_unbundled_env) Bundler.with_unbundled_env { yield } else # Deprecated on Bundler 2.1 Bundler.with_clean_env { yield } end end |