orasaurus 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Orasaurus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/orasaurus.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Orasaurus::VERSION
8
8
  s.authors = ["Andy Campbell"]
9
9
  s.email = ["pmacydna@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/andycamp/orasaurus"
11
11
  s.summary = %q{Tools for building Oracle Applications}
12
12
  s.description = %q{A robust interface for building Oracle Applications, especially pl/sql.}
13
13
 
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # specify any dependencies here; for example:
23
23
  s.add_development_dependency "rspec"
24
- s.add_runtime_dependency "ruby-oci8"
25
- s.add_runtime_dependency "ruby-plsql"
24
+ #s.add_runtime_dependency "ruby-oci8"
25
+ #s.add_runtime_dependency "ruby-plsql"
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orasaurus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-22 00:00:00.000000000Z
12
+ date: 2011-10-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &9959040 !ruby/object:Gem::Requirement
16
+ requirement: &9977448 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,29 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *9959040
25
- - !ruby/object:Gem::Dependency
26
- name: ruby-oci8
27
- requirement: &9958788 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *9958788
36
- - !ruby/object:Gem::Dependency
37
- name: ruby-plsql
38
- requirement: &9958536 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *9958536
24
+ version_requirements: *9977448
47
25
  description: A robust interface for building Oracle Applications, especially pl/sql.
48
26
  email:
49
27
  - pmacydna@gmail.com
@@ -60,13 +38,6 @@ files:
60
38
  - lib/orasaurus.rb
61
39
  - lib/orasaurus/sql_script_builder.rb
62
40
  - lib/orasaurus/version.rb
63
- - notes/build_table_build_script.rb
64
- - notes/db_migrator.rb
65
- - notes/file_dependencies.rb
66
- - notes/main_db.rb
67
- - notes/rakefile.rb
68
- - notes/stractor.rb
69
- - notes/try_to_compile.rb
70
41
  - orasaurus.gemspec
71
42
  - spec/orasaurus_spec.rb
72
43
  - spec/spec_helper.rb
@@ -92,7 +63,7 @@ files:
92
63
  - test/db/build.sql
93
64
  - test/db/create_test_user.sql
94
65
  - test/db/teardown.sql
95
- homepage: ''
66
+ homepage: https://github.com/andycamp/orasaurus
96
67
  licenses: []
97
68
  post_install_message:
98
69
  rdoc_options: []
@@ -1,207 +0,0 @@
1
- require 'oci8'
2
- require 'erb'
3
-
4
- class TableScriptBuilder
5
-
6
- def initialize( db_user, db_password, db_name, output_path )
7
-
8
- @db_user = db_user
9
- @db_password = db_password
10
- @db_name = db_name
11
- @output_path = output_path
12
-
13
- puts "producing raw table list"
14
- @raw_table_list = get_table_list
15
- puts "raw table list count: " + @raw_table_list.length.to_s
16
- #puts @raw_table_list
17
-
18
- puts "producing ordered table list"
19
- @ordered_table_list = produce_ordered_list
20
- puts "ordered_table_list count: " + @ordered_table_list.length.to_s
21
- #puts @ordered_table_list
22
-
23
- puts "producing build script"
24
- @build_script = make_build_script
25
-
26
- puts "producing teardown script"
27
- @teardown_script = make_teardown_script
28
-
29
- end
30
-
31
- def get_table_list
32
-
33
- table_qry = %q{
34
- SELECT table_name
35
- FROM user_tables
36
- WHERE ( table_name LIKE 'FNS%' OR table_name LIKE 'FDR%' )
37
- }
38
-
39
- table_list = Array.new
40
-
41
- db_connection = OCI8.new( @db_user, @db_password, @db_name )
42
-
43
- db_connection.exec( table_qry ) do |row|
44
- table_list.push( row.first )
45
- end
46
-
47
- db_connection.logoff
48
-
49
- return table_list
50
-
51
- end
52
-
53
- def get_dependency_list(table_name)
54
-
55
- dependency_qry = %q{ select UNIQUE b.table_name dependent_table
56
- from user_constraints a
57
- join user_constraints b
58
- on a.r_constraint_name = b.constraint_name
59
- where a.constraint_type = 'R'
60
- and ( a.table_name LIKE 'FNS%'
61
- or a.table_name LIKE 'FDR%' )
62
- and a.table_name = :table_name
63
- order by b.table_name
64
- }
65
-
66
- dependency_list = Array.new
67
-
68
- db_connection = OCI8.new(@db_user, @db_password, @db_name)
69
-
70
- db_connection.exec(dependency_qry, table_name) do |row|
71
- dependency_list.push(row.first)
72
- end
73
-
74
- db_connection.logoff
75
-
76
- return dependency_list
77
-
78
- end
79
-
80
- def produce_ordered_list
81
-
82
- ordered_list = Array.new
83
- done_collecting = false
84
- loop_idx = 0
85
-
86
- while not done_collecting
87
-
88
- loop_idx += 1
89
-
90
- @raw_table_list.each{ |table|
91
-
92
- if not ordered_list.include?(table) then
93
-
94
- dependencies = get_dependency_list(table).sort
95
-
96
- if dependencies.length == 0 then
97
- ordered_list.push( table )
98
- else
99
- #this line of code is checking to see if all of the dependencies
100
- # for the table we are analyzing are already int the ordered_list
101
- matches = ordered_list.select{ |i| dependencies.include?(i) }
102
- matches = matches.sort
103
- if matches.eql?(dependencies)
104
- ordered_list.push( table )
105
- end
106
- end
107
- end
108
-
109
- }
110
-
111
- if ordered_list.sort.eql?(@raw_table_list.sort) then
112
- done_collecting = true
113
- puts "done colecting dependency matches. all tables have been collected and matched."
114
- end
115
-
116
- if loop_idx > 10
117
- done_collecting = true
118
- puts "giving up on finishing collecting"
119
- puts "difference (missing ones): "
120
- puts @raw_table_list - ordered_list
121
- end
122
-
123
- end
124
-
125
- return ordered_list
126
-
127
- end
128
-
129
- def make_build_script
130
- build_template = %q{
131
- SET SERVEROUTPUT ON
132
- SET DEFINE OFF
133
- SPOOL build.log
134
-
135
- PROMPT
136
- PROMPT *****************************GETTING STARTED************************
137
- PROMPT
138
- /
139
- BEGIN DBMS_OUTPUT.PUT_LINE( 'BEGIN TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
140
- /
141
-
142
- <% @ordered_table_list.each do |item| %>
143
- PROMPT
144
- PROMPT ***** <%= item %> ******
145
- PROMPT
146
- @<%= item %>;
147
-
148
- <% end %>
149
-
150
- BEGIN DBMS_OUTPUT.PUT_LINE( 'END TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
151
- /
152
- PROMPT
153
- PROMPT *******************************FINISHED*******************************
154
- PROMPT
155
-
156
-
157
- EXIT
158
- /
159
- }
160
-
161
-
162
- script_contents = ERB.new( build_template, nil, ">" ).result(binding)
163
- script_file = File.new( @output_path + "build.sql", "w" )
164
- script_file.print( script_contents )
165
-
166
- end
167
-
168
- def make_teardown_script
169
-
170
- teardown_template = %q{
171
- SET SERVEROUTPUT ON
172
- SET DEFINE OFF
173
- SPOOL teardown.log
174
-
175
- PROMPT
176
- PROMPT *****************************GETTING STARTED************************
177
- PROMPT
178
- /
179
- BEGIN DBMS_OUTPUT.PUT_LINE( 'BEGIN TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
180
- /
181
-
182
- <% @ordered_table_list.reverse.each do |item| %>
183
- PROMPT
184
- PROMPT <%= item + "\n" %>
185
- PROMPT
186
- DROP TABLE <%= item %> CASCADE CONSTRAINTS;
187
- <% end %>
188
-
189
- BEGIN DBMS_OUTPUT.PUT_LINE( 'END TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
190
- /
191
- PROMPT
192
- PROMPT *******************************FINISHED*******************************
193
- PROMPT
194
-
195
-
196
- EXIT
197
- /
198
- }
199
-
200
-
201
- script_contents = ERB.new( teardown_template, nil, ">" ).result(binding)
202
- script_file = File.new( @output_path + "teardown.sql", "w" )
203
- script_file.print( script_contents )
204
-
205
- end
206
-
207
- end
data/notes/db_migrator.rb DELETED
@@ -1,115 +0,0 @@
1
- require "find"
2
- require "fileutils"
3
- require "highline/import"
4
- require "oci8"
5
-
6
- class DbMigrator
7
-
8
- @migration_directory
9
- @current_db_version
10
- @db_name
11
- @db_user
12
- @db_user_password
13
-
14
- def initialize( migration_directory, db_name, db_user, db_user_password )
15
- @migration_directory = migration_directory
16
- @db_name = db_name
17
- @db_user = db_user
18
- @db_user_password = db_user_password
19
- puts "Initializing database migrator"
20
- @current_db_version = get_current_db_version
21
- end
22
-
23
- def get_current_db_version
24
- current_version = 0
25
- begin
26
- conn = OCI8.new( $db_user, $db_user_password, $db_name )
27
- cursor = conn.exec( 'select value from tbparameters where system = \'FNS\' AND key = \'DB_VERSION\'' )
28
- current_version = cursor.fetch.first.to_i
29
- conn.logoff
30
- rescue
31
- puts "Error getting current db version from the database: #{ $! }"
32
- continue = ask( "The database version cannot be retrieved from the database. Would you like to continue?" ){ |q| q.echo = true }
33
- #if response begins with y
34
- if continue =~ /y/i then
35
- current_version = ask( "What is the current version number of the database (migrations that are greater than this number will be run)?", Integer ){ |q| q.echo = true }
36
- else
37
- puts "Exiting immediately. No database migrations will be run"
38
- exit
39
- end
40
- end
41
- return current_version
42
- end
43
-
44
- def set_db_version( version_no )
45
- begin
46
- conn = OCI8.new( $db_user, $db_user_password, $db_name )
47
- rows_updated = conn.exec( 'update tbparameters set value = :version_no where system = \'FNS\' AND key = \'DB_VERSION\'', version_no )
48
- if rows_updated == 1
49
- conn.commit
50
- else
51
- conn.rollback
52
- "#{ rows_updated } when 1 row was expected."
53
- end
54
- conn.logoff
55
- puts "new db_version set #{ version_no }"
56
- rescue
57
- puts "Error setting db version #{ $! }"
58
- puts "THE DATABASE WAS NOT UPDATED WITH THE LATEST VERSION NUMBER: #{ version_no }"
59
- end
60
- end
61
-
62
- def pluck_version_no( the_path )
63
- path_syllables = the_path.split( "_" )
64
- version_no = 0
65
- path_syllables.each do |syllable|
66
- #look for the first syllable that has no characters in it
67
- #the first integer syllable
68
- if not syllable =~ /\D/ then
69
- version_no = syllable.to_i
70
- break
71
- end
72
- end
73
- return version_no
74
- end
75
-
76
- def migratable_path?( the_path )
77
- if pluck_version_no( the_path ) > @current_db_version then
78
- return true
79
- else
80
- return false
81
- end
82
- end
83
-
84
- def migrate
85
-
86
- puts "beginning migration process..."
87
- puts @migration_directory
88
- puts "collecting files to migrate"
89
- migration_paths = Array.new
90
- Find.find(@migration_directory) do |path|
91
- if FileTest.file?(path) and path.match(/migration_\d.*sql/) and not path.match( /\.svn/ ) and migratable_path?(path)
92
- print "."
93
- migration_paths.push( path )
94
- end
95
- end
96
- #sort paths
97
- migration_paths = migration_paths.sort
98
-
99
- if migration_paths.length > 0 then
100
- migration_paths.each do |path|
101
- puts "sqlplus #{ $db_user }//#{ $db_user_password }@#{ $db_name } @#{ path }"
102
- end
103
- #capture last migration number
104
- final_db_version = pluck_version_no( migration_paths.last )
105
- puts "final db version #{ final_db_version }"
106
- #set database to version
107
- set_db_version( final_db_version )
108
- else
109
- puts "database is current"
110
- end
111
-
112
- end
113
-
114
- end
115
-
@@ -1,65 +0,0 @@
1
- class DependencyAnalyzer
2
-
3
- def initialize(directory)
4
- p "Analyzing " + directory
5
- @search_directory
6
- end
7
-
8
- def get_file_list
9
-
10
- end
11
-
12
- def get_dependency_list(file_name)
13
-
14
-
15
- end
16
-
17
- def produce_ordered_list
18
-
19
- ordered_list = Array.new
20
- done_collecting = false
21
- loop_idx = 0
22
-
23
- while not done_collecting
24
-
25
- loop_idx += 1
26
-
27
- @raw_table_list.each{ |table|
28
-
29
- if not ordered_list.include?(table) then
30
-
31
- dependencies = get_dependency_list(table).sort
32
-
33
- if dependencies.length == 0 then
34
- ordered_list.push( table )
35
- else
36
- #this line of code is checking to see if all of the dependencies
37
- # for the table we are analyzing are already int the ordered_list
38
- matches = ordered_list.select{ |i| dependencies.include?(i) }
39
- matches = matches.sort
40
- if matches.eql?(dependencies)
41
- ordered_list.push( table )
42
- end
43
- end
44
- end
45
-
46
- }
47
-
48
- if ordered_list.sort.eql?(@raw_table_list.sort) then
49
- done_collecting = true
50
- puts "done colecting dependency matches. all tables have been collected and matched."
51
- end
52
-
53
- if loop_idx > 10
54
- done_collecting = true
55
- puts "giving up on finishing collecting"
56
- puts "difference (missing ones): "
57
- puts @raw_table_list - ordered_list
58
- end
59
-
60
- end
61
-
62
- return ordered_list
63
-
64
- end
65
-
data/notes/main_db.rb DELETED
@@ -1,130 +0,0 @@
1
- #ruby classes
2
- require "oci8"
3
- require "erb"
4
- require "find"
5
- require "logger"
6
-
7
- #local classes
8
- require "lib/DB_Table.rb"
9
- require "lib/PLSQLGen.rb"
10
-
11
- my_plsql_gen = PLSQLGen.new()
12
- params = my_plsql_gen.load_properties( "conf/PLSQLGen.conf" )
13
-
14
- $system_column_names = ["CREATE_DATE", "CREATE_USER", "CREATE_PGM", "UPDATE_DATE", "UPDATE_USER", "UPDATE_PGM"]
15
- $system_column_defaults = Hash.new
16
- $system_column_defaults[ "CREATE_DATE" ] = "SYSDATE"
17
- $system_column_defaults[ "CREATE_USER" ] = "USER"
18
- $system_column_defaults[ "CREATE_PGM" ] = "g_pkgName"
19
- $system_column_defaults[ "UPDATE_DATE" ] = "SYSDATE"
20
- $system_column_defaults[ "UPDATE_USER" ] = "USER"
21
- $system_column_defaults[ "UPDATE_PGM" ] = "g_pkgName"
22
-
23
- #oracle stuff
24
- conn = OCI8.new( params['db_user'], params['db_password'], params['db_name'])
25
- tableList = Array.new
26
- params['tables'].split( ',' ).each{ |s| tableList.push( conn.describe_table( s.strip ) ) }
27
-
28
-
29
- pkg_names = Array.new()
30
- app_abbr = params[ 'app_abbr' ]
31
- app_name = params[ 'app_name' ]
32
-
33
- logger = Logger.new( params[ 'log_path' ] + ".log", 'weekly')
34
- logger.info('main') { "begin" }
35
- puts "begin"
36
-
37
- tableList.each { |tbl|
38
-
39
- logger.info('main') { "working with " + tbl.obj_name }
40
-
41
- $table = tbl
42
- $updatable_cols = Array.new
43
- tbl.columns.each{ |c| $updatable_cols.push( c ) unless $system_column_names.include?( c.name.upcase ) }
44
- #collect package name
45
- pkg_names.push( "pkg_" + $table.obj_name.downcase + params["pkg_name_suffix"] )
46
- #process spec
47
- begin
48
- my_plsql_gen.erb_to_file( my_plsql_gen.file_to_string( File.open( params[ 'spec_template' ], "r" )) \
49
- ,params[ 'destination_path' ] + pkg_names.last + ".pkg")
50
- logger.info('main') { "creating spec " + pkg_names.last+".pkg" }
51
- puts "package created " + pkg_names.last+".pkg"
52
- rescue
53
- logger.error( 'main' ){"error processing spec for " + pkg_names.last }
54
- puts "There was a problem processing the spec for " + pkg_names.last
55
- puts $!
56
- end
57
-
58
- =begin
59
- #process body
60
- begin
61
- my_plsql_gen.erb_to_file(my_plsql_gen.file_to_string(File.open(params['body_template'],"r")) \
62
- ,params[ 'destination_path' ] + pkg_names.last+".pkb")
63
- logger.info('main') { "creating body " + pkg_names.last+".pkb" }
64
- puts "creating body " + pkg_names.last+".pkb"
65
- rescue
66
- logger.error( 'main' ){"error processing body for " + pkg_names.last }
67
- puts "There was a problem processing the body for " + pkg_names.last
68
- puts $!
69
- end
70
- logger.info('main') { "package creation complete" }
71
- =end
72
- }
73
-
74
- =begin
75
-
76
- #make home page
77
- if params.has_key?('include_home') \
78
- and params['include_home'] = 'YES' then
79
- #collect package name
80
- pkg_name.push("pkg_" + app_abbr.downcase + "_home")
81
-
82
- #making spec
83
- begin
84
- my_plsql_gen.erb_to_file( my_plsql_gen.file_to_string( File.open( params[ 'home_spec_template' ], "r" ) ) \
85
- , params[ 'destination_path' ] + pkg_name.last+".pks" )
86
- logger.info('main') { "creating spec " + pkg_name.last+".pks" }
87
- puts "creating spec " + pkg_name.last+".pks"
88
- rescue
89
- logger.error( 'main' ){"error processing body for " + pkg_name.last }
90
- puts "There was a problem processing the body for " + pkg_name.last
91
- puts $!
92
- end
93
-
94
- #making body
95
- begin
96
- my_plsql_gen.erb_to_file( my_plsql_gen.file_to_string( File.open( params[ 'home_body_template' ], "r" ) ) \
97
- , params[ 'destination_path' ] + pkg_name.last+".pkb")
98
- logger.info('main') { "creating body " + pkg_name.last }
99
- puts "creating body " + pkg_name.last
100
- rescue
101
- logger.error( 'main' ){"error processing body for " + pkg_name.last }
102
- puts "There was a problem processing the body for " + pkg_name.last
103
- puts $!
104
- end
105
-
106
- end
107
- logger.info('main') { "home page create" }
108
-
109
- #make db script
110
- if params.has_key?('include_db_script') \
111
- and params['include_db_script'] = 'YES' then
112
- role_name = params['role_name']
113
- begin
114
- #making grant script
115
- my_plsql_gen.erb_to_file( my_plsql_gen.file_to_string( File.open( params[ 'db_script_template' ], "r" ) ) \
116
- , params[ 'destination_path' ] + app_abbr.downcase + "_db_script.sql" )
117
- logger.info('main') { "db script created" }
118
- puts "db script created "
119
- rescue
120
- logger.error( 'main' ){"error creating db script" + pkg_name.last }
121
- puts "There was a problem processing the db script"
122
- puts $!
123
- end
124
- end
125
- =end
126
- logger.info('main') { "end" }
127
- logger.close
128
- conn.logoff
129
-
130
- puts "finished"
data/notes/rakefile.rb DELETED
@@ -1,375 +0,0 @@
1
- #this is a build or make file written in ruby
2
-
3
- require "oci8"
4
- require "fileutils"
5
- require "highline/import"
6
-
7
- $db_name = ""
8
- $db_user = ""
9
- $db_user_password = ""
10
-
11
- def print_response
12
- if $? == 0 then
13
- puts "completed successfully"
14
- else
15
- puts( "command failure" )
16
- end
17
- end
18
-
19
- def process_db_connect_params
20
-
21
- if ENV['db_user'].nil? then
22
- $db_user = ask("Database User: ") { |q| q.echo = true }
23
- else
24
- $db_user = ENV['db_user']
25
- end
26
-
27
- if ENV['db_user_password'].nil? then
28
- $db_user_password = ask("Database User Password: ") { |q| q.echo = "*" }
29
- else
30
- $db_user_password = ENV['db_user_password']
31
- end
32
-
33
- if ENV['db_name'].nil? then
34
- $db_name = ask("Database Instance: ") { |q| q.echo = true }
35
- else
36
- $db_name = ENV['db_name']
37
- end
38
-
39
- if not $db_user.nil? and not $db_user_password.nil? and not $db_name.nil? then
40
- return true
41
- else
42
- puts "INVALID DATABASE CONNECTION PARAMETERS"
43
- end
44
-
45
- end
46
-
47
- def sqlplus_connect_string
48
- return $db_user + "/" + $db_user_password + "@" + $db_name
49
- end
50
-
51
- desc "Test database connection"
52
- task :test_connection do
53
- if not process_db_connect_params then
54
- exit
55
- puts "test failed"
56
- else
57
- puts "valid parameters"
58
- end
59
- puts "Starting database connection test"
60
- begin
61
- conn = OCI8.new( $db_user, $db_user_password, $db_name )
62
- conn.logoff
63
- puts "Connection successful"
64
- rescue
65
- puts $!
66
- puts "Connection failed"
67
- end
68
- end
69
-
70
- desc "Rebuild all build and teardown scripts"
71
- task :rebuild_build_scripts do
72
- if not process_db_connect_params then
73
- exit
74
- end
75
-
76
- s = ScriptBuilder.new( '.' )
77
- puts "building simple build scripts"
78
- s.build_all_scripts( 'build.sql', 'teardown.sql' )
79
-
80
- puts "re-doing table build scripts for proper order"
81
- t = TableScriptBuilder.new( $db_user, $db_user_password, $db_name, './Tables/' )
82
- puts 'build_tables has finished'
83
-
84
- puts 'done'
85
- end
86
-
87
- =begin
88
- desc "logs in as system and creates application schema user and issues all necessary grants"
89
- task :do_grants do
90
- #check for args
91
- if not process_db_connect_params then
92
- exit
93
- end
94
-
95
- # call script
96
- sqlplus_cmd = "cd BuildScripts\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @grants.sql"
97
- system "cd BuildScripts"
98
- system sqlplus_cmd
99
- system "cd .."
100
- #print response
101
- print_response
102
-
103
- end
104
- =end
105
-
106
- desc "runs table build script"
107
- task :build_tables do
108
- puts "building tables"
109
- if not process_db_connect_params then
110
- exit
111
- end
112
- # call script
113
- sqlplus_cmd = "cd tables\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
114
- system sqlplus_cmd
115
- print_response
116
- end
117
-
118
- desc "runs table teardown script"
119
- task :teardown_tables do
120
- puts "teardown tables"
121
- if not process_db_connect_params then
122
- exit
123
- end
124
- # call script
125
- sqlplus_cmd = "cd tables\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
126
- system sqlplus_cmd
127
- print_response
128
- end
129
-
130
- desc "runs table teardown, then table build script"
131
- task :rebuild_tables => [:teardown_tables,:build_tables] do
132
- puts "rebuild complete"
133
- end
134
-
135
- desc "runs view build script"
136
- task :build_views do
137
- puts "building views"
138
- if not process_db_connect_params then
139
- exit
140
- end
141
- # call script
142
- sqlplus_cmd = "cd views\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
143
- system sqlplus_cmd
144
- print_response
145
- end
146
-
147
- desc "runs view teardown script"
148
- task :teardown_views do
149
- puts "teardown views"
150
- if not process_db_connect_params then
151
- exit
152
- end
153
- # call script
154
- sqlplus_cmd = "cd views\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
155
- system sqlplus_cmd
156
- print_response
157
- end
158
-
159
- desc "runs view teardown, then view build script"
160
- task :rebuild_views => [:teardown_views,:build_views] do
161
- puts "rebuild complete"
162
- end
163
-
164
- desc "runs sequence build script"
165
- task :build_sequences do
166
- puts "building sequences"
167
- if not process_db_connect_params then
168
- exit
169
- end
170
- # call script
171
- sqlplus_cmd = "cd bin\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @rebuild_all_sequences.sql"
172
- puts sqlplus_cmd
173
- system sqlplus_cmd
174
- print_response
175
- end
176
-
177
- desc "runs sequence teardown script"
178
- task :teardown_sequences do
179
- puts "tearing down sequences"
180
- if not process_db_connect_params then
181
- exit
182
- end
183
- # call script
184
- sqlplus_cmd = "cd sequences\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
185
- system sqlplus_cmd
186
- print_response
187
- end
188
-
189
- desc "runs sequence teardown then sequence build scripts"
190
- task :rebuild_sequences => [:build_sequences] do
191
- puts "rebuild complete"
192
- end
193
-
194
- desc "runs package model build script"
195
- task :build_models do
196
- puts "building models"
197
- if not process_db_connect_params then
198
- exit
199
- end
200
- # call script
201
- sqlplus_cmd = "cd packages\\models && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
202
- system sqlplus_cmd
203
- print_response
204
- end
205
-
206
- desc "runs package model teardown script"
207
- task :teardown_models do
208
- puts "tearing down models"
209
- if not process_db_connect_params then
210
- exit
211
- end
212
- # call script
213
- sqlplus_cmd = "cd packages\\models && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
214
- system sqlplus_cmd
215
- print_response
216
- end
217
-
218
- desc "runs package model teardown then build scripts"
219
- task :rebuild_models => [:teardown_models, :build_models] do
220
- puts "rebuild complete"
221
- end
222
-
223
- desc "build controller packages"
224
- task :build_controllers do
225
- puts "building controllers"
226
- if not process_db_connect_params then
227
- exit
228
- end
229
- # call script
230
- sqlplus_cmd = "cd packages\\controllers && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
231
- system sqlplus_cmd
232
- print_response
233
- end
234
-
235
- desc "teardown controller packages"
236
- task :teardown_controllers do
237
- puts "tearing down controllers"
238
- if not process_db_connect_params then
239
- exit
240
- end
241
- # call script
242
- sqlplus_cmd = "cd packages\\controllers && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
243
- system sqlplus_cmd
244
- print_response
245
- end
246
-
247
- desc "teardown then rebuild all controllers"
248
- task :rebuild_controllers => [:teardown_controllers, :build_controllers] do
249
- puts "rebuild complete"
250
- end
251
-
252
- desc "build helper packages"
253
- task :build_helpers do
254
- puts "building helpers"
255
- if not process_db_connect_params then
256
- exit
257
- end
258
- # call script
259
- sqlplus_cmd = "cd packages\\helpers && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
260
- system sqlplus_cmd
261
- print_response
262
- end
263
-
264
- desc "teardown helper packages"
265
- task :teardown_helpers do
266
- puts "tearing down helpers"
267
- if not process_db_connect_params then
268
- exit
269
- end
270
- # call script
271
- sqlplus_cmd = "cd packages\\helpers && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
272
- system sqlplus_cmd
273
- print_response
274
- end
275
-
276
- desc "teardown then build helper packages"
277
- task :rebuild_helpers => [:teardown_helpers, :build_helpers] do
278
- puts "rebuild complete"
279
- end
280
-
281
- desc "build view packages"
282
- task :build_pkg_views do
283
- puts "building views"
284
- if not process_db_connect_params then
285
- exit
286
- end
287
- # call script
288
- sqlplus_cmd = "cd packages\\views && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
289
- system sqlplus_cmd
290
- print_response
291
- end
292
-
293
- desc "teardown view packages"
294
- task :teardown_pkg_views do
295
- puts "tearing down views"
296
- if not process_db_connect_params then
297
- exit
298
- end
299
- # call script
300
- sqlplus_cmd = "cd packages\\views && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @teardown.sql"
301
- system sqlplus_cmd
302
- print_response
303
- end
304
-
305
- desc "teardown then build view packages"
306
- task :rebuild_pkg_views => [:teardown_pkg_views, :build_pkg_views] do
307
- puts "rebuild complete"
308
- end
309
-
310
- desc "teardown all packages"
311
- task :teardown_packages => [:teardown_controllers, :teardown_views, :teardown_helpers, :teardown_models] do
312
- puts "teardown complete"
313
- end
314
-
315
- desc "build all packages"
316
- task :build_packages => [:build_models, :build_helpers, :build_pkg_views, :build_controllers] do
317
- puts "package build complete"
318
- end
319
-
320
- desc "teardown and build all packages"
321
- task :rebuild_packages => [:teardown_packages, :build_packages] do
322
- puts "rebuild complete"
323
- end
324
-
325
- desc "teardown the whole app...DANGEROUS!!!! BE CAREFUL RUNNING THIS ONE"
326
- task :teardown_app => [:teardown_packages, :teardown_views, :teardown_sequences, :teardown_tables] do
327
- puts "application teardown complete"
328
- end
329
-
330
- desc "builds the application from the ground up"
331
- task :build_app => [:build_tables, :build_sequences, :build_views, :build_packages] do
332
- puts "application build complete"
333
- end
334
-
335
- desc "teardown the rebuild the appliction from the ground up...DANGEROUS!!! you will lose all data if you run this script"
336
- task :rebuild_app => [:teardown_app, :build_app] do
337
- puts "application rebuild complete"
338
- puts Time.now.to_s
339
- end
340
-
341
- desc "teardown the rebuild the appliction from the ground up...DANGEROUS!!! you will lose all data if you run this script"
342
- task :rebuild_app => [:teardown_app, :build_app] do
343
- puts "application rebuild complete"
344
- puts Time.now.to_s
345
- end
346
-
347
- desc "run database migrations"
348
- task :run_db_migrations do
349
- puts "running database migrations"
350
- if not process_db_connect_params then
351
- exit
352
- end
353
- mig = DbMigrator.new( "Migrations", $db_name, $db_user, $db_user_password )
354
- mig.migrate
355
- puts "done runing database migrations"
356
- end
357
-
358
- desc "runs trigger build script"
359
- task :build_triggers do
360
- puts "building triggers"
361
- if not process_db_connect_params then
362
- exit
363
- end
364
- # call script
365
- sqlplus_cmd = "cd triggers\\ && sqlplus " + $db_user + "/" + $db_user_password + "@" + $db_name + " @build.sql"
366
- system sqlplus_cmd
367
- print_response
368
- end
369
-
370
- desc "lines of code"
371
- task :lines_of_code do
372
- puts "Generating lines of code report"
373
- system "cd bin && lines_of_code.rb"
374
- end
375
-
data/notes/stractor.rb DELETED
@@ -1,41 +0,0 @@
1
- require 'oci8'
2
-
3
- class Stractor
4
-
5
- def initialize( db_user, db_password, db_name )
6
-
7
- @db_user = db_user
8
- @db_password = db_password
9
- @db_name = db_name
10
-
11
- end
12
-
13
- def extract_ddl( object_type, object_name )
14
-
15
- ddl_sql = %q{
16
- SELECT dbms_metadata.get_ddl( :object_type, :object_name ) ddl_clob FROM dual
17
- }
18
-
19
- db_connection = OCI8.new( @db_user, @db_password, @db_name )
20
-
21
- ddl = ""
22
-
23
- db_connection.exec( ddl_sql, object_type, object_name ) do |result|
24
- ddl << result[0].read
25
- end
26
-
27
- db_connection.logoff
28
-
29
- return ddl.delete( 34.chr ).gsub( Regexp.new( @db_user << '\.' ), '' ).strip << ";"
30
-
31
- end
32
-
33
- def extract_into_file( object_type, object_name, file_name )
34
-
35
- ddl = extract_ddl( object_type, object_name )
36
- File.open(file_name, 'w') {|f| f.write( ddl )}
37
-
38
- end
39
-
40
- end
41
-
@@ -1,28 +0,0 @@
1
- require 'oci8'
2
-
3
-
4
- f2k = OCI8.new("junk", "password", "xe")
5
-
6
- puts "effin' eh"
7
-
8
- pkg = File.open( 'pkg_fdr_bridges.pks' )
9
-
10
- #f = f2k.exec( "#{ pkg.read }; " )
11
-
12
- #puts f.to_s
13
-
14
- #puts f2k.exec( "SHOW ERRORS" )
15
-
16
- error_cursor = f2k.exec( "SELECT * FROM USER_ERRORS" )
17
-
18
- while r = error_cursor.fetch_hash()
19
- puts r.to_s
20
- end
21
-
22
- # errors = .fetch_hash()
23
-
24
- puts errors.to_s
25
-
26
- puts "done"
27
-
28
- f2k.logoff