Module: PuppetX::EnterpriseModules::Oracle::ProcedureHandling

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

Overview

Module for handling Oracle procedure definitions.

This module provides methods to manage and process Oracle procedure definitions within Puppet.

Instance Method Summary collapse

Instance Method Details

#change_to_s(currentvalue, _newvalue) ⇒ String

Converts the current value to a string representation.

Parameters:

  • currentvalue (Object)

    The current value of the procedure.

  • _newvalue (Object)

    The new value (not used).

Returns:

  • (String)

    A message indicating the status of the procedure.



20
21
22
23
24
25
26
# File 'lib/puppet_x/enterprisemodules/oracle/procedure_handling.rb', line 20

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

#compilation_errorsInteger

Retrieves the compilation errors from the procedure.

Returns:

  • (Integer)

    The number of compilation errors found.



55
56
57
58
# File 'lib/puppet_x/enterprisemodules/oracle/procedure_handling.rb', line 55

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

#current_contentString

Retrieves the current content of the procedure definition.

Returns:

  • (String)

    The processed content of the procedure definition.



31
32
33
# File 'lib/puppet_x/enterprisemodules/oracle/procedure_handling.rb', line 31

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

#process_content(content) ⇒ String

Processes the content of the procedure definition.

Parameters:

  • content (String)

    The raw content of the procedure definition.

Returns:

  • (String)

    The cleaned and formatted content.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/puppet_x/enterprisemodules/oracle/procedure_handling.rb', line 39

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