Class: Orasaurus::SqlBuildGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/orasaurus/generator.rb

Instance Attribute Summary

Attributes inherited from Generator

#build_list, #name, #output_file_name, #output_path

Instance Method Summary collapse

Methods inherited from Generator

#full_output_file_name, #initialize

Constructor Details

This class inherits a constructor from Orasaurus::Generator

Instance Method Details

#generateObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/orasaurus/generator.rb', line 32

def generate
  
  if @build_list.empty? then
    puts "nothing in build list. no need for build file."
  else
    
    puts "processing erb for #{@build_list}"
  
    build_template = %q{
SET SERVEROUTPUT ON
SET DEFINE OFF
SPOOL <%=@output_file_name%>.log

PROMPT
PROMPT *****************************GETTING STARTED************************
PROMPT
/
BEGIN DBMS_OUTPUT.PUT_LINE( 'BEGIN TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
/

<% @build_list.each do |item| %>
PROMPT ***** <%= item %> *****
@<%= item %>;
SHOW ERRORS
<% end %>

BEGIN DBMS_OUTPUT.PUT_LINE( 'END TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
/
PROMPT
PROMPT *******************************FINISHED*******************************
PROMPT


EXIT
/
}		


    script_contents = ERB.new( build_template, nil, ">" ).result(binding)
    script_file = File.new( full_output_file_name, "w" )
    script_file.print( script_contents )
    puts "creating " + full_output_file_name
    script_file.close
  end
end