Module: PuppetX::EnterpriseModules::Oracle::FunctionHandling

Defined in:
lib/puppet_x/enterprisemodules/oracle/function_handling.rb

Overview

This module handles Oracle function definitions and their processing.

Provides methods to manage and manipulate Oracle function definitions within Puppet configurations.

Instance Method Summary collapse

Instance Method Details

#change_to_s(currentvalue, _newvalue) ⇒ String

Converts the current value of a function definition to a string.

Parameters:

  • currentvalue (String)

    The current value of the function definition.

  • _newvalue (String)

    The new value (not used in this method).

Returns:

  • (String)

    A message indicating the status of the function definition.



22
23
24
25
26
27
28
# File 'lib/puppet_x/enterprisemodules/oracle/function_handling.rb', line 22

def change_to_s(currentvalue, _newvalue)
  if currentvalue.to_s == 'absent'
    'created function definition'
  else
    'changed to new function definition'
  end
end

#compilation_errorsInteger

Checks for compilation errors in the function definition.

Returns:

  • (Integer)

    The number of compilation errors found.



58
59
60
61
# File 'lib/puppet_x/enterprisemodules/oracle/function_handling.rb', line 58

def compilation_errors
  results = sql template('ora_config/ora_function/function_errors.sql.erb', binding), :sid => resource.sid
  results.first['ERRORS'].to_i
end

#current_contentString

Retrieves the current content of the function definition.

Returns:

  • (String)

    The processed content of the function definition.



33
34
35
# File 'lib/puppet_x/enterprisemodules/oracle/function_handling.rb', line 33

def current_content
  @current_content ||= process_content(sql(template('ora_config/ora_function/function_definition.sql.erb', binding), :sid => resource.sid, :parse => false))
end

#process_content(content) ⇒ String

Processes the content of the function definition by removing unnecessary characters and formatting it.

Parameters:

  • content (String)

    The raw content of the function definition.

Returns:

  • (String)

    The cleaned and formatted content.



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puppet_x/enterprisemodules/oracle/function_handling.rb', line 42

def process_content(content)
  new_content = content.gsub(/CONTENT\s*\n-*\s*\n/, '').
                gsub(/--.*\n/, '').
                gsub(%r{^/\s*$}, '').
                gsub(/\s|\s|"|'/, '').
                delete("\n").upcase
  if resource[:editionable].to_s == 'false'
    new_content.gsub(/(?:non)?editionable/i, '')
  else
    new_content
  end
end