Module: DTK::Client::RemoteDependencyUtil
- Defined in:
- lib/util/remote_dependency_util.rb
Constant Summary collapse
- MODULE_REF_FILE =
'module_refs.yaml'
Class Method Summary collapse
-
.check_for_frozen_modules(required_modules) ⇒ Object
check if all dependent modules are frozen; if they are don’t display prompt for update.
- .check_permission_warnings(response) ⇒ Object
- .module_ref_content(location) ⇒ Object
- .print_dependency_warnings(response, success_msg = nil, opts = {}) ⇒ Object
Class Method Details
.check_for_frozen_modules(required_modules) ⇒ Object
check if all dependent modules are frozen; if they are don’t display prompt for update
64 65 66 67 68 69 |
# File 'lib/util/remote_dependency_util.rb', line 64 def check_for_frozen_modules(required_modules) return true if required_modules.nil? || required_modules.empty? modules_to_update = required_modules.select{ |md| (md['frozen'].nil? || md['frozen'] == false)} return modules_to_update.empty? end |
.check_permission_warnings(response) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/util/remote_dependency_util.rb', line 46 def (response) errors = '' dependency_warnings = response.data['dependency_warnings'] if dependency_warnings && !dependency_warnings.empty? = dependency_warnings.select { |warning| warning['error_type'].eql?('no_permission') } unless .empty? errors << "\n\nYou do not have (R) permissions for modules:\n\n" .each { |np| errors << " - #{np['module_namespace']}:#{np['module_name']} (owner: #{np['module_owner']})\n" } errors << "\nPlease contact owner(s) to change permissions for those modules." end end raise DtkError, errors unless errors.empty? end |
.module_ref_content(location) ⇒ Object
71 72 73 74 |
# File 'lib/util/remote_dependency_util.rb', line 71 def module_ref_content(location) abs_location = File.join(location, MODULE_REF_FILE) File.exists?(abs_location) ? File.read(abs_location) : nil end |
.print_dependency_warnings(response, success_msg = nil, opts = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/util/remote_dependency_util.rb', line 27 def print_dependency_warnings(response, success_msg = nil, opts = {}) are_there_warnings = false return are_there_warnings if response.nil? || response.data.nil? warnings = response.data['dependency_warnings'] if warnings && !warnings.empty? if opts[:ignore_permission_warnings] warnings.delete_if { |warning| warning['error_type'].eql?('no_permission') } return if warnings.empty? end print_out "Following warnings have been detected for current module by Repo Manager:\n" warnings.each { |w| print_out(" - #{w['message']}") } puts are_there_warnings = true end print_out success_msg, :green if success_msg are_there_warnings end |