[DRE-commits] [SCM] ruby-dataobjects.git branch, master, updated. upstream/0.10.0-2-g1dbc5d4
Deepak Tripathi
deepak at debian.org
Thu Jun 16 08:54:44 UTC 2011
The following commit has been merged in the master branch:
commit 1dbc5d419535dee9bfb8e955c2da0fb809c57588
Author: Deepak Tripathi <deepak at debian.org>
Date: Thu Jun 16 14:24:20 2011 +0530
Removing files
diff --git a/HISTORY.markdown b/HISTORY.markdown
deleted file mode 100644
index ef941cf..0000000
--- a/HISTORY.markdown
+++ /dev/null
@@ -1,7 +0,0 @@
-== 0.9.11 2009-01-19
-* Fixes
- * Use Extlib Object.full_const_get instead of custom code
- * Remove Field as it was unused
-
-== 0.9.9 2008-11-27
-* No Changes since 0.9.8
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index a3001c4..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,48 +0,0 @@
-Copyright (c) 2007, 2008, 2009 Yehuda Katz, Dirkjan Bussink
-
-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.
-
----
----
-
-Some portions of tasks/ext_helper_java.rb are verbatim copies of software
-licensed under the MIT license. That license is included below:
-
-Copyright (c) 2006-2008 Nick Sieger <nick at nicksieger.com>
-Copyright (c) 2006-2008 Ola Bini <ola.bini at gmail.com>
-
-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.
diff --git a/Manifest.txt b/Manifest.txt
deleted file mode 100644
index e7cf946..0000000
--- a/Manifest.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-.gitignore
-HISTORY.markdown
-LICENSE
-Manifest.txt
-README.markdown
-Rakefile
-lib/data_objects.rb
-lib/data_objects/command.rb
-lib/data_objects/connection.rb
-lib/data_objects/logger.rb
-lib/data_objects/quoting.rb
-lib/data_objects/reader.rb
-lib/data_objects/result.rb
-lib/data_objects/spec/command_spec.rb
-lib/data_objects/spec/connection_spec.rb
-lib/data_objects/spec/encoding_spec.rb
-lib/data_objects/spec/quoting_spec.rb
-lib/data_objects/spec/reader_spec.rb
-lib/data_objects/spec/result_spec.rb
-lib/data_objects/spec/typecast/bigdecimal_spec.rb
-lib/data_objects/spec/typecast/boolean_spec.rb
-lib/data_objects/spec/typecast/byte_array_spec.rb
-lib/data_objects/spec/typecast/class_spec.rb
-lib/data_objects/spec/typecast/date_spec.rb
-lib/data_objects/spec/typecast/datetime_spec.rb
-lib/data_objects/spec/typecast/float_spec.rb
-lib/data_objects/spec/typecast/integer_spec.rb
-lib/data_objects/spec/typecast/ipaddr_spec.rb
-lib/data_objects/spec/typecast/nil_spec.rb
-lib/data_objects/spec/typecast/string_spec.rb
-lib/data_objects/spec/typecast/time_spec.rb
-lib/data_objects/transaction.rb
-lib/data_objects/uri.rb
-lib/data_objects/version.rb
-spec/command_spec.rb
-spec/connection_spec.rb
-spec/do_mock.rb
-spec/lib/pending_helpers.rb
-spec/reader_spec.rb
-spec/result_spec.rb
-spec/spec.opts
-spec/spec_helper.rb
-spec/transaction_spec.rb
-spec/uri_spec.rb
diff --git a/README.markdown b/README.markdown
deleted file mode 100644
index 16a200c..0000000
--- a/README.markdown
+++ /dev/null
@@ -1,4 +0,0 @@
-data_objects
-============
-
-A unified Ruby API for popular databases.
diff --git a/Rakefile b/Rakefile
deleted file mode 100644
index 5934413..0000000
--- a/Rakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'rubygems'
-require 'rake'
-require 'rake/clean'
-
-require 'pathname'
-require 'lib/data_objects/version'
-
-ROOT = Pathname(__FILE__).dirname.expand_path
-JRUBY = RUBY_PLATFORM =~ /java/
-WINDOWS = Gem.win_platform?
-SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
-
-Dir['tasks/*.rake'].sort.each { |f| import f }
-
-CLEAN.include(%w[ pkg/ **/*.rbc ])
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 8c625d1..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-ruby-dataobjects (0.10.0-1) UNRELEASED; urgency=low
-
- * Initial release (Closes: #nnnn)
-
- -- Deepak Tripathi <deepak at debian.org> Tue, 14 Jun 2011 16:44:45 +0530
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7f8f011..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 29d9791..0000000
--- a/debian/control
+++ /dev/null
@@ -1,20 +0,0 @@
-Source: ruby-dataobjects
-Section: ruby
-Priority: optional
-Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers at lists.alioth.debian.org>
-Uploaders: Deepak Tripathi <deepak at debian.org>
-DM-Upload-Allowed: yes
-Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.3)
-Standards-Version: 3.9.1
-#Vcs-Git: git://git.debian.org/pkg-ruby-extras/ruby-dataobjects.git
-#Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/ruby-dataobjects.git;a=summary
-Homepage: http://github.com/datamapper/do
-XS-Ruby-Versions: all
-
-Package: ruby-dataobjects
-Architecture: all
-XB-Ruby-Versions: ${ruby:Versions}
-Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter
-# addressable (~> 2.0), extlib (~> 0.9.12), rspec (~> 1.2.0, development)
-Description: DataObjects basic API and shared driver specifications
- Provide a standard and simplified API for communicating with RDBMS from Ruby
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 7f36a18..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,33 +0,0 @@
-FIXME. fill-in with DEP5 copyright file. http://dep.debian.net/deps/dep5/
-Format: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=173
-Upstream-Name: data-objects
-Source: FIXME (URL where source can be downloaded)
-
-Files: *
-Copyright: Copyright 1998 John Doe <jdoe at example.com>
-License: GPL-2+
- This program is free software; you can redistribute it
- and/or modify it under the terms of the GNU General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later
- version.
- .
- This program is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the GNU General Public License for more
- details.
- .
- You should have received a copy of the GNU General Public
- License along with this package; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- Boston, MA 02110-1301 USA
- .
- On Debian systems, the full text of the GNU General Public
- License version 2 can be found in the file
- `/usr/share/common-licenses/GPL-2'.
-
-Files: debian/*
-Copyright: Copyright 1998 Jane Smith <jsmith at example.net>
-License:
- [LICENSE TEXT]
diff --git a/debian/ruby-dataobjects.docs b/debian/ruby-dataobjects.docs
deleted file mode 100644
index 53cfb6b..0000000
--- a/debian/ruby-dataobjects.docs
+++ /dev/null
@@ -1,2 +0,0 @@
-# FIXME: READMEs found
-# README.markdown
diff --git a/debian/ruby-tests.rb b/debian/ruby-tests.rb
deleted file mode 100644
index eac5ce6..0000000
--- a/debian/ruby-tests.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# FIXME
-# there's a spec/ or a test/ directory in the upstream source, but
-# no test suite was defined in the Gem specification. It would be
-# a good idea to define it here so the package gets tested at build time.
-# Examples:
-# $: << 'lib' << '.'
-# Dir['{spec,test}/**/*.rb'].each { |f| require f }
-#
-# require 'test/ts_foo.rb'
-#
-# require 'rbconfig'
-# ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
-# exec("#{ruby} -I. test/runtests.rb")
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index a5e7dc8..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/make -f
-#export DH_VERBOSE=1
-#
-# Uncomment to ignore all test failures (but the tests will run anyway)
-#export DH_RUBY_IGNORE_TESTS=all
-#
-# Uncomment to ignore some test failures (but the tests will run anyway).
-# Valid values:
-#export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems
-#
-# If you need to specify the .gemspec (eg there is more than one)
-#export DH_RUBY_GEMSPEC=gem.gemspec
-
-%:
- dh $@ --buildsystem=ruby --with ruby
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index e27b5d6..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,2 +0,0 @@
-version=3
-http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/data-objects .*/data-objects-(.*).tar.gz
diff --git a/lib/data_objects.rb b/lib/data_objects.rb
deleted file mode 100644
index 17962d8..0000000
--- a/lib/data_objects.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'extlib'
-
-require 'data_objects/version'
-require 'data_objects/logger'
-require 'data_objects/connection'
-require 'data_objects/uri'
-require 'data_objects/transaction'
-require 'data_objects/command'
-require 'data_objects/result'
-require 'data_objects/reader'
-require 'data_objects/quoting'
-require 'data_objects/error'
-require 'data_objects/error/sql_error'
-require 'data_objects/error/connection_error'
-require 'data_objects/error/data_error'
-require 'data_objects/error/integrity_error'
-require 'data_objects/error/syntax_error'
-require 'data_objects/error/transaction_error'
diff --git a/lib/data_objects/command.rb b/lib/data_objects/command.rb
deleted file mode 100644
index c2de5f2..0000000
--- a/lib/data_objects/command.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-module DataObjects
- # Abstract base class for adapter-specific Command subclasses
- class Command
-
- # The Connection on which the command will be run
- attr_reader :connection
-
- # Create a new Command object on the specified connection
- def initialize(connection, text)
- raise ArgumentError.new("+connection+ must be a DataObjects::Connection") unless DataObjects::Connection === connection
- @connection, @text = connection, text
- end
-
- # Execute this command and return no dataset
- def execute_non_query(*args)
- raise NotImplementedError.new
- end
-
- # Execute this command and return a DataObjects::Reader for a dataset
- def execute_reader(*args)
- raise NotImplementedError.new
- end
-
- # Assign an array of types for the columns to be returned by this command
- def set_types(column_types)
- raise NotImplementedError.new
- end
-
- # Display the command text
- def to_s
- @text
- end
-
- private
-
- # Escape a string of SQL with a set of arguments.
- # The first argument is assumed to be the SQL to escape,
- # the remaining arguments (if any) are assumed to be
- # values to escape and interpolate.
- #
- # ==== Examples
- # escape_sql("SELECT * FROM zoos")
- # # => "SELECT * FROM zoos"
- #
- # escape_sql("SELECT * FROM zoos WHERE name = ?", "Dallas")
- # # => "SELECT * FROM zoos WHERE name = `Dallas`"
- #
- # escape_sql("SELECT * FROM zoos WHERE name = ? AND acreage > ?", "Dallas", 40)
- # # => "SELECT * FROM zoos WHERE name = `Dallas` AND acreage > 40"
- #
- # ==== Warning
- # This method is meant mostly for adapters that don't support
- # bind-parameters.
- def escape_sql(args)
- sql = @text.dup
- vars = args.dup
-
- replacements = 0
- mismatch = false
-
- sql.gsub!(/'[^']*'|"[^"]*"|`[^`]*`|\?/) do |x|
- next x unless x == '?'
- replacements += 1
- if vars.empty?
- mismatch = true
- else
- var = vars.shift
- connection.quote_value(var)
- end
- end
-
- if !vars.empty? || mismatch
- raise ArgumentError, "Binding mismatch: #{args.size} for #{replacements}"
- else
- sql
- end
- end
-
- end
-
-end
diff --git a/lib/data_objects/connection.rb b/lib/data_objects/connection.rb
deleted file mode 100644
index 7190db7..0000000
--- a/lib/data_objects/connection.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-begin
- require 'fastthread'
-rescue LoadError
-end
-
-module DataObjects
- # An abstract connection to a DataObjects resource. The physical connection may be broken and re-established from time to time.
- class Connection
-
- # Make a connection to the database using the DataObjects::URI given.
- # Note that the physical connection may be delayed until the first command is issued, so success here doesn't necessarily mean you can connect.
- def self.new(uri_s)
- uri = DataObjects::URI::parse(uri_s)
-
- case uri.scheme.to_sym
- when :java
- warn 'JNDI URLs (connection strings) are only for use with JRuby' unless RUBY_PLATFORM =~ /java/
- # TODO: handle jndi connection strings
- when :jdbc
- warn 'JDBC URLs (connection strings) are only for use with JRuby' unless RUBY_PLATFORM =~ /java/
-
- driver_name = if uri.path.split(':').first == 'sqlite'
- 'sqlite3'
- elsif uri.path.split(':').first == 'postgresql'
- 'postgres'
- else
- uri.path.split(':').first
- end
-
- conn_uri = uri_s # NOTE: for now, do not reformat this JDBC connection
- # string -- or, in other words, do not let
- # DataObjects::URI#to_s be called -- as it is not
- # correctly handling JDBC URLs, and in doing so, causing
- # java.sql.DriverManager.getConnection to throw a
- # 'No suitable driver found for...' exception.
- else
- driver_name = uri.scheme
- conn_uri = uri
- end
-
- # Exceptions to how a driver class is determined for a given URI
- driver_class = if driver_name == 'sqlserver'
- 'SqlServer'
- else
- driver_name.capitalize
- end
-
- DataObjects.const_get(driver_class)::Connection.new(conn_uri)
- end
-
- # Ensure that all Connection subclasses handle pooling and logging uniformly.
- # See also Extlib::Pooling and DataObjects::Logger
- def self.inherited(target)
- target.class_eval do
-
- # Allocate a Connection object from the pool, creating one if necessary. This method is active in Connection subclasses only.
- def self.new(*args)
- instance = allocate
- instance.send(:initialize, *args)
- instance
- end
-
- include Extlib::Pooling
- include Quoting
-
- alias close release
- end
-
- if driver_module_name = target.name.split('::')[-2]
- driver_module = DataObjects::const_get(driver_module_name)
- driver_module.class_eval <<-EOS, __FILE__, __LINE__
- def self.logger
- @logger
- end
-
- def self.logger=(logger)
- @logger = logger
- end
- EOS
-
- driver_module.logger = DataObjects::Logger.new(nil, :off)
- end
- end
-
- #####################################################
- # Standard API Definition
- #####################################################
-
- # Show the URI for this connection
- def to_s
- @uri.to_s
- end
-
- def initialize(uri) #:nodoc:
- raise NotImplementedError.new
- end
-
- def dispose #:nodoc:
- raise NotImplementedError.new
- end
-
- # Create a Command object of the right subclass using the given text
- def create_command(text)
- concrete_command.new(self, text)
- end
-
- private
- def concrete_command
- @concrete_command || begin
-
- class << self
- private
- def concrete_command
- @concrete_command
- end
- end
-
- @concrete_command = DataObjects::const_get(self.class.name.split('::')[-2]).const_get('Command')
- end
- end
-
- end
-end
diff --git a/lib/data_objects/error.rb b/lib/data_objects/error.rb
deleted file mode 100644
index 66adf74..0000000
--- a/lib/data_objects/error.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- class Error < StandardError
- end
-end
diff --git a/lib/data_objects/error/connection_error.rb b/lib/data_objects/error/connection_error.rb
deleted file mode 100644
index 3643b60..0000000
--- a/lib/data_objects/error/connection_error.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- class ConnectionError < SQLError
- end
-end
diff --git a/lib/data_objects/error/data_error.rb b/lib/data_objects/error/data_error.rb
deleted file mode 100644
index 04e8da2..0000000
--- a/lib/data_objects/error/data_error.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- class DataError < SQLError
- end
-end
diff --git a/lib/data_objects/error/integrity_error.rb b/lib/data_objects/error/integrity_error.rb
deleted file mode 100644
index e9d1e0d..0000000
--- a/lib/data_objects/error/integrity_error.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- class IntegrityError < SQLError
- end
-end
diff --git a/lib/data_objects/error/sql_error.rb b/lib/data_objects/error/sql_error.rb
deleted file mode 100644
index 01ec76c..0000000
--- a/lib/data_objects/error/sql_error.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-module DataObjects
- class SQLError < Error
-
- attr_reader :message
- attr_reader :code
- attr_reader :sqlstate
- attr_reader :query
- attr_reader :uri
-
- def initialize(message, code = nil, sqlstate = nil, query = nil, uri = nil)
- @message = message
- @code = code
- @sqlstate = sqlstate
- @query = query
- @uri = uri
- end
-
- def to_s
- "#{message} (code: #{code}, sql state: #{sqlstate}, query: #{query}, uri: #{uri})"
- end
- end
-end
diff --git a/lib/data_objects/error/syntax_error.rb b/lib/data_objects/error/syntax_error.rb
deleted file mode 100644
index 813fe76..0000000
--- a/lib/data_objects/error/syntax_error.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- class SyntaxError < SQLError
- end
-end
diff --git a/lib/data_objects/error/transaction_error.rb b/lib/data_objects/error/transaction_error.rb
deleted file mode 100644
index bd2c271..0000000
--- a/lib/data_objects/error/transaction_error.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- class TransactionError < SQLError
- end
-end
diff --git a/lib/data_objects/logger.rb b/lib/data_objects/logger.rb
deleted file mode 100644
index 19a7c64..0000000
--- a/lib/data_objects/logger.rb
+++ /dev/null
@@ -1,241 +0,0 @@
-require "time" # httpdate
-
-module DataObjects
-
- class << self
- # The global logger for DataObjects
- attr_accessor :logger
- end
-
- # ==== Public DataObjects Logger API
- #
- # Logger taken from Merb :)
- #
- # To replace an existing logger with a new one:
- # DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})
- #
- # Available logging levels are
- # DataObjects::Logger::{ Fatal, Error, Warn, Info, Debug }
- #
- # Logging via:
- # DataObjects.logger.fatal(message<String>)
- # DataObjects.logger.error(message<String>)
- # DataObjects.logger.warn(message<String>)
- # DataObjects.logger.info(message<String>)
- # DataObjects.logger.debug(message<String>)
- #
- # Flush the buffer to
- # DataObjects.logger.flush
- #
- # Remove the current log object
- # DataObjects.logger.close
- #
- # ==== Private DataObjects Logger API
- #
- # To initialize the logger you create a new object, proxies to set_log.
- # DataObjects::Logger.new(log{String, IO},level{Symbol, String})
- #
- # Logger will not create the file until something is actually logged
- # This avoids file creation on DataObjects init when it creates the
- # default logger.
- class Logger
-
- # Use asynchronous I/O?
- attr_accessor :aio
- # delimiter to use between message sections
- attr_accessor :delimiter
- # a symbol representing the log level from {:off, :fatal, :error, :warn, :info, :debug}
- attr_reader :level
- # Direct access to the buffer
- attr_reader :buffer
- # The name of the log file
- attr_reader :log
-
- # @note
- # Ruby (standard) logger levels:
- # off: absolutely nothing
- # fatal: an unhandleable error that results in a program crash
- # error: a handleable error condition
- # warn: a warning
- # info: generic (useful) information about system operation
- # debug: low-level information for developers
- #
- # DataObjects::Logger::LEVELS[:off, :fatal, :error, :warn, :info, :debug]
- LEVELS =
- {
- :off => 99999,
- :fatal => 7,
- :error => 6,
- :warn => 4,
- :info => 3,
- :debug => 0
- }
-
- # Set the log level (use the level symbols as documented)
- def level=(new_level)
- @level = LEVELS[new_level.to_sym]
- reset_methods(:close)
- end
-
- private
-
- # The idea here is that instead of performing an 'if' conditional check on
- # each logging we do it once when the log object is setup
- def set_write_method
- @log.instance_eval do
-
- # Determine if asynchronous IO can be used
- def aio?
- @aio = !RUBY_PLATFORM.match(/java|mswin/) &&
- !(@log == STDOUT) &&
- @log.respond_to?(:write_nonblock)
- end
-
- # Define the write method based on if aio an be used
- undef write_method if defined? write_method
- if aio?
- alias :write_method :write_nonblock
- else
- alias :write_method :write
- end
- end
- end
-
- def initialize_log(log)
- close if @log # be sure that we don't leave open files laying around.
- @log = log || "log/dm.log"
- end
-
- def reset_methods(o_or_c)
- if o_or_c == :open
- alias internal_push push_opened
- elsif o_or_c == :close
- alias internal_push push_closed
- end
- end
-
- def push_opened(string)
- message = Time.now.httpdate
- message << delimiter
- message << string
- message << "\n" unless message[-1] == ?\n
- @buffer << message
- flush # Force a flush for now until we figure out where we want to use the buffering.
- end
-
- def push_closed(string)
- unless @log.respond_to?(:write)
- log = Pathname(@log)
- log.dirname.mkpath
- @log = log.open('a')
- @log.sync = true
- end
- set_write_method
- reset_methods(:open)
- push(string)
- end
-
- alias internal_push push_closed
-
- def prep_msg(message, level)
- level << delimiter << message
- end
-
- public
-
- # To initialize the logger you create a new object, proxies to set_log.
- # DataObjects::Logger.new(log{String, IO},level{Symbol, String})
- #
- # @param log<IO,String> either an IO object or a name of a logfile.
- # @param log_level<String> the message string to be logged
- # @param delimiter<String> delimiter to use between message sections
- # @param log_creation<Boolean> log that the file is being created
- def initialize(*args)
- set_log(*args)
- end
-
- # To replace an existing logger with a new one:
- # DataObjects::Logger.set_log(log{String, IO},level{Symbol, String})
- #
- #
- # @param log<IO,String> either an IO object or a name of a logfile.
- # @param log_level<Symbol> a symbol representing the log level from
- # {:off, :fatal, :error, :warn, :info, :debug}
- # @param delimiter<String> delimiter to use between message sections
- # @param log_creation<Boolean> log that the file is being created
- def set_log(log, log_level = :off, delimiter = " ~ ", log_creation = false)
- delimiter ||= " ~ "
-
- if log_level && LEVELS[log_level.to_sym]
- self.level = log_level.to_sym
- else
- self.level = :debug
- end
-
- @buffer = []
- @delimiter = delimiter
-
- initialize_log(log)
-
- DataObjects.logger = self
-
- self.info("Logfile created") if log_creation
- end
-
- # Flush the entire buffer to the log object.
- # DataObjects.logger.flush
- #
- def flush
- return unless @buffer.size > 0
- @log.write_method(@buffer.slice!(0..-1).join)
- end
-
- # Close and remove the current log object.
- # DataObjects.logger.close
- #
- def close
- flush
- @log.close if @log.respond_to?(:close)
- @log = nil
- end
-
- # Appends a string and log level to logger's buffer.
-
- # @note
- # Note that the string is discarded if the string's log level less than the
- # logger's log level.
- # @note
- # Note that if the logger is aio capable then the logger will use
- # non-blocking asynchronous writes.
- #
- # @param level<Fixnum> the logging level as an integer
- # @param string<String> the message string to be logged
- def push(string)
- internal_push(string)
- end
- alias << push
-
- # Generate the following logging methods for DataObjects.logger as described
- # in the API:
- # :fatal, :error, :warn, :info, :debug
- # :off only gets an off? method
- LEVELS.each_pair do |name, number|
- unless name.to_sym == :off
- class_eval <<-EOS, __FILE__, __LINE__
- # DOC
- def #{name}(message)
- self.<<( prep_msg(message, "#{name}") ) if #{name}?
- end
- EOS
- end
-
- class_eval <<-EOS, __FILE__, __LINE__
- # DOC
- def #{name}?
- #{number} >= level
- end
- EOS
- end
-
- end # class Logger
-end # module DataObjects
diff --git a/lib/data_objects/quoting.rb b/lib/data_objects/quoting.rb
deleted file mode 100755
index c1d2172..0000000
--- a/lib/data_objects/quoting.rb
+++ /dev/null
@@ -1,99 +0,0 @@
-module DataObjects
-
- module Quoting
-
- # Quote a value of any of the recognised data types
- def quote_value(value)
- return 'NULL' if value.nil?
-
- case value
- when Numeric then quote_numeric(value)
- when ::Extlib::ByteArray then quote_byte_array(value)
- when String then quote_string(value)
- when Time then quote_time(value)
- when DateTime then quote_datetime(value)
- when Date then quote_date(value)
- when TrueClass, FalseClass then quote_boolean(value)
- when Array then quote_array(value)
- when Range then quote_range(value)
- when Symbol then quote_symbol(value)
- when Regexp then quote_regexp(value)
- when Class then quote_class(value)
- else
- if value.respond_to?(:to_sql)
- value.to_sql
- else
- raise "Don't know how to quote #{value.class} objects (#{value.inspect})"
- end
- end
- end
-
- # Convert the Symbol to a String and quote that
- def quote_symbol(value)
- quote_string(value.to_s)
- end
-
- # Convert the Numeric to a String and quote that
- def quote_numeric(value)
- value.to_s
- end
-
- # Quote a String for SQL by doubling any embedded single-quote characters
- def quote_string(value)
- "'#{value.gsub("'", "''")}'"
- end
-
- # Quote a class by quoting its name
- def quote_class(value)
- quote_string(value.name)
- end
-
- # Convert a Time to standard YMDHMS format (with microseconds if necessary)
- def quote_time(value)
- offset = value.utc_offset
- if offset >= 0
- offset_string = "+#{sprintf("%02d", offset / 3600)}:#{sprintf("%02d", (offset % 3600) / 60)}"
- elsif offset < 0
- offset_string = "-#{sprintf("%02d", -offset / 3600)}:#{sprintf("%02d", (-offset % 3600) / 60)}"
- end
- "'#{value.strftime('%Y-%m-%dT%H:%M:%S')}" << (value.usec > 0 ? ".#{value.usec.to_s.rjust(6, '0')}" : "") << offset_string << "'"
- end
-
- # Quote a DateTime by relying on it's own to_s conversion
- def quote_datetime(value)
- "'#{value.dup}'"
- end
-
- # Convert a Date to standard YMD format
- def quote_date(value)
- "'#{value.strftime("%Y-%m-%d")}'"
- end
-
- # Quote true, false as the strings TRUE, FALSE
- def quote_boolean(value)
- value.to_s.upcase
- end
-
- # Quote an array as a list of quoted values
- def quote_array(value)
- "(#{value.map { |entry| quote_value(entry) }.join(', ')})"
- end
-
- # Quote a range by joining the quoted end-point values with AND.
- # It's not clear whether or when this is a useful or correct thing to do.
- def quote_range(value)
- "#{quote_value(value.first)} AND #{quote_value(value.last)}"
- end
-
- # Quote a Regex using its string value. Note that there's no attempt to make a valid SQL "LIKE" string.
- def quote_regexp(value)
- quote_string(value.source)
- end
-
- def quote_byte_array(value)
- quote_string(value)
- end
-
- end
-
-end
diff --git a/lib/data_objects/reader.rb b/lib/data_objects/reader.rb
deleted file mode 100644
index 6acb578..0000000
--- a/lib/data_objects/reader.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-module DataObjects
- # Abstract class to read rows from a query result
- class Reader
-
- # Return the array of field names
- def fields
- raise NotImplementedError.new
- end
-
- # Return the array of field values for the current row. Not legal after next! has returned false or before it's been called
- def values
- raise NotImplementedError.new
- end
-
- # Close the reader discarding any unread results.
- def close
- raise NotImplementedError.new
- end
-
- # Discard the current row (if any) and read the next one (returning true), or return nil if there is no further row.
- def next!
- raise NotImplementedError.new
- end
-
- # Return the number of fields in the result set.
- def field_count
- raise NotImplementedError.new
- end
-
- end
-end
diff --git a/lib/data_objects/result.rb b/lib/data_objects/result.rb
deleted file mode 100644
index ea9632b..0000000
--- a/lib/data_objects/result.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module DataObjects
- # The Result class is returned from Connection#execute_non_query.
- class Result
- # The ID of a row inserted by the Command
- attr_accessor :insert_id
- # The number of rows affected by the Command
- attr_accessor :affected_rows
-
- # Create a new Result. Used internally in the adapters.
- def initialize(command, affected_rows, insert_id = nil)
- @command, @affected_rows, @insert_id = command, affected_rows, insert_id
- end
-
- # Return the number of affected rows
- def to_i
- @affected_rows
- end
- end
-end
diff --git a/lib/data_objects/spec/command_spec.rb b/lib/data_objects/spec/command_spec.rb
deleted file mode 100644
index 4c5f9be..0000000
--- a/lib/data_objects/spec/command_spec.rb
+++ /dev/null
@@ -1,222 +0,0 @@
-WINDOWS = Gem.win_platform?
-
-share_examples_for 'a Command' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- @command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
- @reader = @connection.create_command("SELECT code, name FROM widgets WHERE ad_description = ?")
- end
-
- after :each do
- @connection.close
- end
-
- it { @command.should be_kind_of(DataObjects::Command) }
-
- it { @command.should respond_to(:execute_non_query) }
-
- describe 'execute_non_query' do
-
- describe 'with an invalid statement' do
-
- before :each do
- @invalid_command = @connection.create_command("INSERT INTO non_existent_table (tester) VALUES (1)")
- end
-
- it 'should raise an error on an invalid query' do
- lambda { @invalid_command.execute_non_query }.should raise_error
- end
-
- it 'should raise an error with too few binding parameters' do
- lambda { @command.execute_non_query("Too", "Many") }.should raise_error(ArgumentError, "Binding mismatch: 2 for 1")
- end
-
- it 'should raise an error with too many binding parameters' do
- lambda { @command.execute_non_query }.should raise_error(ArgumentError, "Binding mismatch: 0 for 1")
- end
-
- end
-
- describe 'with a valid statement' do
-
- it 'should not raise an error with an explicit nil as parameter' do
- lambda { @command.execute_non_query(nil) }.should_not raise_error
- end
-
- end
-
- describe 'with a valid statement and ? inside quotes' do
-
- before :each do
- @command_with_quotes = @connection.create_command("INSERT INTO users (name) VALUES ('will it work? ')")
- end
-
- it 'should not raise an error' do
- lambda { @command_with_quotes.execute_non_query }.should_not raise_error
- end
-
- end
-
- end
-
- it { @command.should respond_to(:execute_reader) }
-
- describe 'execute_reader' do
-
- describe 'with an invalid reader' do
-
- before :each do
- @invalid_reader = @connection.create_command("SELECT * FROM non_existent_widgets WHERE ad_description = ?")
- end
-
- it 'should raise an error on an invalid query' do
- lambda { @invalid_reader.execute_reader }.should raise_error
- end
-
- it 'should raise an error with too few binding parameters' do
- lambda { @reader.execute_reader("Too", "Many") }.should raise_error(ArgumentError, "Binding mismatch: 2 for 1")
- end
-
- it 'should raise an error with too many binding parameters' do
- lambda { @reader.execute_reader }.should raise_error(ArgumentError, "Binding mismatch: 0 for 1")
- end
-
- end
-
- describe 'with a valid reader' do
-
- it 'should not raise an error with an explicit nil as parameter' do
- lambda { @reader.execute_reader(nil) }.should_not raise_error
- end
-
- end
-
- describe 'with a valid reader and ? inside column alias' do
-
- before :each do
- @reader_with_quotes = @connection.create_command("SELECT code AS \"code?\", name FROM widgets WHERE ad_description = ?")
- end
-
- it 'should not raise an error' do
- lambda { @reader_with_quotes.execute_reader(nil) }.should_not raise_error
- end
-
- end
-
-
- end
-
- it { @command.should respond_to(:set_types) }
-
- describe 'set_types' do
-
- describe 'is invalid when used with a statement' do
-
- before :each do
- @command.set_types(String)
- end
-
- it 'should raise an error when types are set' do
- lambda { @command.execute_non_query }.should raise_error
- end
-
- end
-
- describe 'with an invalid reader' do
-
- it 'should raise an error with too few types' do
- @reader.set_types(String)
- lambda { @reader.execute_reader("One parameter") }.should raise_error(ArgumentError, "Field-count mismatch. Expected 1 fields, but the query yielded 2")
- end
-
- it 'should raise an error with too many types' do
- @reader.set_types(String, String, BigDecimal)
- lambda { @reader.execute_reader("One parameter") }.should raise_error(ArgumentError, "Field-count mismatch. Expected 3 fields, but the query yielded 2")
- end
-
- end
-
- describe 'with a valid reader' do
-
- it 'should not raise an error with correct number of types' do
- @reader.set_types(String, String)
- lambda { @result = @reader.execute_reader('Buy this product now!') }.should_not raise_error
- lambda { @result.next! }.should_not raise_error
- lambda { @result.values }.should_not raise_error
- @result.close
- end
-
- it 'should also support old style array argument types' do
- @reader.set_types([String, String])
- lambda { @result = @reader.execute_reader('Buy this product now!') }.should_not raise_error
- lambda { @result.next! }.should_not raise_error
- lambda { @result.values }.should_not raise_error
- @result.close
- end
-
- end
-
- end
-
- it { @command.should respond_to(:to_s) }
-
- describe 'to_s' do
-
- end
-
-
-end
-
-share_examples_for 'a Command with async' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- describe 'running queries in parallel' do
-
- before :each do
-
- threads = []
-
- @start = Time.now
- 4.times do |i|
- threads << Thread.new do
- connection = DataObjects::Connection.new(CONFIG.uri)
- command = connection.create_command(CONFIG.sleep)
- if CONFIG.sleep =~ /^SELECT/i
- reader = command.execute_reader
- reader.next!
- reader.close
- else
- result = command.execute_non_query
- end
- connection.close
- end
- end
-
- threads.each{|t| t.join }
- @finish = Time.now
- end
-
- after :each do
- @connection.close
- end
-
- it "should finish within 2 seconds" do
- pending_if("Ruby on Windows doesn't support asynchronious operations", WINDOWS) do
- (@finish - @start).should < 2
- end
- end
-
- end
-end
diff --git a/lib/data_objects/spec/connection_spec.rb b/lib/data_objects/spec/connection_spec.rb
deleted file mode 100644
index 0b78b60..0000000
--- a/lib/data_objects/spec/connection_spec.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-share_examples_for 'a Connection' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- it { @connection.should be_kind_of(DataObjects::Connection) }
- it { @connection.should be_kind_of(Extlib::Pooling) }
-
- it { @connection.should respond_to(:dispose) }
-
- describe 'dispose' do
-
- describe 'on open connection' do
- before do
- @open_connection = DataObjects::Connection.new("#{@driver}://#{@user}:#{@password}@#{@host}:#{@port}#{@database}")
- @open_connection.detach
- end
-
- after do
- @open_connection.close
- end
-
- it { @open_connection.dispose.should be_true }
- end
-
- describe 'on closed connection' do
- before do
- @closed_connection = DataObjects::Connection.new("#{@driver}://#{@user}:#{@password}@#{@host}:#{@port}#{@database}")
- @closed_connection.detach
- @closed_connection.dispose
- end
-
- after do
- @closed_connection.close
- end
-
- it { @closed_connection.dispose.should be_false }
-
- it 'should raise an error on creating a command' do
- lambda { @closed_connection.create_command("INSERT INTO non_existant_table (tester) VALUES (1)").execute_non_query }.should raise_error
- end
- end
-
- end
-
- it { @connection.should respond_to(:create_command) }
-
- describe 'create_command' do
- it { @connection.create_command('This is a dummy command').should be_kind_of(DataObjects::Command) }
- end
-
-end
-
-share_examples_for 'a Connection with authentication support' do
-
- before :all do
- %w[ @driver @user @password @host @port @database ].each do |ivar|
- raise "+#{ivar}+ should be defined in before block" unless instance_variable_get(ivar)
- end
-
- end
-
- describe 'with an invalid URI' do
-
- def connecting_with(uri)
- lambda { DataObjects::Connection.new(uri) }
- end
-
- it 'should raise an error if no database specified' do
- connecting_with("#{@driver}://#{@user}:#{@password}@#{@host}:#{@port}").should raise_error
- end
-
- it 'should raise an error if bad username is given' do
- connecting_with("#{@driver}://thisreallyshouldntexist:#{@password}@#{@host}:#{@port}#{@database}").should raise_error
- end
-
- it 'should raise an error if bad password is given' do
- connecting_with("#{@driver}://#{@user}:completelyincorrectpassword:#{@host}:#{@port}#{@database}").should raise_error
- end
-
- it 'should raise an error if an invalid port is given' do
- connecting_with("#{@driver}://#{@user}:#{@password}:#{@host}:648646543#{@database}").should raise_error
- end
-
- it 'should raise an error if an invalid database is given' do
- connecting_with("#{@driver}://#{@user}:#{@password}:#{@host}:#{@port}/someweirddatabase").should raise_error
- end
-
- it 'should raise an error with a meaningless URI' do
- connecting_with("#{@driver}://peekaboo$2!@#4543").should raise_error
- end
-
- end
-
-end
-
-share_examples_for 'a Connection with SSL support' do
-
- if DataObjectsSpecHelpers.test_environment_supports_ssl?
- describe 'connecting with SSL' do
-
- it 'should connect securely' do
- DataObjects::Connection.new("#{CONFIG.uri}?#{CONFIG.ssl}").secure?.should be_true
- end
-
- end
- end
-
- describe 'connecting without SSL' do
-
- it 'should not connect securely' do
- DataObjects::Connection.new(CONFIG.uri).secure?.should be_false
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/encoding_spec.rb b/lib/data_objects/spec/encoding_spec.rb
deleted file mode 100644
index 4b14e17..0000000
--- a/lib/data_objects/spec/encoding_spec.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-share_examples_for 'a driver supporting encodings' do
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
-
- it { @connection.should respond_to(:character_set) }
-
- describe 'character_set' do
-
- it 'uses utf8 by default' do
- @connection.character_set.should == 'UTF-8'
- end
-
- describe 'sets the character set through the URI' do
- before do
- # @latin1_connection = DataObjects::Connection.new("#{CONFIG.uri}?encoding=latin1")
- @latin1_connection = DataObjects::Connection.new("#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}?encoding=ISO-8859-1")
- end
-
- after { @latin1_connection.close }
-
- it { @latin1_connection.character_set.should == 'ISO-8859-1' }
- end
-
- describe 'uses UTF-8 when an invalid encoding is given' do
- before do
- @latin1_connection = DataObjects::Connection.new("#{CONFIG.scheme}://#{CONFIG.user}:#{CONFIG.pass}@#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}?encoding=ISO-INVALID")
- end
-
- after { @latin1_connection.close }
-
- it { @latin1_connection.character_set.should == 'UTF-8' }
- end
-
-
- end
-end
diff --git a/lib/data_objects/spec/quoting_spec.rb b/lib/data_objects/spec/quoting_spec.rb
deleted file mode 100644
index e69de29..0000000
diff --git a/lib/data_objects/spec/reader_spec.rb b/lib/data_objects/spec/reader_spec.rb
deleted file mode 100644
index 941d648..0000000
--- a/lib/data_objects/spec/reader_spec.rb
+++ /dev/null
@@ -1,156 +0,0 @@
-share_examples_for 'a Reader' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- @reader = @connection.create_command("SELECT code, name FROM widgets WHERE ad_description = ? order by id").execute_reader('Buy this product now!')
- end
-
- after :each do
- @reader.close
- @connection.close
- end
-
- it { @reader.should respond_to(:fields) }
-
- describe 'fields' do
-
- it 'should return the correct fields in the reader' do
- # we downcase the field names as some drivers such as do_derby, do_h2,
- # do_hsqldb return the field names as uppercase
- @reader.fields.map{ |f| f.downcase }.should == ['code', 'name']
- end
-
- end
-
- it { @reader.should respond_to(:values) }
-
- describe 'values' do
-
- describe 'when the reader is uninitialized' do
-
- it 'should raise an error' do
- lambda { @reader.values }.should raise_error
- end
-
- end
-
- describe 'when the reader is moved to the first result' do
-
- before do
- @reader.next!
- end
-
- it 'should return the correct first set of in the reader' do
- @reader.values.should == ["W0000001", "Widget 1"]
- end
-
- end
-
- describe 'when the reader is moved to the second result' do
-
- before do
- @reader.next!; @reader.next!
- end
-
- it 'should return the correct first set of in the reader' do
- @reader.values.should == ["W0000002", "Widget 2"]
- end
-
- end
-
- describe 'when the reader is moved to the end' do
-
- before do
- while @reader.next! ; end
- end
-
- it 'should raise an error again' do
- lambda { @reader.values }.should raise_error
- end
- end
-
- end
-
- it { @reader.should respond_to(:close) }
-
- describe 'close' do
-
- describe 'on an open reader' do
-
- it 'should return true' do
- @reader.close.should be_true
- end
-
- end
-
- describe 'on an already closed reader' do
-
- before do
- @reader.close
- end
-
- it 'should return false' do
- @reader.close.should be_false
- end
-
- end
-
- end
-
- it { @reader.should respond_to(:next!) }
-
- describe 'next!' do
-
- describe 'successfully moving the cursor initially' do
-
- it 'should return true' do
- @reader.next!.should be_true
- end
-
- end
-
- describe 'moving the cursor' do
-
- before do
- @reader.next!
- end
-
- it 'should move the cursor to the next value' do
- lambda { @reader.next! }.should change(@reader, :values).
- from(["W0000001", "Widget 1"]).
- to(["W0000002", "Widget 2"])
- end
-
- end
-
- describe 'arriving at the end of the reader' do
-
- before do
- while @reader.next!; end
- end
-
- it 'should return false when the end is reached' do
- @reader.next!.should be_false
- end
-
- end
-
- end
-
- it { @reader.should respond_to(:field_count) }
-
- describe 'field_count' do
-
- it 'should count the number of fields' do
- @reader.field_count.should == 2
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/result_spec.rb b/lib/data_objects/spec/result_spec.rb
deleted file mode 100644
index 3f2a111..0000000
--- a/lib/data_objects/spec/result_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-share_examples_for 'a Result' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- @result = @connection.create_command("INSERT INTO users (name) VALUES (?)").execute_non_query("monkey")
- end
-
- after :each do
- @connection.close
- end
-
- it { @result.should respond_to(:affected_rows) }
-
- describe 'affected_rows' do
-
- it 'should return the number of affected rows' do
- @result.affected_rows.should == 1
- end
-
- end
-
-end
-
-share_examples_for 'a Result which returns inserted keys' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
- # execute the command twice and expose the second result
- command.execute_non_query("monkey")
- @result = command.execute_non_query("monkey")
- end
-
- after :each do
- @connection.close
- end
-
- it { @result.should respond_to(:affected_rows) }
-
- describe 'insert_id' do
-
- it 'should return the number of affected rows' do
- # This is actually the 2nd record inserted
- @result.insert_id.should == 2
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/array_spec.rb b/lib/data_objects/spec/typecast/array_spec.rb
deleted file mode 100644
index c580772..0000000
--- a/lib/data_objects/spec/typecast/array_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-share_examples_for 'supporting Array' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'passing an Array as a parameter in execute_reader' do
-
- before do
- @reader = @connection.create_command("SELECT * FROM widgets WHERE id in ?").execute_reader([2,3,4,5])
- end
-
- after do
- @reader.close
- end
-
- it 'should return correct number of rows' do
- counter = 0
- while(@reader.next!) do
- counter += 1
- end
- counter.should == 4
- end
-
- end
-end
diff --git a/lib/data_objects/spec/typecast/bigdecimal_spec.rb b/lib/data_objects/spec/typecast/bigdecimal_spec.rb
deleted file mode 100644
index 5e663ec..0000000
--- a/lib/data_objects/spec/typecast/bigdecimal_spec.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-share_examples_for 'supporting BigDecimal' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a BigDecimal' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT cost1 FROM widgets WHERE ad_description = ?")
- @command.set_types(BigDecimal)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(BigDecimal)
- end
-
- it 'should return the correct result' do
- # rounding seems necessary for the jruby do_derby driver
- @values.first.round(2).should == 10.23
- end
-
- end
-
- describe 'with manual typecasting a nil value' do
-
- before do
- @command = @connection.create_command("SELECT cost2 FROM widgets WHERE id = ?")
- @command.set_types(BigDecimal)
- @reader = @command.execute_reader(6)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return the correct result' do
- @values.first.should be_nil
- end
-
- end
-
- end
-
- describe 'writing an Integer' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(BigDecimal("2.0"))
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- @values.first.should == 2
- end
-
- end
-
-end
-
-share_examples_for 'supporting BigDecimal autocasting' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a BigDecimal' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT cost2 FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(BigDecimal)
- end
-
- it 'should return the correct result' do
- @values.first.should == 50.23
- end
-
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/boolean_spec.rb b/lib/data_objects/spec/typecast/boolean_spec.rb
deleted file mode 100644
index cf3d1c4..0000000
--- a/lib/data_objects/spec/typecast/boolean_spec.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-share_examples_for 'supporting Boolean' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Boolean' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT flags FROM widgets WHERE ad_description = ?")
- @command.set_types(TrueClass)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(FalseClass)
- end
-
- it 'should return the correct result' do
- @values.first.should == false
- end
-
- end
-
- describe 'with manual typecasting a nil value' do
-
- before do
- @command = @connection.create_command("SELECT flags FROM widgets WHERE id = ?")
- @command.set_types(TrueClass)
- @reader = @command.execute_reader(4)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return the correct result' do
- @values.first.should be_nil
- end
-
- end
-
- end
-
- describe 'writing an Boolean' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE flags = ?").execute_reader(true)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- @values.first.should == 2
- end
-
- end
-
-end
-
-share_examples_for 'supporting Boolean autocasting' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Boolean' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT flags FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(FalseClass)
- end
-
- it 'should return the correct result' do
- @values.first.should == false
- end
-
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/byte_array_spec.rb b/lib/data_objects/spec/typecast/byte_array_spec.rb
deleted file mode 100644
index d3033a6..0000000
--- a/lib/data_objects/spec/typecast/byte_array_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-share_examples_for 'supporting ByteArray' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a ByteArray' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(::Extlib::ByteArray)
- end
-
- it 'should return the correct result' do
- @values.first.should == "CAD \001 \000 DRAWING"
- end
-
- end
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?")
- @command.set_types(::Extlib::ByteArray)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(::Extlib::ByteArray)
- end
-
- it 'should return the correct result' do
- @values.first.should == "CAD \001 \000 DRAWING"
- end
-
- end
-
- end
-
- describe 'writing a ByteArray' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(::Extlib::ByteArray.new("2"))
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 2 or val == 1 }
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/class_spec.rb b/lib/data_objects/spec/typecast/class_spec.rb
deleted file mode 100644
index f185170..0000000
--- a/lib/data_objects/spec/typecast/class_spec.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-share_examples_for 'supporting Class' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Class' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE ad_description = ?")
- @command.set_types(Class)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Class)
- end
-
- it 'should return the correct result' do
- @values.first.should == String
- end
-
- end
-
- end
-
- describe 'writing a Class' do
-
- before do
- @reader = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE whitepaper_text = ?").execute_reader(String)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- @values.first.should == "String"
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/date_spec.rb b/lib/data_objects/spec/typecast/date_spec.rb
deleted file mode 100644
index 4b21046..0000000
--- a/lib/data_objects/spec/typecast/date_spec.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-share_examples_for 'supporting Date' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Date' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT release_datetime FROM widgets WHERE ad_description = ?")
- @command.set_types(Date)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Date)
- end
-
- it 'should return the correct result' do
- @values.first.should == Date.civil(2008, 2, 14)
- end
-
- end
-
- describe 'with manual typecasting a nil value' do
-
- before do
- @command = @connection.create_command("SELECT release_date FROM widgets WHERE id = ?")
- @command.set_types(Date)
- @reader = @command.execute_reader(7)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return a nil class' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return nil' do
- @values.first.should be_nil
- end
-
- end
-
- end
-
- describe 'writing an Date' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE release_date = ? ORDER BY id").execute_reader(Date.civil(2008, 2, 14))
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 1 or val == 0 }
- end
-
- end
-
-end
-
-share_examples_for 'supporting Date autocasting' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Date' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT release_date FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Date)
- end
-
- it 'should return the correct result' do
- @values.first.should == Date.civil(2008, 2, 14)
- end
-
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/datetime_spec.rb b/lib/data_objects/spec/typecast/datetime_spec.rb
deleted file mode 100644
index 6c710c3..0000000
--- a/lib/data_objects/spec/typecast/datetime_spec.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-JRUBY = RUBY_PLATFORM =~ /java/ unless defined?(JRUBY)
-
-share_examples_for 'supporting DateTime' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a DateTime' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT release_date FROM widgets WHERE ad_description = ?")
- @command.set_types(DateTime)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(DateTime)
- end
-
- it 'should return the correct result' do
- date = @values.first
- Date.civil(date.year, date.mon, date.day).should == Date.civil(2008, 2, 14)
- end
-
- end
-
- describe 'with manual typecasting a nil value' do
-
- before do
- @command = @connection.create_command("SELECT release_datetime FROM widgets WHERE id = ?")
- @command.set_types(DateTime)
- @reader = @command.execute_reader(8)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return a nil class' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return nil' do
- @values.first.should be_nil
- end
-
- end
-
- end
-
- describe 'writing an DateTime' do
-
- before do
- local_offset = Rational(Time.local(2008, 2, 14).utc_offset, 86400)
- @reader = @connection.create_command("SELECT id FROM widgets WHERE release_datetime = ? ORDER BY id").execute_reader(DateTime.civil(2008, 2, 14, 00, 31, 12, local_offset))
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 0 or val == 1 }
- end
-
- end
-
-end
-
-share_examples_for 'supporting DateTime autocasting' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a DateTime' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT release_datetime FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(DateTime)
- end
-
- it 'should return the correct result' do
- pending "when this is fixed for DST issues"
- @values.first.should == Time.local(2008, 2, 14, 00, 31, 12).to_datetime
- end
-
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/float_spec.rb b/lib/data_objects/spec/typecast/float_spec.rb
deleted file mode 100644
index 9757b92..0000000
--- a/lib/data_objects/spec/typecast/float_spec.rb
+++ /dev/null
@@ -1,134 +0,0 @@
-share_examples_for 'supporting Float' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Float' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT id FROM widgets WHERE ad_description = ?")
- @command.set_types(Float)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Float)
- end
-
- it 'should return the correct result' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 1.0 or val == 0.0 }
- end
-
- end
-
- describe 'with manual typecasting a nil' do
-
- before do
- @command = @connection.create_command("SELECT cost1 FROM widgets WHERE id = ?")
- @command.set_types(Float)
- @reader = @command.execute_reader(5)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return the correct result' do
- @values.first.should be_nil
- end
-
- end
- end
-
- describe 'writing an Float' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(2.0)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 1 or val == 2 }
- end
-
- end
-
-end
-
-share_examples_for 'supporting Float autocasting' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Float' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT weight, cost1 FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Float)
- @values.last.should be_kind_of(Float)
- end
-
- it 'should return the correct result' do
- @values.first.should == 13.4
- BigDecimal.new(@values.last.to_s).round(2).should == 10.23
- end
-
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/integer_spec.rb b/lib/data_objects/spec/typecast/integer_spec.rb
deleted file mode 100644
index 5c1a639..0000000
--- a/lib/data_objects/spec/typecast/integer_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-share_examples_for 'supporting Integer' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading an Integer' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Integer)
- end
-
- it 'should return the correct result' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 1 or val == 0 }
- end
-
- end
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT weight FROM widgets WHERE ad_description = ?")
- @command.set_types(Integer)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Integer)
- end
-
- it 'should return the correct result' do
- @values.first.should == 13
- end
-
- end
-
- end
-
- describe 'writing an Integer' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(2)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- @values.first.should == 2
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/ipaddr_spec.rb b/lib/data_objects/spec/typecast/ipaddr_spec.rb
deleted file mode 100644
index e69de29..0000000
diff --git a/lib/data_objects/spec/typecast/nil_spec.rb b/lib/data_objects/spec/typecast/nil_spec.rb
deleted file mode 100644
index 7b27381..0000000
--- a/lib/data_objects/spec/typecast/nil_spec.rb
+++ /dev/null
@@ -1,131 +0,0 @@
-share_examples_for 'supporting Nil' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Nil' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT flags FROM widgets WHERE ad_description = ?")
- @command.set_types(NilClass)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return the correct result' do
- @values.first.should == nil
- end
-
- end
-
- end
-
-end
-
-share_examples_for 'supporting writing an Nil' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
-
- describe 'supporting writing an Nil' do
- # see as an example oracle
- # http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements005.htm#sthref487
- # http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions013.htm#i1050801
-
- describe 'as a parameter' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE ad_description IN (?) ORDER BY id").execute_reader(nil)
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- @reader.next!.should be_false
- end
-
- end
-
- end
-
-end
-
-share_examples_for 'supporting Nil autocasting' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Nil' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT ad_description FROM widgets WHERE id = ?").execute_reader(3)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return the correct result' do
- @values.first.should == nil
- end
-
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/range_spec.rb b/lib/data_objects/spec/typecast/range_spec.rb
deleted file mode 100644
index a1d823e..0000000
--- a/lib/data_objects/spec/typecast/range_spec.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-share_examples_for 'supporting Range' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'passing a Range as a parameter in execute_reader' do
-
- before do
- @reader = @connection.create_command("SELECT * FROM widgets WHERE id between ?").execute_reader(2..5)
- end
-
- after do
- @reader.close
- end
-
- it 'should return correct number of rows' do
- counter = 0
- while(@reader.next!) do
- counter += 1
- end
- counter.should == 4
- end
-
- end
-end
diff --git a/lib/data_objects/spec/typecast/string_spec.rb b/lib/data_objects/spec/typecast/string_spec.rb
deleted file mode 100644
index 4b15afb..0000000
--- a/lib/data_objects/spec/typecast/string_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-share_examples_for 'supporting String' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a String' do
-
- describe 'with automatic typecasting' do
-
- before do
- @reader = @connection.create_command("SELECT code FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(String)
- end
-
- it 'should return the correct result' do
- @values.first.should == "W0000001"
- end
-
- end
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT weight FROM widgets WHERE ad_description = ?")
- @command.set_types(String)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(String)
- end
-
- it 'should return the correct result' do
- @values.first.should == "13.4"
- end
-
- end
-
- end
-
- describe 'writing a String' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader("2")
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- # Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 1 or val == 2 }
- end
-
- end
-
-end
diff --git a/lib/data_objects/spec/typecast/time_spec.rb b/lib/data_objects/spec/typecast/time_spec.rb
deleted file mode 100644
index ddd9085..0000000
--- a/lib/data_objects/spec/typecast/time_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-share_examples_for 'supporting Time' do
-
- include DataObjectsSpecHelpers
-
- before :all do
- setup_test_environment
- end
-
- before :each do
- @connection = DataObjects::Connection.new(CONFIG.uri)
- end
-
- after :each do
- @connection.close
- end
-
- describe 'reading a Time' do
-
- describe 'with manual typecasting' do
-
- before do
- @command = @connection.create_command("SELECT release_date FROM widgets WHERE ad_description = ?")
- @command.set_types(Time)
- @reader = @command.execute_reader('Buy this product now!')
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correctly typed result' do
- @values.first.should be_kind_of(Time)
- end
-
- it 'should return the correct result' do
- @values.first.should == Time.local(2008, 2, 14)
- end
-
- end
-
- describe 'with manual typecasting a nil value' do
-
- before do
- @command = @connection.create_command("SELECT release_timestamp FROM widgets WHERE id = ?")
- @command.set_types(Time)
- @reader = @command.execute_reader(9)
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return a nil class' do
- @values.first.should be_kind_of(NilClass)
- end
-
- it 'should return nil' do
- @values.first.should be_nil
- end
-
- end
-
- end
-
- describe 'writing an Time' do
-
- before do
- @reader = @connection.create_command("SELECT id FROM widgets WHERE release_datetime = ? ORDER BY id").execute_reader(Time.local(2008, 2, 14, 00, 31, 12))
- @reader.next!
- @values = @reader.values
- end
-
- after do
- @reader.close
- end
-
- it 'should return the correct entry' do
- #Some of the drivers starts autoincrementation from 0 not 1
- @values.first.should satisfy { |val| val == 1 or val == 0 }
- end
-
- end
-
-end
diff --git a/lib/data_objects/transaction.rb b/lib/data_objects/transaction.rb
deleted file mode 100644
index 6c97d72..0000000
--- a/lib/data_objects/transaction.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'digest'
-require 'digest/sha2'
-
-module DataObjects
-
- class Transaction
-
- # The host name. Note, this relies on the host name being configured and resolvable using DNS
- HOST = "#{Socket::gethostbyname(Socket::gethostname)[0]}" rescue "localhost"
- @@counter = 0
-
- # The connection object allocated for this transaction
- attr_reader :connection
- # A unique ID for this transaction
- attr_reader :id
-
- # Instantiate the Transaction subclass that's appropriate for this uri scheme
- def self.create_for_uri(uri)
- uri = uri.is_a?(String) ? URI::parse(uri) : uri
- DataObjects.const_get(uri.scheme.capitalize)::Transaction.new(uri)
- end
-
- #
- # Creates a Transaction bound to a connection for the given DataObjects::URI
- #
- def initialize(uri)
- @connection = DataObjects::Connection.new(uri)
- @id = Digest::SHA256.hexdigest("#{HOST}:#{$$}:#{Time.now.to_f}:#{@@counter += 1}")
- end
-
- # Close the connection for this Transaction
- def close
- @connection.close
- end
-
- def begin
- cmd = "BEGIN"
- connection.create_command(cmd).execute_non_query
- end
-
- def commit
- cmd = "COMMIT"
- connection.create_command(cmd).execute_non_query
- end
-
- def rollback
- cmd = "ROLLBACK"
- connection.create_command(cmd).execute_non_query
- end
-
- def prepare; not_implemented; end;
- def begin_prepared; not_implemented; end;
- def commit_prepared; not_implemented; end;
- def rollback_prepared; not_implemented; end;
- def prepare; not_implemented; end;
-
- private
- def not_implemented
- raise NotImplementedError
- end
- end
-end
diff --git a/lib/data_objects/uri.rb b/lib/data_objects/uri.rb
deleted file mode 100644
index 7252337..0000000
--- a/lib/data_objects/uri.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-require 'addressable/uri'
-
-module DataObjects
-
- # A DataObjects URI is of the form scheme://user:password@host:port/path#fragment
- #
- # The elements are all optional except scheme and path:
- # scheme:: The name of a DBMS for which you have a do_\<scheme\> adapter gem installed. If scheme is *jdbc*, the actual DBMS is in the _path_ followed by a colon.
- # user:: The name of the user to authenticate to the database
- # password:: The password to use in authentication
- # host:: The domain name (defaulting to localhost) where the database is available
- # port:: The TCP/IP port number to use for the connection
- # path:: The name or path to the database
- # query:: Parameters for the connection, for example encoding=utf8
- # fragment:: Not currently known to be in use, but available to the adapters
- class URI < Struct.new(:scheme, :user, :password, :host, :port, :path, :query, :fragment)
- # Make a DataObjects::URI object by parsing a string. Simply delegates to Addressable::URI::parse.
- def self.parse(uri)
- return uri if uri.kind_of?(self)
- uri = Addressable::URI::parse(uri) unless uri.kind_of?(Addressable::URI)
- self.new(uri.scheme, uri.user, uri.password, uri.host, uri.port, uri.path, uri.query_values, uri.fragment)
- end
-
- # Display this URI object as a string
- def to_s
- string = ""
- string << "#{scheme}://" if scheme
- if user
- string << "#{user}"
- string << ":#{password}" if password
- string << "@"
- end
- string << "#{host}" if host
- string << ":#{port}" if port
- string << path.to_s
- if query
- string << "?" << query.map do |key, value|
- "#{key}=#{value}"
- end.join("&")
- end
- string << "##{fragment}" if fragment
- string
- end
-
- # Compare this URI to another for hashing
- def eql?(other)
- to_s.eql?(other.to_s)
- end
-
- # Hash this URI
- def hash
- to_s.hash
- end
- end
-end
diff --git a/lib/data_objects/version.rb b/lib/data_objects/version.rb
deleted file mode 100644
index eea3252..0000000
--- a/lib/data_objects/version.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module DataObjects
- # Current DataObjects Gem version
- VERSION = "0.10.0" unless defined?(DataObjects::VERSION)
-end
diff --git a/metadata.yml b/metadata.yml
deleted file mode 100644
index 7c27f72..0000000
--- a/metadata.yml
+++ /dev/null
@@ -1,140 +0,0 @@
---- !ruby/object:Gem::Specification
-name: data_objects
-version: !ruby/object:Gem::Version
- version: 0.10.0
-platform: ruby
-authors:
-- Dirkjan Bussink
-autorequire:
-bindir: bin
-cert_chain: []
-
-date: 2009-09-16 00:00:00 +02:00
-default_executable:
-dependencies:
-- !ruby/object:Gem::Dependency
- name: addressable
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ~>
- - !ruby/object:Gem::Version
- version: "2.0"
- version:
-- !ruby/object:Gem::Dependency
- name: extlib
- type: :runtime
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ~>
- - !ruby/object:Gem::Version
- version: 0.9.12
- version:
-- !ruby/object:Gem::Dependency
- name: rspec
- type: :development
- version_requirement:
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - ~>
- - !ruby/object:Gem::Version
- version: 1.2.0
- version:
-description: Provide a standard and simplified API for communicating with RDBMS from Ruby
-email: d.bussink at gmail.com
-executables: []
-
-extensions: []
-
-extra_rdoc_files: []
-
-files:
-- lib/data_objects/command.rb
-- lib/data_objects/connection.rb
-- lib/data_objects/error/connection_error.rb
-- lib/data_objects/error/data_error.rb
-- lib/data_objects/error/integrity_error.rb
-- lib/data_objects/error/sql_error.rb
-- lib/data_objects/error/syntax_error.rb
-- lib/data_objects/error/transaction_error.rb
-- lib/data_objects/error.rb
-- lib/data_objects/logger.rb
-- lib/data_objects/quoting.rb
-- lib/data_objects/reader.rb
-- lib/data_objects/result.rb
-- lib/data_objects/spec/command_spec.rb
-- lib/data_objects/spec/connection_spec.rb
-- lib/data_objects/spec/encoding_spec.rb
-- lib/data_objects/spec/quoting_spec.rb
-- lib/data_objects/spec/reader_spec.rb
-- lib/data_objects/spec/result_spec.rb
-- lib/data_objects/spec/typecast/array_spec.rb
-- lib/data_objects/spec/typecast/bigdecimal_spec.rb
-- lib/data_objects/spec/typecast/boolean_spec.rb
-- lib/data_objects/spec/typecast/byte_array_spec.rb
-- lib/data_objects/spec/typecast/class_spec.rb
-- lib/data_objects/spec/typecast/date_spec.rb
-- lib/data_objects/spec/typecast/datetime_spec.rb
-- lib/data_objects/spec/typecast/float_spec.rb
-- lib/data_objects/spec/typecast/integer_spec.rb
-- lib/data_objects/spec/typecast/ipaddr_spec.rb
-- lib/data_objects/spec/typecast/nil_spec.rb
-- lib/data_objects/spec/typecast/range_spec.rb
-- lib/data_objects/spec/typecast/string_spec.rb
-- lib/data_objects/spec/typecast/time_spec.rb
-- lib/data_objects/transaction.rb
-- lib/data_objects/uri.rb
-- lib/data_objects/version.rb
-- lib/data_objects.rb
-- spec/command_spec.rb
-- spec/connection_spec.rb
-- spec/do_mock.rb
-- spec/lib/pending_helpers.rb
-- spec/lib/rspec_immediate_feedback_formatter.rb
-- spec/lib/ssl_helpers.rb
-- spec/reader_spec.rb
-- spec/result_spec.rb
-- spec/spec_helper.rb
-- spec/transaction_spec.rb
-- spec/uri_spec.rb
-- tasks/gem.rake
-- tasks/install.rake
-- tasks/release.rake
-- tasks/spec.rake
-- LICENSE
-- Rakefile
-- HISTORY.markdown
-- README.markdown
-- Manifest.txt
-has_rdoc: true
-homepage: http://github.com/datamapper/do
-licenses: []
-
-post_install_message:
-rdoc_options: []
-
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: "0"
- version:
-requirements: []
-
-rubyforge_project: dorb
-rubygems_version: 1.3.4
-signing_key:
-specification_version: 3
-summary: DataObjects basic API and shared driver specifications
-test_files: []
-
diff --git a/spec/command_spec.rb b/spec/command_spec.rb
deleted file mode 100644
index 7c5d106..0000000
--- a/spec/command_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
-
-describe DataObjects::Command do
- before do
- @connection = DataObjects::Connection.new('mock://localhost')
- @command = DataObjects::Command.new(@connection, 'SQL STRING')
- end
-
- after do
- @connection.close
- end
-
- %w{connection execute_non_query execute_reader set_types}.each do |meth|
- it "should respond to ##{meth}" do
- @command.should respond_to(meth.intern)
- end
- end
-
- %w{execute_non_query execute_reader set_types}.each do |meth|
- it "should raise NotImplementedError on ##{meth}" do
- lambda { @command.send(meth.intern, nil) }.should raise_error(NotImplementedError)
- end
- end
-
-end
diff --git a/spec/connection_spec.rb b/spec/connection_spec.rb
deleted file mode 100644
index 2d5d075..0000000
--- a/spec/connection_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
-
-describe DataObjects::Connection do
- before do
- @connection = DataObjects::Connection.new('mock://localhost')
- end
-
- after do
- @connection.release
- end
-
- %w{dispose create_command}.each do |meth|
- it "should respond to ##{meth}" do
- @connection.should respond_to(meth.intern)
- end
- end
-
- it "should have #to_s that returns the connection uri string" do
- @connection.to_s.should == 'mock://localhost'
- end
-
- describe "initialization" do
-
- it "should accept a connection uri as a Addressable::URI" do
- c = DataObjects::Connection.new(Addressable::URI::parse('mock://localhost/database'))
- # relying on the fact that mock connection sets @uri
- c.to_s.should == 'mock://localhost/database'
- end
-
- it "should return the Connection specified by the scheme" do
- c = DataObjects::Connection.new(Addressable::URI.parse('mock://localhost/database'))
- c.should be_kind_of(DataObjects::Mock::Connection)
-
- c = DataObjects::Connection.new(Addressable::URI.parse('mock:jndi://jdbc/database'))
- c.should be_kind_of(DataObjects::Mock::Connection)
- end
-
- end
-end
diff --git a/spec/do_mock.rb b/spec/do_mock.rb
deleted file mode 100644
index 7ab65aa..0000000
--- a/spec/do_mock.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-module DataObjects
-
- module Mock
- class Connection < DataObjects::Connection
- def initialize(uri)
- @uri = uri
- end
-
- def dispose
- nil
- end
- end
-
- class Command < DataObjects::Command
- def execute_non_query(*args)
- Result.new(self, 0, nil)
- end
-
- def execute_reader(*args)
- Reader.new
- end
- end
-
- class Result < DataObjects::Result
- end
-
- class Reader < DataObjects::Reader
- end
- end
-
-end
diff --git a/spec/lib/pending_helpers.rb b/spec/lib/pending_helpers.rb
deleted file mode 100644
index dd1bdf5..0000000
--- a/spec/lib/pending_helpers.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module DataObjects::Spec
- module PendingHelpers
- def pending_if(message, boolean)
- if boolean
- pending(message) { yield }
- else
- yield
- end
- end
- end
-end
diff --git a/spec/lib/rspec_immediate_feedback_formatter.rb b/spec/lib/rspec_immediate_feedback_formatter.rb
deleted file mode 100644
index 8e434ae..0000000
--- a/spec/lib/rspec_immediate_feedback_formatter.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'spec/runner/formatter/base_text_formatter'
-
-# Code is based on standard SpecdocFormatter, but will print full error details as soon as they are found.
-# Successful or pending examples are written only as a dot in the output. Header is only printed if errors occur.
-#
-# To use it, add the following to your spec/spec.opts:
-# --require
-# lib/rspec_immediate_feedback_formatter.rb
-# --format
-# Spec::Runner::Formatter::ImmediateFeedbackFormatter
-
-module Spec
- module Runner
- module Formatter
- class ImmediateFeedbackFormatter < BaseTextFormatter
-
- def add_example_group(example_group)
- super
- @current_group = example_group.description
- end
-
- def example_failed(example, counter, failure)
- if @current_group
- output.puts
- output.puts @current_group
- @current_group = nil # only print the group name once
- end
-
- message = if failure.expectation_not_met?
- "- #{example.description} (FAILED - #{counter})"
- else
- "- #{example.description} (ERROR - #{counter})"
- end
-
- output.puts(red(message))
- dump_failure(counter, failure) # dump stacktrace immediately
- output.flush
- end
-
- def example_passed(*)
- output.print green('.')
- output.flush
- end
-
- def example_pending(*)
- super
- output.print yellow('*')
- output.flush
- end
- end
- end
- end
-end
diff --git a/spec/lib/ssl_helpers.rb b/spec/lib/ssl_helpers.rb
deleted file mode 100644
index 2ed11c7..0000000
--- a/spec/lib/ssl_helpers.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'cgi'
-
-module SSLHelpers
-
- CERTS_DIR = Pathname(__FILE__).dirname.join('ssl_certs').to_s
-
- CONFIG = OpenStruct.new
- CONFIG.ca_cert = CERTS_DIR / 'ca-cert.pem'
- CONFIG.ca_key = CERTS_DIR / 'ca-key.pem'
- CONFIG.server_cert = CERTS_DIR / 'server-cert.pem'
- CONFIG.server_key = CERTS_DIR / 'server-key.pem'
- CONFIG.client_cert = CERTS_DIR / 'client-cert.pem'
- CONFIG.client_key = CERTS_DIR / 'client-key.pem'
- CONFIG.cipher = 'AES128-SHA'
-
- def self.query(*keys)
- keys.map { |key| "ssl[#{key}]=#{CGI::escape(CONFIG.send(key))}" }.join('&')
- end
-
-end
diff --git a/spec/reader_spec.rb b/spec/reader_spec.rb
deleted file mode 100644
index b206326..0000000
--- a/spec/reader_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
-
-describe DataObjects::Reader do
-
- it "should define a standard API" do
- connection = DataObjects::Connection.new('mock://localhost')
-
- command = connection.create_command("SELECT * FROM example")
-
- reader = command.execute_reader
-
- reader.should respond_to(:close)
- reader.should respond_to(:next!)
- reader.should respond_to(:values)
- reader.should respond_to(:fields)
-
- connection.close
- end
-
-end
diff --git a/spec/result_spec.rb b/spec/result_spec.rb
deleted file mode 100644
index c7716f6..0000000
--- a/spec/result_spec.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
-
-describe DataObjects::Result do
-
- it "should define a standard API" do
- connection = DataObjects::Connection.new('mock://localhost')
-
- command = connection.create_command("SELECT * FROM example")
-
- result = command.execute_non_query
-
- # Affected Rows:
- result.should respond_to(:to_i)
- result.to_i.should == 0
-
- # The id of the inserted row.
- result.should respond_to(:insert_id)
- connection.close
- end
-
-end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
deleted file mode 100644
index b8aab52..0000000
--- a/spec/spec_helper.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'rubygems'
-require 'spec'
-
-dir = File.dirname(__FILE__)
-lib_path = File.expand_path("#{dir}/../lib")
-$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
-require 'data_objects'
-
-require File.expand_path(File.join(File.dirname(__FILE__), 'do_mock'))
diff --git a/spec/transaction_spec.rb b/spec/transaction_spec.rb
deleted file mode 100644
index 81ae18e..0000000
--- a/spec/transaction_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
-
-describe DataObjects::Transaction do
-
- before :each do
- @connection = mock("connection")
- DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection)
- @transaction = DataObjects::Transaction.new("mock://mock/mock")
- end
-
- it "should have a HOST constant" do
- DataObjects::Transaction::HOST.should_not == nil?
- end
-
- describe "#initialize" do
- it "should provide a connection" do
- @transaction.connection.should == @connection
- end
- it "should provide an id" do
- @transaction.id.should_not == nil
- end
- it "should provide a unique id" do
- DataObjects::Connection.should_receive(:new).with("mock://mock/mock2").once.and_return(@connection)
- @transaction.id.should_not == DataObjects::Transaction.new("mock://mock/mock2").id
- end
- end
- describe "#close" do
- it "should close its connection" do
- @connection.should_receive(:close).once
- @transaction.close
- end
- end
- [:prepare, :commit_prepared, :rollback_prepared].each do |meth|
- it "should raise NotImplementedError on #{meth}" do
- lambda do @transaction.send(meth) end.should raise_error(NotImplementedError)
- end
- end
-
-end
diff --git a/spec/uri_spec.rb b/spec/uri_spec.rb
deleted file mode 100644
index fc0ae13..0000000
--- a/spec/uri_spec.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
-
-describe DataObjects::URI do
- before do
- @uri = DataObjects::URI.parse('mock://username:password@localhost:12345/path?encoding=utf8#fragment')
- end
-
- it "should parse the scheme part" do
- @uri.scheme.should == "mock"
- end
-
- it "should parse the user part" do
- @uri.user.should == "username"
- end
-
- it "should parse the password part" do
- @uri.password.should == "password"
- end
-
- it "should parse the host part" do
- @uri.host.should == "localhost"
- end
-
- it "should parse the port part" do
- @uri.port.should == 12345
- end
-
- it "should parse the path part" do
- @uri.path.should == "/path"
- end
-
- it "should parse the query part" do
- @uri.query.should == { "encoding" => "utf8" }
- end
-
- it "should parse the fragment part" do
- @uri.fragment.should == "fragment"
- end
-
- it "should provide a correct string representation" do
- @uri.to_s.should == 'mock://username:password@localhost:12345/path?encoding=utf8#fragment'
- end
-
-end
diff --git a/tasks/gem.rake b/tasks/gem.rake
deleted file mode 100644
index 11a78dc..0000000
--- a/tasks/gem.rake
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'rubygems/package_task'
-
-GEM_SPEC = eval(File.read('data_objects.gemspec'))
-
-gem_package = Gem::PackageTask.new(GEM_SPEC) do |pkg|
- pkg.need_tar = false
- pkg.need_zip = false
-end
diff --git a/tasks/install.rake b/tasks/install.rake
deleted file mode 100644
index 0eeb335..0000000
--- a/tasks/install.rake
+++ /dev/null
@@ -1,13 +0,0 @@
-def sudo_gem(cmd)
- sh "#{SUDO} #{RUBY} -S gem #{cmd}", :verbose => false
-end
-
-desc "Install #{GEM_SPEC.name} #{GEM_SPEC.version}"
-task :install => [ :package ] do
- sudo_gem "install --local pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version} --no-update-sources"
-end
-
-desc "Uninstall #{GEM_SPEC.name} #{GEM_SPEC.version}"
-task :uninstall => [ :clean ] do
- sudo_gem "uninstall #{GEM_SPEC.name} -v#{GEM_SPEC.version} -I -x"
-end
diff --git a/tasks/release.rake b/tasks/release.rake
deleted file mode 100644
index 7cc6c9a..0000000
--- a/tasks/release.rake
+++ /dev/null
@@ -1,74 +0,0 @@
-begin
- gem 'rubyforge', '~> 1.0.1'
- require 'rubyforge'
-rescue Exception
- nil
-end
-
-if defined?(RubyForge) then
- if defined?(GEM_SPEC) then
- desc 'Package and upload to RubyForge'
- task :release => [:clobber, :package] do |t|
- ver = ENV['VERSION'] or fail "Must supply VERSION (rake release VERSION=x.y.z)."
-
- # compare versions to avoid mistakes
- unless ver == GEM_SPEC.version.to_s then
- fail "Version mismatch (supplied and specification versions differ)."
- end
-
- # no rubyforge project? no release for you!
- if GEM_SPEC.rubyforge_project == 'TODO' or GEM_SPEC.rubyforge_project.nil? then
- fail "Must define rubyforge_project in your gem specification."
- end
-
- # instantiate a RubyForge object
- rf = RubyForge.new
-
- # read project info and overview
- notes = begin
- r = File.read("README.markdown")
- r.split(/^(.*\n\-+)/)[1..4].join.strip
- rescue
- warn "Missing README.markdown"
- ''
- end
-
- # read changes
- changes = begin
- h = File.read("HISTORY.markdown")
- h.split(/^(##+ .*)/)[1..2].join.strip
- rescue
- warn "Missing HISTORY.markdown"
- ''
- end
-
- # build the configuration for the release
- config = Hash.new
- config["release_notes"] = notes
- config["release_changes"] = changes
- config["preformatted"] = true
-
- # prepare configuration
- rf.configure config
-
- files = FileList["pkg/#{GEM_SPEC.name}-#{GEM_SPEC.version}*.*"].to_a
- fail "No files found for the release." if files.empty?
-
- puts "Logging in RubyForge..."
- rf.login
-
- puts "Files to upload:"
- files.each do |f|
- puts " * #{f}"
- end
-
- puts "Releasing #{GEM_SPEC.name} version #{GEM_SPEC.version}..."
- rf.add_release GEM_SPEC.rubyforge_project, GEM_SPEC.name, GEM_SPEC.version, *files
- puts "Done."
- end
- else
- warn "no GEM_SPEC is found or defined. 'release' task cannot work without it."
- end
-else
- warn "rubyforge gem is required to generate releases, please install it (gem install rubyforge)."
-end
diff --git a/tasks/spec.rake b/tasks/spec.rake
deleted file mode 100644
index 77fa1d8..0000000
--- a/tasks/spec.rake
+++ /dev/null
@@ -1,19 +0,0 @@
-# Specs
-require 'spec/rake/spectask'
-
-desc 'Run specifications'
-Spec::Rake::SpecTask.new(:spec) do |t|
- t.spec_opts << '--options' << ROOT + 'spec/spec.opts'
- t.spec_files = Pathname.glob(ENV['FILES'] || 'spec/**/*_spec.rb').map { |f| f.to_s }
- t.libs << 'lib'
-
- begin
- # RCov is run by default, except on the JRuby platform
- t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
- t.rcov_opts << '--exclude' << 'spec'
- t.rcov_opts << '--text-summary'
- t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
- rescue Exception
- # rcov not installed
- end
-end
--
ruby-dataobjects.git
More information about the Pkg-ruby-extras-commits
mailing list