ruby-plsql 0.1.0
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/History.txt +6 -0
 - data/License.txt +20 -0
 - data/Manifest.txt +31 -0
 - data/README.txt +66 -0
 - data/Rakefile +4 -0
 - data/config/hoe.rb +70 -0
 - data/config/requirements.rb +17 -0
 - data/lib/plsql/package.rb +42 -0
 - data/lib/plsql/procedure.rb +172 -0
 - data/lib/plsql/schema.rb +103 -0
 - data/lib/ruby_plsql.rb +16 -0
 - data/lib/ruby_plsql/version.rb +9 -0
 - data/log/debug.log +0 -0
 - data/script/destroy +14 -0
 - data/script/generate +14 -0
 - data/script/txt2html +74 -0
 - data/setup.rb +1585 -0
 - data/spec/plsql/package_spec.rb +48 -0
 - data/spec/plsql/procedure_spec.rb +168 -0
 - data/spec/plsql/schema_spec.rb +68 -0
 - data/spec/spec.opts +1 -0
 - data/spec/spec_helper.rb +9 -0
 - data/tasks/deployment.rake +34 -0
 - data/tasks/environment.rake +7 -0
 - data/tasks/rspec.rake +21 -0
 - data/tasks/website.rake +17 -0
 - data/website/index.html +110 -0
 - data/website/index.txt +51 -0
 - data/website/javascripts/rounded_corners_lite.inc.js +285 -0
 - data/website/stylesheets/screen.css +138 -0
 - data/website/template.rhtml +48 -0
 - metadata +89 -0
 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Package" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 5 
     | 
    
         
            +
                plsql.connection = conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 6 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 7 
     | 
    
         
            +
                  CREATE OR REPLACE PACKAGE test_package IS
         
     | 
| 
      
 8 
     | 
    
         
            +
                    FUNCTION test_uppercase ( p_string VARCHAR2 )
         
     | 
| 
      
 9 
     | 
    
         
            +
                      RETURN VARCHAR2;
         
     | 
| 
      
 10 
     | 
    
         
            +
                  END;
         
     | 
| 
      
 11 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 12 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 13 
     | 
    
         
            +
                  CREATE OR REPLACE PACKAGE BODY test_package IS
         
     | 
| 
      
 14 
     | 
    
         
            +
                    FUNCTION test_uppercase ( p_string VARCHAR2 )
         
     | 
| 
      
 15 
     | 
    
         
            +
                      RETURN VARCHAR2
         
     | 
| 
      
 16 
     | 
    
         
            +
                    IS
         
     | 
| 
      
 17 
     | 
    
         
            +
                    BEGIN
         
     | 
| 
      
 18 
     | 
    
         
            +
                      RETURN UPPER(p_string);
         
     | 
| 
      
 19 
     | 
    
         
            +
                    END test_uppercase;
         
     | 
| 
      
 20 
     | 
    
         
            +
                  END;
         
     | 
| 
      
 21 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 26 
     | 
    
         
            +
                plsql.logoff
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
              
         
     | 
| 
      
 29 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
              
         
     | 
| 
      
 32 
     | 
    
         
            +
              it "should find existing package" do
         
     | 
| 
      
 33 
     | 
    
         
            +
                PLSQL::Package.find(plsql, :test_package).should_not be_nil
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              it "should not find nonexisting package" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                PLSQL::Package.find(plsql, :qwerty123456).should be_nil
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              it "should find existing package in schema" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                plsql.test_package.class.should == PLSQL::Package
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              it "should execute package function and return correct value" do
         
     | 
| 
      
 45 
     | 
    
         
            +
                plsql.test_package.test_uppercase('xxx').should == 'XXX'
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,168 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Procedure with string parameters" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                plsql.connection = conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 7 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 8 
     | 
    
         
            +
                  CREATE OR REPLACE FUNCTION test_uppercase
         
     | 
| 
      
 9 
     | 
    
         
            +
                    ( p_string VARCHAR2 )
         
     | 
| 
      
 10 
     | 
    
         
            +
                    RETURN VARCHAR2
         
     | 
| 
      
 11 
     | 
    
         
            +
                  IS
         
     | 
| 
      
 12 
     | 
    
         
            +
                  BEGIN
         
     | 
| 
      
 13 
     | 
    
         
            +
                    RETURN UPPER(p_string);
         
     | 
| 
      
 14 
     | 
    
         
            +
                  END test_uppercase;
         
     | 
| 
      
 15 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
              
         
     | 
| 
      
 18 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 19 
     | 
    
         
            +
                plsql.logoff
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
              
         
     | 
| 
      
 22 
     | 
    
         
            +
              it "should find existing procedure" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                PLSQL::Procedure.find(plsql, :test_uppercase).should_not be_nil
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              it "should not find nonexisting procedure" do
         
     | 
| 
      
 27 
     | 
    
         
            +
                PLSQL::Procedure.find(plsql, :qwerty123456).should be_nil
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              it "should execute function and return correct value" do
         
     | 
| 
      
 31 
     | 
    
         
            +
                plsql.test_uppercase('xxx').should == 'XXX'
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              it "should execute function with named parameters and return correct value" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                plsql.test_uppercase(:p_string => 'xxx').should == 'XXX'
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              it "should raise error if wrong number of arguments is passed" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                lambda { plsql.test_uppercase('xxx','yyy') }.should raise_error(ArgumentError)
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              it "should raise error if wrong named argument is passed" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                lambda { plsql.test_uppercase(:p_string2 => 'xxx') }.should raise_error(ArgumentError)
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
              
         
     | 
| 
      
 46 
     | 
    
         
            +
              it "should execute function with schema name specified" do
         
     | 
| 
      
 47 
     | 
    
         
            +
                plsql.hr.test_uppercase('xxx').should == 'XXX'
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            describe "Procedure with numeric parameters" do
         
     | 
| 
      
 53 
     | 
    
         
            +
              
         
     | 
| 
      
 54 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 55 
     | 
    
         
            +
                plsql.connection = conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 56 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 57 
     | 
    
         
            +
                  CREATE OR REPLACE FUNCTION test_sum
         
     | 
| 
      
 58 
     | 
    
         
            +
                    ( p_num1 NUMBER, p_num2 NUMBER )
         
     | 
| 
      
 59 
     | 
    
         
            +
                    RETURN NUMBER
         
     | 
| 
      
 60 
     | 
    
         
            +
                  IS
         
     | 
| 
      
 61 
     | 
    
         
            +
                  BEGIN
         
     | 
| 
      
 62 
     | 
    
         
            +
                    RETURN p_num1 + p_num2;
         
     | 
| 
      
 63 
     | 
    
         
            +
                  END test_sum;
         
     | 
| 
      
 64 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
              
         
     | 
| 
      
 67 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 68 
     | 
    
         
            +
                plsql.logoff
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
              
         
     | 
| 
      
 71 
     | 
    
         
            +
              it "should process integer parameters" do
         
     | 
| 
      
 72 
     | 
    
         
            +
                plsql.test_sum(123,456).should == 579
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              it "should process big integer parameters" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                plsql.test_sum(123123123123,456456456456).should == 579579579579
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              it "should process float parameters" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                plsql.test_sum(123.123,456.456).should == 579.579
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            describe "Procedure with date parameters" do
         
     | 
| 
      
 86 
     | 
    
         
            +
              
         
     | 
| 
      
 87 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 88 
     | 
    
         
            +
                plsql.connection = conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 89 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 90 
     | 
    
         
            +
                  CREATE OR REPLACE FUNCTION test_date
         
     | 
| 
      
 91 
     | 
    
         
            +
                    ( p_date DATE )
         
     | 
| 
      
 92 
     | 
    
         
            +
                    RETURN DATE
         
     | 
| 
      
 93 
     | 
    
         
            +
                  IS
         
     | 
| 
      
 94 
     | 
    
         
            +
                  BEGIN
         
     | 
| 
      
 95 
     | 
    
         
            +
                    RETURN p_date + 1;
         
     | 
| 
      
 96 
     | 
    
         
            +
                  END test_date;
         
     | 
| 
      
 97 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
              
         
     | 
| 
      
 100 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 101 
     | 
    
         
            +
                plsql.logoff
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
              
         
     | 
| 
      
 104 
     | 
    
         
            +
              it "should process date parameters" do
         
     | 
| 
      
 105 
     | 
    
         
            +
                now = DateTime.new(2008,8,12,14,28,0)
         
     | 
| 
      
 106 
     | 
    
         
            +
                plsql.test_date(now).should == now + 1
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              it "should process old date parameters" do
         
     | 
| 
      
 110 
     | 
    
         
            +
                now = DateTime.new(1900,1,1,12,0,0)
         
     | 
| 
      
 111 
     | 
    
         
            +
                plsql.test_date(now).should == now + 1
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
            describe "Procedure with timestamp parameters" do
         
     | 
| 
      
 117 
     | 
    
         
            +
              
         
     | 
| 
      
 118 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 119 
     | 
    
         
            +
                plsql.connection = conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 120 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 121 
     | 
    
         
            +
                  CREATE OR REPLACE FUNCTION test_timestamp
         
     | 
| 
      
 122 
     | 
    
         
            +
                    ( p_time TIMESTAMP )
         
     | 
| 
      
 123 
     | 
    
         
            +
                    RETURN TIMESTAMP
         
     | 
| 
      
 124 
     | 
    
         
            +
                  IS
         
     | 
| 
      
 125 
     | 
    
         
            +
                  BEGIN
         
     | 
| 
      
 126 
     | 
    
         
            +
                    RETURN p_time + 1;
         
     | 
| 
      
 127 
     | 
    
         
            +
                  END test_timestamp;
         
     | 
| 
      
 128 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 129 
     | 
    
         
            +
              end
         
     | 
| 
      
 130 
     | 
    
         
            +
              
         
     | 
| 
      
 131 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 132 
     | 
    
         
            +
                plsql.logoff
         
     | 
| 
      
 133 
     | 
    
         
            +
              end
         
     | 
| 
      
 134 
     | 
    
         
            +
              
         
     | 
| 
      
 135 
     | 
    
         
            +
              it "should process timestamp parameters" do
         
     | 
| 
      
 136 
     | 
    
         
            +
                now = Time.local(2008,8,12,14,28,0)
         
     | 
| 
      
 137 
     | 
    
         
            +
                plsql.test_timestamp(now).should == now + 60*60*24
         
     | 
| 
      
 138 
     | 
    
         
            +
              end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
            describe "Procedure with output parameters" do
         
     | 
| 
      
 143 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 144 
     | 
    
         
            +
                plsql.connection = conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 145 
     | 
    
         
            +
                plsql.connection.exec <<-EOS
         
     | 
| 
      
 146 
     | 
    
         
            +
                  CREATE OR REPLACE PROCEDURE test_copy
         
     | 
| 
      
 147 
     | 
    
         
            +
                    ( p_from VARCHAR2, p_to OUT VARCHAR2, p_to_double OUT VARCHAR2 )
         
     | 
| 
      
 148 
     | 
    
         
            +
                  IS
         
     | 
| 
      
 149 
     | 
    
         
            +
                  BEGIN
         
     | 
| 
      
 150 
     | 
    
         
            +
                    p_to := p_from;
         
     | 
| 
      
 151 
     | 
    
         
            +
                    p_to_double := p_from || p_from;
         
     | 
| 
      
 152 
     | 
    
         
            +
                  END test_copy;
         
     | 
| 
      
 153 
     | 
    
         
            +
                EOS
         
     | 
| 
      
 154 
     | 
    
         
            +
              end
         
     | 
| 
      
 155 
     | 
    
         
            +
              
         
     | 
| 
      
 156 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 157 
     | 
    
         
            +
                plsql.logoff
         
     | 
| 
      
 158 
     | 
    
         
            +
              end
         
     | 
| 
      
 159 
     | 
    
         
            +
              
         
     | 
| 
      
 160 
     | 
    
         
            +
              it "should return array with output parameters" do
         
     | 
| 
      
 161 
     | 
    
         
            +
                plsql.test_copy("abc", nil, nil).should == { :p_to => "abc", :p_to_double => "abcabc" }
         
     | 
| 
      
 162 
     | 
    
         
            +
              end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
              it "should return array with output parameters when called with named parameters" do
         
     | 
| 
      
 165 
     | 
    
         
            +
                plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil).should == { :p_to => "abc", :p_to_double => "abcabc" }
         
     | 
| 
      
 166 
     | 
    
         
            +
              end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,68 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Schema" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              it "should create Schema object" do
         
     | 
| 
      
 6 
     | 
    
         
            +
                plsql.class.should == PLSQL::Schema
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            describe "Connection" do
         
     | 
| 
      
 12 
     | 
    
         
            +
              
         
     | 
| 
      
 13 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 14 
     | 
    
         
            +
                @conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              after(:each) do
         
     | 
| 
      
 18 
     | 
    
         
            +
                @conn.logoff
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it "should connect to test database" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                plsql.connection = @conn
         
     | 
| 
      
 23 
     | 
    
         
            +
                plsql.connection.should == @conn
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              it "should connect to test database using connection alias" do
         
     | 
| 
      
 27 
     | 
    
         
            +
                plsql(:hr).connection = @conn
         
     | 
| 
      
 28 
     | 
    
         
            +
                plsql(:hr).connection.should == @conn
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
              it "should return schema name" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                plsql.connection = @conn
         
     | 
| 
      
 33 
     | 
    
         
            +
                plsql.schema_name.should == 'HR'
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              it "should return nil schema name if not connected" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                plsql(:xxx).schema_name.should == nil
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            describe "Named Schema" do
         
     | 
| 
      
 43 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 44 
     | 
    
         
            +
                @conn = OCI8.new("hr","hr","xe")
         
     | 
| 
      
 45 
     | 
    
         
            +
                plsql.connection = @conn
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 49 
     | 
    
         
            +
                @conn.logoff
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              it "should find existing schema" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                plsql.hr.class.should == PLSQL::Schema
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              it "should have the same connection as default schema" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                plsql.hr.connection.should == @conn
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              it "should return schema name" do
         
     | 
| 
      
 61 
     | 
    
         
            +
                plsql.hr.schema_name.should == 'HR'
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              it "should not find named schema if specified twice" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                lambda { plsql.hr.hr }.should raise_error(ArgumentError)
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec.opts
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --colour
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            desc 'Release the website and new gem version'
         
     | 
| 
      
 2 
     | 
    
         
            +
            task :deploy => [:check_version, :website, :release] do
         
     | 
| 
      
 3 
     | 
    
         
            +
              puts "Remember to create SVN tag:"
         
     | 
| 
      
 4 
     | 
    
         
            +
              puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
         
     | 
| 
      
 5 
     | 
    
         
            +
                "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
         
     | 
| 
      
 6 
     | 
    
         
            +
              puts "Suggested comment:"
         
     | 
| 
      
 7 
     | 
    
         
            +
              puts "Tagging release #{CHANGES}"
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
         
     | 
| 
      
 11 
     | 
    
         
            +
            task :local_deploy => [:website_generate, :install_gem]
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            task :check_version do
         
     | 
| 
      
 14 
     | 
    
         
            +
              unless ENV['VERSION']
         
     | 
| 
      
 15 
     | 
    
         
            +
                puts 'Must pass a VERSION=x.y.z release version'
         
     | 
| 
      
 16 
     | 
    
         
            +
                exit
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
              unless ENV['VERSION'] == VERS
         
     | 
| 
      
 19 
     | 
    
         
            +
                puts "Please update your version.rb to match the release version, currently #{VERS}"
         
     | 
| 
      
 20 
     | 
    
         
            +
                exit
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
         
     | 
| 
      
 25 
     | 
    
         
            +
            task :install_gem_no_doc => [:clean, :package] do
         
     | 
| 
      
 26 
     | 
    
         
            +
              sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            namespace :manifest do
         
     | 
| 
      
 30 
     | 
    
         
            +
              desc 'Recreate Manifest.txt to include ALL files'
         
     | 
| 
      
 31 
     | 
    
         
            +
              task :refresh do
         
     | 
| 
      
 32 
     | 
    
         
            +
                `rake check_manifest | patch -p0 > Manifest.txt`
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        data/tasks/rspec.rake
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            begin
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'spec'
         
     | 
| 
      
 3 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'rubygems'
         
     | 
| 
      
 5 
     | 
    
         
            +
              require 'spec'
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
            begin
         
     | 
| 
      
 8 
     | 
    
         
            +
              require 'spec/rake/spectask'
         
     | 
| 
      
 9 
     | 
    
         
            +
            rescue LoadError
         
     | 
| 
      
 10 
     | 
    
         
            +
              puts <<-EOS
         
     | 
| 
      
 11 
     | 
    
         
            +
            To use rspec for testing you must install rspec gem:
         
     | 
| 
      
 12 
     | 
    
         
            +
                gem install rspec
         
     | 
| 
      
 13 
     | 
    
         
            +
            EOS
         
     | 
| 
      
 14 
     | 
    
         
            +
              exit(0)
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            desc "Run the specs under spec/*"
         
     | 
| 
      
 18 
     | 
    
         
            +
            Spec::Rake::SpecTask.new do |t|
         
     | 
| 
      
 19 
     | 
    
         
            +
              t.spec_opts = ['--options', "spec/spec.opts"]
         
     | 
| 
      
 20 
     | 
    
         
            +
              t.spec_files = FileList['spec/*/*_spec.rb']
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
    
        data/tasks/website.rake
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            desc 'Generate website files'
         
     | 
| 
      
 2 
     | 
    
         
            +
            task :website_generate => :ruby_env do
         
     | 
| 
      
 3 
     | 
    
         
            +
              (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
         
     | 
| 
      
 4 
     | 
    
         
            +
                sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
         
     | 
| 
      
 5 
     | 
    
         
            +
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
            end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            desc 'Upload website files to rubyforge'
         
     | 
| 
      
 9 
     | 
    
         
            +
            task :website_upload do
         
     | 
| 
      
 10 
     | 
    
         
            +
              host = "#{rubyforge_username}@rubyforge.org"
         
     | 
| 
      
 11 
     | 
    
         
            +
              remote_dir = "/var/www/gforge-projects/#{PATH}/"
         
     | 
| 
      
 12 
     | 
    
         
            +
              local_dir = 'website'
         
     | 
| 
      
 13 
     | 
    
         
            +
              sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            desc 'Generate and upload website files'
         
     | 
| 
      
 17 
     | 
    
         
            +
            task :website => [:website_generate, :website_upload, :publish_docs]
         
     | 
    
        data/website/index.html
    ADDED
    
    | 
         @@ -0,0 +1,110 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         
     | 
| 
      
 2 
     | 
    
         
            +
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
         
     | 
| 
      
 3 
     | 
    
         
            +
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
         
     | 
| 
      
 4 
     | 
    
         
            +
            <head>
         
     | 
| 
      
 5 
     | 
    
         
            +
              <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
         
     | 
| 
      
 6 
     | 
    
         
            +
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
         
     | 
| 
      
 7 
     | 
    
         
            +
              <title>
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Ruby API for PL/SQL
         
     | 
| 
      
 9 
     | 
    
         
            +
              </title>
         
     | 
| 
      
 10 
     | 
    
         
            +
              <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
         
     | 
| 
      
 11 
     | 
    
         
            +
            <style>
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            </style>
         
     | 
| 
      
 14 
     | 
    
         
            +
              <script type="text/javascript">
         
     | 
| 
      
 15 
     | 
    
         
            +
                window.onload = function() {
         
     | 
| 
      
 16 
     | 
    
         
            +
                  settings = {
         
     | 
| 
      
 17 
     | 
    
         
            +
                      tl: { radius: 10 },
         
     | 
| 
      
 18 
     | 
    
         
            +
                      tr: { radius: 10 },
         
     | 
| 
      
 19 
     | 
    
         
            +
                      bl: { radius: 10 },
         
     | 
| 
      
 20 
     | 
    
         
            +
                      br: { radius: 10 },
         
     | 
| 
      
 21 
     | 
    
         
            +
                      antiAlias: true,
         
     | 
| 
      
 22 
     | 
    
         
            +
                      autoPad: true,
         
     | 
| 
      
 23 
     | 
    
         
            +
                      validTags: ["div"]
         
     | 
| 
      
 24 
     | 
    
         
            +
                  }
         
     | 
| 
      
 25 
     | 
    
         
            +
                  var versionBox = new curvyCorners(settings, document.getElementById("version"));
         
     | 
| 
      
 26 
     | 
    
         
            +
                  versionBox.applyCornersToAll();
         
     | 
| 
      
 27 
     | 
    
         
            +
                }
         
     | 
| 
      
 28 
     | 
    
         
            +
              </script>
         
     | 
| 
      
 29 
     | 
    
         
            +
            </head>
         
     | 
| 
      
 30 
     | 
    
         
            +
            <body>
         
     | 
| 
      
 31 
     | 
    
         
            +
            <div id="main">
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                <h1>Ruby API for PL/SQL</h1>
         
     | 
| 
      
 34 
     | 
    
         
            +
                <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/ruby-plsql"; return false'>
         
     | 
| 
      
 35 
     | 
    
         
            +
                  <p>Get Version</p>
         
     | 
| 
      
 36 
     | 
    
         
            +
                  <a href="http://rubyforge.org/projects/ruby-plsql" class="numbers">0.1.0</a>
         
     | 
| 
      
 37 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 38 
     | 
    
         
            +
                <h1>→ ‘ruby-plsql’</h1>
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            	<h2>What</h2>
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            	<p>ruby-plsql gem provides simple Ruby <span class="caps">API</span> for calling Oracle PL/SQL procedures. This gem requires ruby-oci8 for connection to Oracle database.</p>
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            	<h2>Installing</h2>
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            	<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">ruby</span><span class="punct">-</span><span class="ident">plsql</span></pre></p>
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            	<h2>The basics</h2>
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            	<p>Read <a href="http://blog.rayapps.com/2008/03/15/ruby-plsql-gem-simple-ruby-api-for-plsql-procedures/">this blog post first.</a></p>
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            	<p>Usage examples:</p>
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            	<p><pre class='syntax'>
         
     | 
| 
      
 63 
     | 
    
         
            +
            <span class="ident">require</span> <span class="punct">"</span><span class="string">ruby_plsql</span><span class="punct">"</span>
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">connection</span> <span class="punct">=</span> <span class="constant">OCI8</span><span class="punct">.</span><span class="ident">new</span><span class="punct">("</span><span class="string">hr</span><span class="punct">","</span><span class="string">hr</span><span class="punct">","</span><span class="string">xe</span><span class="punct">")</span>
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">test_uppercase</span><span class="punct">('</span><span class="string">xxx</span><span class="punct">')</span>              <span class="comment"># => "XXX"</span>
         
     | 
| 
      
 68 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">test_uppercase</span><span class="punct">(</span><span class="symbol">:p_string</span> <span class="punct">=></span> <span class="punct">'</span><span class="string">xxx</span><span class="punct">')</span> <span class="comment"># => "XXX"</span>
         
     | 
| 
      
 69 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">test_copy</span><span class="punct">("</span><span class="string">abc</span><span class="punct">",</span> <span class="constant">nil</span><span class="punct">,</span> <span class="constant">nil</span><span class="punct">)</span>         <span class="comment"># => { :p_to => "abc", :p_to_double => "abcabc" }</span>
         
     | 
| 
      
 70 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">test_copy</span><span class="punct">(</span><span class="symbol">:p_from</span> <span class="punct">=></span> <span class="punct">"</span><span class="string">abc</span><span class="punct">",</span> <span class="symbol">:p_to</span> <span class="punct">=></span> <span class="constant">nil</span><span class="punct">,</span> <span class="symbol">:p_to_double</span> <span class="punct">=></span> <span class="constant">nil</span><span class="punct">)</span>
         
     | 
| 
      
 71 
     | 
    
         
            +
                                                     <span class="comment"># => { :p_to => "abc", :p_to_double => "abcabc" }</span>
         
     | 
| 
      
 72 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">hr</span><span class="punct">.</span><span class="ident">test_uppercase</span><span class="punct">('</span><span class="string">xxx</span><span class="punct">')</span>           <span class="comment"># => "XXX"</span>
         
     | 
| 
      
 73 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">test_package</span><span class="punct">.</span><span class="ident">test_uppercase</span><span class="punct">('</span><span class="string">xxx</span><span class="punct">')</span> <span class="comment"># => 'XXX'</span>
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            <span class="ident">plsql</span><span class="punct">.</span><span class="ident">logoff</span>
         
     | 
| 
      
 76 
     | 
    
         
            +
            </pre></p>
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            	<p>See more examples in RSpec tests in spec directory of gem.</p>
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            	<h2>Feedback</h2>
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            	<p>Submit your feedback as comments <a href="http://blog.rayapps.com/2008/03/15/ruby-plsql-gem-simple-ruby-api-for-plsql-procedures/">here.</a></p>
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            	<h2>How to submit patches</h2>
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            	<p>Submit bugs and patches to <a href="http://rubyforge.org/tracker/?group_id=5816">RubyForge</a></p>
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            	<p>The trunk repository is <code>http://ruby-plsql.rubyforge.org/svn/</code> for anonymous access.</p>
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
            	<h2>License</h2>
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            	<p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
         
     | 
| 
      
 101 
     | 
    
         
            +
                <p class="coda">
         
     | 
| 
      
 102 
     | 
    
         
            +
                  <a href="http://blog.rayapps.com">Raimonds Simanovskis</a>, 16th March 2008<br>
         
     | 
| 
      
 103 
     | 
    
         
            +
                  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
         
     | 
| 
      
 104 
     | 
    
         
            +
                </p>
         
     | 
| 
      
 105 
     | 
    
         
            +
            </div>
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            <!-- insert site tracking codes here, like Google Urchin -->
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            </body>
         
     | 
| 
      
 110 
     | 
    
         
            +
            </html>
         
     |