Module: PuppetX::EnterpriseModules::Oracle::SourceFunctions
- Defined in:
- lib/puppet_x/enterprisemodules/oracle/source_functions.rb
Overview
This module provides functions to manage and compare Oracle source content.
It includes methods to check for errors, determine if the current content is in sync with the required content, and show differences between the two.
Instance Method Summary collapse
-
#contains_errors? ⇒ Boolean
Checks if there are any compilation errors.
-
#insync?(_is) ⇒ Boolean
Compares the current content with the required content to determine if they are in sync.
-
#show_diff(current_content, required_content) ⇒ Object
Shows the difference between current and required content.
Instance Method Details
#contains_errors? ⇒ Boolean
Checks if there are any compilation errors.
23 24 25 |
# File 'lib/puppet_x/enterprisemodules/oracle/source_functions.rb', line 23 def contains_errors? compilation_errors > 0 end |
#insync?(_is) ⇒ Boolean
Compares the current content with the required content to determine if they are in sync.
36 37 38 39 40 41 42 43 44 |
# File 'lib/puppet_x/enterprisemodules/oracle/source_functions.rb', line 36 def insync?(_is) if current_content == required_content Puppet.warning "#{path}: #{resource.owner}.#{resource.java_name} up-to-date, but contains #{compilation_errors} error(s)." \ if contains_errors? && resource.report_errors return true end show_diff(current_content, required_content) false end |
#show_diff(current_content, required_content) ⇒ Object
Shows the difference between current and required content.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet_x/enterprisemodules/oracle/source_functions.rb', line 50 def show_diff(current_content, required_content) # Use a single Tempfile for both contents to reduce overhead Tempfile.create(['ora_java_source', nil]) do |current_content_file| current_content_file.write(current_content) current_content_file.flush Tempfile.create(['ora_java_source', nil]) do |required_content_file| required_content_file.write(required_content) required_content_file.flush file_diff = `diff #{current_content_file.path} #{required_content_file.path}` Puppet.info "#{path}: Difference is:\n#{file_diff}" end end end |