orasaurus 0.0.2 → 0.0.3

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.
data/bin/orasaurus CHANGED
@@ -1,4 +1,30 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'thor'
2
3
  require File.dirname(__FILE__) + '/../lib/orasaurus.rb'
3
4
 
4
- Orasaurus(ARGV)
5
+ class OraThauruth < Thor
6
+
7
+ include Thor::Actions
8
+
9
+ map "-v" => :version
10
+ map "-h" => :help
11
+
12
+ desc "generate_build_scripts", "generate mysql build scripts for a directory."
13
+ method_options :build_script_name => :string, :teardown_script_name => :string
14
+ def generate_build_scripts
15
+ build_script_name = options[:build_script_name]||"build.sql"
16
+ teardown_script_name = options[:teardown_script_name]||"teardown.sql"
17
+
18
+ say "generating build scripts"
19
+ s = Orasaurus::ScriptBuilder.new( '.' )
20
+ s.build_all_scripts( build_script_name, teardown_script_name )
21
+ end
22
+
23
+ desc "version", "Currently installed version of Orasaurus."
24
+ def version
25
+ puts "Orasarus v"+Orasaurus::VERSION
26
+ end
27
+
28
+ end
29
+
30
+ OraThauruth.start
@@ -0,0 +1,17 @@
1
+ require 'highline'
2
+
3
+ module Orasaurus
4
+
5
+ module Cli
6
+
7
+ def process_db_connect_params(db_name, db_user, db_password)
8
+ params = Hash.new
9
+ params[:db_name] = db_name||ask("Database Name? ") { |q| q.echo = true }
10
+ params[:db_user] = db_user||ask("Database User? ") { |q| q.echo = true }
11
+ params[:db_password] = db_password||ask("Database Password? ") { |q| q.echo = true }
12
+ return params
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Orasaurus
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/orasaurus.rb CHANGED
@@ -10,3 +10,5 @@ module Orasaurus
10
10
  end
11
11
 
12
12
  require 'orasaurus/sql_script_builder'
13
+ require 'orasaurus/version'
14
+ require 'orasaurus/cli'
data/orasaurus.gemspec CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
6
6
  s.name = "orasaurus"
7
7
  s.version = Orasaurus::VERSION
8
8
  s.authors = ["Andy Campbell"]
9
- s.email = ["pmacydna@gmail.com"]
9
+ s.email = ["andrewthomascampbell@gmail.com"]
10
10
  s.homepage = "https://github.com/andycamp/orasaurus"
11
11
  s.summary = %q{Tools for building Oracle Applications}
12
- s.description = %q{A robust interface for building Oracle Applications, especially pl/sql.}
12
+ s.description = %q{A simple toolset for making it easier to build Oracle databases.}
13
13
 
14
14
  s.rubyforge_project = "orasaurus"
15
15
 
@@ -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 "thor"
25
+ s.add_runtime_dependency "highline"
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.2
4
+ version: 0.0.3
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-24 00:00:00.000000000Z
12
+ date: 2011-10-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &9977448 !ruby/object:Gem::Requirement
16
+ requirement: &9916668 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,32 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *9977448
25
- description: A robust interface for building Oracle Applications, especially pl/sql.
24
+ version_requirements: *9916668
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &9916344 !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: *9916344
36
+ - !ruby/object:Gem::Dependency
37
+ name: highline
38
+ requirement: &9916056 !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: *9916056
47
+ description: A simple toolset for making it easier to build Oracle databases.
26
48
  email:
27
- - pmacydna@gmail.com
49
+ - andrewthomascampbell@gmail.com
28
50
  executables:
29
51
  - orasaurus
30
52
  extensions: []
@@ -36,33 +58,12 @@ files:
36
58
  - Rakefile
37
59
  - bin/orasaurus
38
60
  - lib/orasaurus.rb
61
+ - lib/orasaurus/cli.rb
39
62
  - lib/orasaurus/sql_script_builder.rb
40
63
  - lib/orasaurus/version.rb
41
64
  - orasaurus.gemspec
42
65
  - spec/orasaurus_spec.rb
43
66
  - spec/spec_helper.rb
44
- - test/db/Notes/Packages/build.sql
45
- - test/db/Notes/Packages/pkg_note_comments.pkg
46
- - test/db/Notes/Packages/pkg_note_tags.pkg
47
- - test/db/Notes/Packages/pkg_notebooks.pkg
48
- - test/db/Notes/Packages/pkg_notes.pkg
49
- - test/db/Notes/Packages/teardown.sql
50
- - test/db/Notes/Sequences/build.sql
51
- - test/db/Notes/Sequences/note_comments_seq.sql
52
- - test/db/Notes/Sequences/note_tags_seq.sql
53
- - test/db/Notes/Sequences/notebooks_seq.sql
54
- - test/db/Notes/Sequences/notes_seq.sql
55
- - test/db/Notes/Sequences/teardown.sql
56
- - test/db/Notes/Tables/build.sql
57
- - test/db/Notes/Tables/note_comments.sql
58
- - test/db/Notes/Tables/note_tags.sql
59
- - test/db/Notes/Tables/notebooks.sql
60
- - test/db/Notes/Tables/notes.sql
61
- - test/db/Notes/Tables/teardown.sql
62
- - test/db/Rakefile
63
- - test/db/build.sql
64
- - test/db/create_test_user.sql
65
- - test/db/teardown.sql
66
67
  homepage: https://github.com/andycamp/orasaurus
67
68
  licenses: []
68
69
  post_install_message:
@@ -1,35 +0,0 @@
1
-
2
- SET SERVEROUTPUT ON
3
- SET DEFINE OFF
4
- SPOOL build.log
5
-
6
- PROMPT
7
- PROMPT *****************************GETTING STARTED************************
8
- PROMPT
9
- /
10
- BEGIN DBMS_OUTPUT.PUT_LINE( 'BEGIN TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
11
- /
12
-
13
- PROMPT ***** pkg_note_comments.pkg *****
14
- @pkg_note_comments.pkg;
15
- SHOW ERRORS
16
- PROMPT ***** pkg_note_tags.pkg *****
17
- @pkg_note_tags.pkg;
18
- SHOW ERRORS
19
- PROMPT ***** pkg_notebooks.pkg *****
20
- @pkg_notebooks.pkg;
21
- SHOW ERRORS
22
- PROMPT ***** pkg_notes.pkg *****
23
- @pkg_notes.pkg;
24
- SHOW ERRORS
25
-
26
- BEGIN DBMS_OUTPUT.PUT_LINE( 'END TIME: '||TO_CHAR( SYSDATE, 'MM/DD/YYYY HH:MI:SS' ) ); END;
27
- /
28
- PROMPT
29
- PROMPT *******************************FINISHED*******************************
30
- PROMPT
31
-
32
-
33
- EXIT
34
- /
35
-
@@ -1,164 +0,0 @@
1
- /*<TOAD_FILE_CHUNK>*/
2
- CREATE OR REPLACE PACKAGE pkg_note_comments
3
- IS
4
-
5
- TYPE note_comments_tab
6
- IS TABLE OF note_comments%ROWTYPE
7
- INDEX BY BINARY_INTEGER;
8
-
9
- empty_tab note_comments_tab;
10
-
11
- FUNCTION f_get
12
- ( the_id note_comments.id%TYPE )
13
- RETURN note_comments%ROWTYPE;
14
-
15
- FUNCTION f_get_comments
16
- ( the_note_id IN note_comments.note_id%TYPE )
17
- RETURN note_comments_tab;
18
-
19
- PROCEDURE p_create
20
- ( the_note_id IN note_comments.note_id%TYPE
21
- , the_text IN note_comments.text%TYPE );
22
-
23
- PROCEDURE p_update
24
- ( the_id IN note_comments.id%TYPE
25
- , the_note_id IN note_comments.note_id%TYPE
26
- , the_text IN note_comments.text%TYPE );
27
-
28
- PROCEDURE p_save
29
- ( the_comment IN note_comments%ROWTYPE );
30
-
31
- PROCEDURE p_save
32
- ( the_comments IN note_comments_tab );
33
-
34
- PROCEDURE p_delete
35
- ( the_id IN note_comments.id%TYPE );
36
-
37
- END;
38
-
39
- /
40
- /*<TOAD_FILE_CHUNK>*/
41
-
42
- CREATE OR REPLACE PACKAGE BODY pkg_note_comments
43
- IS
44
-
45
- FUNCTION f_get
46
- ( the_id note_comments.id%TYPE )
47
- RETURN note_comments%ROWTYPE
48
- IS
49
- return_rec note_comments%ROWTYPE;
50
- BEGIN
51
-
52
- SELECT *
53
- INTO return_rec
54
- FROM note_comments
55
- WHERE id = the_id;
56
-
57
- RETURN return_rec;
58
-
59
- END;
60
-
61
- FUNCTION f_get_comments
62
- ( the_note_id IN note_comments.note_id%TYPE )
63
- RETURN note_comments_tab
64
- IS
65
- return_tab note_comments_tab;
66
- BEGIN
67
-
68
- SELECT *
69
- BULK COLLECT INTO return_tab
70
- FROM note_comments
71
- WHERE note_id = the_note_id
72
- ORDER BY created_at;
73
-
74
- RETURN return_tab;
75
-
76
- END;
77
-
78
- PROCEDURE p_create
79
- ( the_note_id IN note_comments.note_id%TYPE
80
- , the_text IN note_comments.text%TYPE )
81
- IS
82
- BEGIN
83
-
84
- INSERT INTO note_comments
85
- ( id
86
- , note_id
87
- , text
88
- , created_at
89
- , created_by
90
- , updated_at
91
- , updated_by )
92
- VALUES
93
- ( note_comments_seq.nextval
94
- , the_note_id
95
- , the_text
96
- , SYSDATE
97
- , USER
98
- , SYSDATE
99
- , USER );
100
-
101
- END;
102
-
103
- PROCEDURE p_update
104
- ( the_id IN note_comments.id%TYPE
105
- , the_note_id IN note_comments.note_id%TYPE
106
- , the_text IN note_comments.text%TYPE )
107
- IS
108
- BEGIN
109
-
110
- UPDATE note_comments
111
- SET note_id = the_note_id
112
- , text = the_text
113
- , updated_at = SYSDATE
114
- , updated_by = USER
115
- WHERE id = the_id;
116
-
117
- END;
118
-
119
- PROCEDURE p_save
120
- ( the_comment IN note_comments%ROWTYPE )
121
- IS
122
- BEGIN
123
-
124
- IF the_comment.id IS NULL
125
- OR the_comment.id < 0
126
- THEN
127
- p_create
128
- ( the_note_id => the_comment.note_id
129
- , the_text => the_comment.text );
130
- ELSE
131
- p_update
132
- ( the_id => the_comment.id
133
- , the_note_id => the_comment.note_id
134
- , the_text => the_comment.text );
135
-
136
- END IF;
137
-
138
- END;
139
-
140
- PROCEDURE p_save
141
- ( the_comments IN note_comments_tab )
142
- IS
143
- BEGIN
144
-
145
- IF the_comments.COUNT > 0 THEN
146
- FOR i IN the_comments.FIRST..the_comments.LAST LOOP
147
- p_save( the_comments( i ) );
148
- END LOOP;
149
- END IF;
150
-
151
- END;
152
-
153
- PROCEDURE p_delete
154
- ( the_id IN note_comments.id%TYPE )
155
- IS
156
- BEGIN
157
-
158
- DELETE FROM note_comments WHERE id = the_id;
159
-
160
- END;
161
-
162
- END;
163
-
164
- /
@@ -1,146 +0,0 @@
1
- /*<TOAD_FILE_CHUNK>*/
2
- CREATE OR REPLACE PACKAGE pkg_note_tags
3
- IS
4
-
5
- TYPE tag_stat
6
- IS RECORD
7
- ( tag note_tags.tag%TYPE
8
- , count INTEGER );
9
-
10
- TYPE tag_stats
11
- IS TABLE OF tag_stat
12
- INDEX BY BINARY_INTEGER;
13
-
14
- CURSOR cur_tag_stats
15
- ( the_notebook_id IN notebooks.id%TYPE )
16
- RETURN tag_stat;
17
-
18
- FUNCTION f_get_tags
19
- ( the_note_id IN notes.id%TYPE )
20
- RETURN pkg_array_utils.vc_arr;
21
-
22
- FUNCTION f_get_tag_stats
23
- ( the_notebook_id IN notebooks.id%TYPE )
24
- RETURN tag_stats;
25
-
26
- PROCEDURE p_save
27
- ( the_note_tag_rec IN OUT note_tags%ROWTYPE );
28
-
29
- PROCEDURE p_save_note_tags
30
- ( the_note_id IN notes.id%TYPE
31
- , the_tags IN pkg_array_utils.vc_arr );
32
-
33
- END;
34
-
35
- /
36
- /*<TOAD_FILE_CHUNK>*/
37
-
38
- CREATE OR REPLACE PACKAGE BODY pkg_note_tags
39
- IS
40
-
41
- CURSOR cur_tag_stats
42
- ( the_notebook_id IN notebooks.id%TYPE )
43
- RETURN tag_stat
44
- IS
45
- SELECT *
46
- FROM (
47
- SELECT tag, COUNT( * ) cnt
48
- FROM note_tags nt
49
- JOIN notes n
50
- ON nt.note_id = n.id
51
- JOIN notebooks nb
52
- ON n.notebook_id = nb.id
53
- WHERE nb.id = the_notebook_id
54
- GROUP BY tag
55
- )
56
- ORDER BY cnt DESC, tag;
57
-
58
- FUNCTION f_get_tags
59
- ( the_note_id IN notes.id%TYPE )
60
- RETURN pkg_array_utils.vc_arr
61
- IS
62
- return_arr pkg_array_utils.vc_arr;
63
- BEGIN
64
-
65
- SELECT tag
66
- BULK COLLECT INTO return_arr
67
- FROM note_tags
68
- WHERE note_id = the_note_id;
69
-
70
- RETURN return_arr;
71
-
72
- END;
73
-
74
- FUNCTION f_get_tag_stats
75
- ( the_notebook_id IN notebooks.id%TYPE )
76
- RETURN tag_stats
77
- IS
78
- return_stats tag_stats;
79
- BEGIN
80
-
81
- OPEN cur_tag_stats( the_notebook_id );
82
- FETCH cur_tag_stats
83
- BULK COLLECT INTO return_stats;
84
- CLOSE cur_tag_stats;
85
-
86
- RETURN return_stats;
87
-
88
- END;
89
-
90
- PROCEDURE p_save
91
- ( the_note_tag_rec IN OUT note_tags%ROWTYPE )
92
- IS
93
- BEGIN
94
-
95
- IF the_note_tag_rec.id IS NULL THEN
96
-
97
- SELECT note_tags_seq.NEXTVAL
98
- INTO the_note_tag_rec.id
99
- FROM DUAL;
100
-
101
- INSERT INTO note_tags
102
- ( id
103
- , note_id
104
- , tag )
105
- VALUES
106
- ( the_note_tag_rec.id
107
- , the_note_tag_rec.note_id
108
- , the_note_tag_rec.tag );
109
-
110
- ELSE
111
-
112
- UPDATE note_tags
113
- SET note_id = the_note_tag_rec.note_id
114
- , tag = the_note_tag_rec.tag
115
- WHERE id = the_note_tag_rec.id;
116
-
117
- END IF;
118
-
119
- END;
120
-
121
- PROCEDURE p_save_note_tags
122
- ( the_note_id IN notes.id%TYPE
123
- , the_tags IN pkg_array_utils.vc_arr )
124
- IS
125
- BEGIN
126
-
127
- DELETE FROM note_tags WHERE note_id = the_note_id;
128
-
129
- IF the_tags.COUNT > 0 THEN
130
- FOR i IN the_tags.FIRST..the_tags.LAST LOOP
131
- DECLARE
132
- the_tag_rec note_tags%ROWTYPE;
133
- BEGIN
134
- the_tag_rec.note_id := the_note_id;
135
- the_tag_rec.tag := the_tags( i );
136
- p_save( the_note_tag_rec => the_tag_rec );
137
- END;
138
- END LOOP;
139
- END IF;
140
-
141
-
142
- END;
143
-
144
- END;
145
-
146
- /
@@ -1,135 +0,0 @@
1
- /*<TOAD_FILE_CHUNK>*/
2
- CREATE OR REPLACE PACKAGE pkg_notebooks
3
- IS
4
-
5
- TYPE notebooks_tab
6
- IS TABLE OF notebooks%ROWTYPE;
7
-
8
- CURSOR cur_notebooks
9
- RETURN notebooks%ROWTYPE;
10
-
11
- FUNCTION f_get_all
12
- RETURN notebooks_tab;
13
-
14
- FUNCTION f_get
15
- ( the_id IN notebooks.id%TYPE )
16
- RETURN notebooks%ROWTYPE;
17
-
18
- FUNCTION f_get
19
- ( the_title IN notebooks.title%TYPE )
20
- RETURN notebooks%ROWTYPE;
21
-
22
- FUNCTION f_title
23
- ( the_id IN notebooks.id%TYPE )
24
- RETURN notebooks.title%TYPE;
25
-
26
- FUNCTION f_human_title
27
- ( the_id IN notebooks.id%TYPE )
28
- RETURN notebooks.title%TYPE;
29
-
30
- PROCEDURE p_create
31
- ( the_title IN VARCHAR2 );
32
-
33
- END;
34
-
35
- /
36
- /*<TOAD_FILE_CHUNK>*/
37
- CREATE OR REPLACE PACKAGE BODY pkg_notebooks
38
- IS
39
-
40
- CURSOR cur_notebooks
41
- RETURN notebooks%ROWTYPE
42
- IS
43
- SELECT *
44
- FROM notebooks
45
- ORDER BY title;
46
-
47
- FUNCTION f_get_all
48
- RETURN notebooks_tab
49
- IS
50
- return_tab notebooks_tab;
51
- BEGIN
52
-
53
- OPEN cur_notebooks;
54
- FETCH cur_notebooks BULK COLLECT INTO return_tab;
55
- CLOSE cur_notebooks;
56
-
57
- RETURN return_tab;
58
-
59
- END;
60
-
61
- FUNCTION f_get
62
- ( the_id IN notebooks.id%TYPE )
63
- RETURN notebooks%ROWTYPE
64
- IS
65
- return_rec notebooks%ROWTYPE;
66
- BEGIN
67
-
68
- SELECT *
69
- INTO return_rec
70
- FROM notebooks
71
- WHERE id = the_id;
72
-
73
- RETURN return_rec;
74
-
75
- END;
76
-
77
- FUNCTION f_get
78
- ( the_title IN notebooks.title%TYPE )
79
- RETURN notebooks%ROWTYPE
80
- IS
81
- return_rec notebooks%ROWTYPE;
82
- BEGIN
83
-
84
- SELECT *
85
- INTO return_rec
86
- FROM notebooks
87
- WHERE title = the_title;
88
-
89
- RETURN return_rec;
90
-
91
- END;
92
-
93
- FUNCTION f_title
94
- ( the_id IN notebooks.id%TYPE )
95
- RETURN notebooks.title%TYPE
96
- IS
97
- return_val notebooks.title%TYPE;
98
- BEGIN
99
-
100
- SELECT title
101
- INTO return_val
102
- FROM notebooks
103
- WHERE id = the_id;
104
-
105
- RETURN return_val;
106
-
107
- END;
108
-
109
- FUNCTION f_human_title
110
- ( the_id IN notebooks.id%TYPE )
111
- RETURN notebooks.title%TYPE
112
- IS
113
- BEGIN
114
-
115
- RETURN INITCAP( REPLACE( f_title( the_id ), '_', ' ' ) );
116
-
117
- END;
118
-
119
- PROCEDURE p_create
120
- ( the_title IN VARCHAR2 )
121
- IS
122
- BEGIN
123
-
124
- INSERT INTO notebooks
125
- ( id
126
- , title )
127
- VALUES
128
- ( notebooks_seq.nextval
129
- , the_title );
130
-
131
-
132
- END;
133
-
134
- END;
135
- /