forked from rsim/ruby-plsql
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Raimonds Simanovskis
authored and
Raimonds Simanovskis
committed
Apr 19, 2008
0 parents
commit 9e879e4
Showing
31 changed files
with
3,461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.svn | ||
doc | ||
pkg | ||
log | ||
tmp | ||
sqlnet.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
== 0.1.4 2008-04-18 | ||
|
||
* Bug fixes | ||
* Fixed bug when nil numeric parameters where passed as 0, now nil numeric parameter is passed as NULL | ||
|
||
== 0.1.3 2008-04-15 | ||
|
||
* Improvements | ||
* Support for overloaded procedure definitions (named parameter calls compared by number of arguments and by argument names, | ||
sequential parameters compared by number of arguments) | ||
* Bug fixes | ||
* Fixed BigDecimal support for procedure parameters (all number types except from Fixnum are converted to Float) | ||
* Fixed Date parameters support (always will convert to DateTime) | ||
|
||
== 0.1.2 2008-04-02 | ||
|
||
* Improvements | ||
* When PL/SQL procedure is called with less arguments then missing arguments are filled with nil | ||
|
||
== 0.1.1 2008-04-01 | ||
|
||
* Bug fixes | ||
* Improved performance of PL/SQL procedure arguments selection in large databases | ||
* Added schema and package names in generated PL/SQL block when calling procedures from packages | ||
|
||
== 0.1.0 2008-03-15 | ||
|
||
* Initial release | ||
* Known limitations | ||
* Currently just NUMBER, VARCHAR2, DATE, TIMESTAMP argument types are supported for PL/SQL procedures | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008 Raimonds Simanovskis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
History.txt | ||
License.txt | ||
Manifest.txt | ||
README.txt | ||
Rakefile | ||
config/hoe.rb | ||
config/requirements.rb | ||
lib/plsql/package.rb | ||
lib/plsql/procedure.rb | ||
lib/plsql/schema.rb | ||
lib/ruby_plsql.rb | ||
lib/ruby_plsql/version.rb | ||
log/debug.log | ||
script/destroy | ||
script/generate | ||
script/txt2html | ||
setup.rb | ||
spec/plsql/package_spec.rb | ||
spec/plsql/procedure_spec.rb | ||
spec/plsql/schema_spec.rb | ||
spec/spec.opts | ||
spec/spec_helper.rb | ||
tasks/deployment.rake | ||
tasks/environment.rake | ||
tasks/rspec.rake | ||
tasks/website.rake | ||
website/index.html | ||
website/index.txt | ||
website/javascripts/rounded_corners_lite.inc.js | ||
website/stylesheets/screen.css | ||
website/template.rhtml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
= ruby-plsql | ||
|
||
* http://rubyforge.org/projects/ruby-plsql/ | ||
|
||
== DESCRIPTION: | ||
|
||
ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures. Currently ruby-plsql requires ruby-oci8 for connection to Oracle database, it is planned to add JRuby/JDBC support in the future. | ||
|
||
See http://blog.rayapps.com for more information. | ||
|
||
Look ar RSpec tests under spec directory for usage examples. | ||
|
||
== FEATURES/PROBLEMS: | ||
|
||
* Currently just NUMBER, VARCHAR2, DATE, TIMESTAMP argument types are supported for PL/SQL procedures | ||
|
||
== SYNOPSIS: | ||
|
||
Usage examples: | ||
|
||
require "ruby_plsql" | ||
|
||
plsql.connection = OCI8.new("hr","hr","xe") | ||
|
||
plsql.test_uppercase('xxx') # => "XXX" | ||
plsql.test_uppercase(:p_string => 'xxx') # => "XXX" | ||
plsql.test_copy("abc", nil, nil) # => { :p_to => "abc", :p_to_double => "abcabc" } | ||
plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil) | ||
# => { :p_to => "abc", :p_to_double => "abcabc" } | ||
plsql.hr.test_uppercase('xxx') # => "XXX" | ||
plsql.test_package.test_uppercase('xxx') # => 'XXX' | ||
|
||
plsql.logoff | ||
|
||
== REQUIREMENTS: | ||
|
||
* Requires ruby-oci8 library to connect to Oracle | ||
|
||
== INSTALL: | ||
|
||
* sudo gem install ruby-plsql | ||
|
||
== LICENSE: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2008 Raimonds Simanovskis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'config/requirements' | ||
require 'config/hoe' # setup Hoe + all gem configuration | ||
|
||
Dir['tasks/**/*.rake'].each { |rake| load rake } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'ruby_plsql/version' | ||
|
||
AUTHOR = 'Raimonds Simanovskis' # can also be an array of Authors | ||
EMAIL = "[email protected]" | ||
DESCRIPTION = "ruby-plsql gem provides simple Ruby API for calling Oracle PL/SQL procedures." | ||
GEM_NAME = 'ruby-plsql' # what ppl will type to install your gem | ||
RUBYFORGE_PROJECT = 'ruby-plsql' # The unix name for your project | ||
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org" | ||
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}" | ||
|
||
@config_file = "~/.rubyforge/user-config.yml" | ||
@config = nil | ||
RUBYFORGE_USERNAME = "unknown" | ||
def rubyforge_username | ||
unless @config | ||
begin | ||
@config = YAML.load(File.read(File.expand_path(@config_file))) | ||
rescue | ||
puts <<-EOS | ||
ERROR: No rubyforge config file found: #{@config_file} | ||
Run 'rubyforge setup' to prepare your env for access to Rubyforge | ||
- See http://newgem.rubyforge.org/rubyforge.html for more details | ||
EOS | ||
exit | ||
end | ||
end | ||
RUBYFORGE_USERNAME.replace @config["username"] | ||
end | ||
|
||
|
||
REV = nil | ||
# UNCOMMENT IF REQUIRED: | ||
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil | ||
VERS = RubyPlsql::VERSION::STRING + (REV ? ".#{REV}" : "") | ||
RDOC_OPTS = ['--quiet', '--title', 'ruby_plsql documentation', | ||
"--opname", "index.html", | ||
"--line-numbers", | ||
"--main", "README", | ||
"--inline-source"] | ||
|
||
class Hoe | ||
def extra_deps | ||
@extra_deps.reject! { |x| Array(x).first == 'hoe' } | ||
@extra_deps | ||
end | ||
end | ||
|
||
# Generate all the Rake tasks | ||
# Run 'rake -T' to see list of generated tasks (from gem root directory) | ||
hoe = Hoe.new(GEM_NAME, VERS) do |p| | ||
p.developer(AUTHOR, EMAIL) | ||
p.description = DESCRIPTION | ||
p.summary = DESCRIPTION | ||
p.url = HOMEPATH | ||
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT | ||
p.test_globs = ["test/**/test_*.rb"] | ||
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean. | ||
|
||
# == Optional | ||
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") | ||
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ] | ||
|
||
#p.spec_extras = {} # A hash of extra values to set in the gemspec. | ||
|
||
end | ||
|
||
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n") | ||
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}" | ||
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc') | ||
hoe.rsync_args = '-av --delete --ignore-errors' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'fileutils' | ||
include FileUtils | ||
|
||
require 'rubygems' | ||
%w[rake hoe newgem rubigen].each do |req_gem| | ||
begin | ||
require req_gem | ||
rescue LoadError | ||
puts "This Rakefile requires the '#{req_gem}' RubyGem." | ||
puts "Installation: gem install #{req_gem} -y" | ||
exit | ||
end | ||
end | ||
|
||
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib])) | ||
|
||
require 'ruby_plsql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module PLSQL | ||
|
||
module PackageClassMethods | ||
def find(schema, package) | ||
if schema.select_first(" | ||
SELECT object_name FROM all_objects | ||
WHERE owner = :owner | ||
AND object_name = :package | ||
AND object_type = 'PACKAGE'", | ||
schema.schema_name, package.to_s.upcase) | ||
new(schema, package) | ||
else | ||
nil | ||
end | ||
end | ||
end | ||
|
||
class Package | ||
extend PackageClassMethods | ||
|
||
def initialize(schema, package) | ||
@schema = schema | ||
@package = package.to_s.upcase | ||
@procedures = {} | ||
end | ||
|
||
private | ||
|
||
def method_missing(method, *args) | ||
if procedure = @procedures[method] | ||
procedure.exec(*args) | ||
elsif procedure = Procedure.find(@schema, method, @package) | ||
@procedures[method] = procedure | ||
procedure.exec(*args) | ||
else | ||
raise ArgumentError, "No PL/SQL procedure found" | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.