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 22 23 24 25 26 27 28 |
# 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) method = Bundler.respond_to?(:with_unbundled_env) ? :with_unbundled_env : :with_clean_env Bundler.send(method) do Dir.chdir folder do yield end end else Dir.chdir folder do yield end end end |
#with_clean_env ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/codeowner_validator/helpers/utility_helper.rb', line 30 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 |