Changeset: efa2406c1356 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=efa2406c1356
Removed Files:
clients/ruby/README
clients/ruby/lib/test/test_capabilities.rb
Branch: default
Log Message:
Removed outdated read file and old tests from Ruby Client
diffs (truncated from 480 to 300 lines):
diff --git a/clients/ruby/README b/clients/ruby/README
deleted file mode 100644
--- a/clients/ruby/README
+++ /dev/null
@@ -1,154 +0,0 @@
-== Standalone driver ==
-This directory contains the a ruby interface to monetdb5
-written in pure ruby.
-
-lib/MonetDB.rb
-lib/MonetDBConnection.rb
-lib/MonetDBStatements.rb
-lib/MonetDBData.rb
-lib/MonetDBExceptions.rb
-lib/hasher.rb
-lib/demo.rb: demo application how to interact with the database
-
-ruby-monetdb-sql-0.1.gemspec: make file for rubygems
-
-doc/: rubydoc in HTML format
-
-== Installation ==
-
-The standalone monetdb driver can be installed using the RubyGems Package
Manager.
-
-First build a gem file starting from the gemspec configuration:
-
-$ gem build ruby-monetdb-sql-0.1.gemspec
-
-Then install with the command:
-
-$ gem install ruby-monetdb-sql-0.1.gem
-
-== Usage ==
-To use the standalone driver import the 'MonetDB' class and 'rubygems' (in
case you installed it using gems).
-
-A typical sequence of events is as follows:
-Invoke query using the database handle to send the statement to the server and
get back a result set object.
-
-A result set object has methods for fetching rows, moving around in the
result set, obtaining column metadata, and releasing the result set.
-Use a row fetching method such as fetch_row or an iterator such as each to
access the rows of the result set.
-If you want a count of the number of rows in the result set: invoke 'num_rows'
method.
-Invoke 'free' to release the result set.
-
-== Example ==
-
-require 'MonetDB'
-
-db = MonetDB.new
-db.connect(user = "monetdb", passwd = "monetdb", lang = "sql",
host="127.0.0.1", port = 50000, db_name = "demo", auth_type = "SHA1")
-
-# set type_cast=true to enable MonetDB to Ruby type mapping
-res = db.query("SELECT * from tables;", type_cast = false)
-
-#puts res.debug_columns_type
-
-puts "Number of rows returned: " + res.num_rows.to_s
-puts "Number of fields: " + res.num_fields.to_s
-
-
-# Get the columns' name
-col_names = res.name_fields
-
-
-# Iterate over the record set and retrieve on row at a time
-puts res.fetch
-while row = res.fetch do
- printf "%s \n", row
-end
-
-# Release the result set.
-res.free
-
-# Disconnect from server
-db.close
-
-See lib/demo.rb and the MonetDBDatar class documentation for more examples.
-
-
-
-== ActiveRecord connector adapter ==
-Active Record connects business objects and database tables to create a
persistable domain model where logic and data are presented in one wrapping.
Itâs an implementation of the object-relational mapping (ORM) pattern.
-
-Required files:
-
-adapter/lib/active_record/monetdb_adapter.rb
-
-Usage example follows:
-require 'active_record'
-
-ActiveRecord::Base.logger = Logger.new(STDERR)
-ActiveRecord::Base.colorize_logging = true
-
-ActiveRecord::Base.establish_connection(
- :adapter => "monetdb",
- :host => "localhost",
- :database => "demo"
-)
-
-# Create a new table
-class AddTests < ActiveRecord::Migration
- def self.up
- create_table :tests do |table|
- table.column :name, :string
- table.column :surname, :string
- end
- end
-
- def self.down
- drop_table :tests
- end
-
-end
-
-AddTests.up
-
-# Migration: add a column name with a default value
-class AddAge < ActiveRecord::Migration
- def self.up
- add_column :tests, :age, :smallint, :default => 18
- end
-
- def self.down
- remove_column :tests, :age
- end
-
-end
-
-class Test < ActiveRecord::Base
-end
-
-# Insert an entry in the table
-Test.create(:name => 'X', :surname => 'Y')
-
-# add a column
-AddAge.up
-
-# return the first result of the query SELECT * from tables
-row = Test.find(:first)
-printf "SELECT * from tests LIMIT 1:\n"
-printf "Name: %s, Surname: %s, Age: %s\n", row.name, row.surname, row.age
-
-# Drop the table
-AddTests.down
-
-== Rubygem ==
-
-The standalone ruby driver can be distributed as a ruby gem.
-A gem file is already available; however, it can be generated
-starting from the ruby-monetdb-sql-0.1.gemspec file:
-
-$ gem build ruby-monetdb-sql-0.1.gemspec
-
-To install the file run the command:
-
-$ gem install ruby-monetdb-sql-0.1.gem
-
-Documentation in ri and html format will be generated and installed as well
-
diff --git a/clients/ruby/lib/test/test_capabilities.rb
b/clients/ruby/lib/test/test_capabilities.rb
deleted file mode 100644
--- a/clients/ruby/lib/test/test_capabilities.rb
+++ /dev/null
@@ -1,316 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# Copyright 2008-2015 MonetDB B.V.
-
-# unit test suite for monetdb.
-# connects to the 'ruby_test' database and runs test on the server
capabilities and SQL language.
-# Create first a database with the command:
-# $ monetdb create ruby_test
-# $ monetdb start ruby_start
-#
-# Tests examples have been taken from the python and java internfaces and
mysql driver.
-
-require_relative '../MonetDB'
-require 'test/unit'
-
-require 'time'
-require 'date'
-
-
-class TC_MonetDBCapabilities < Test::Unit::TestCase
- # ruby rand function does not support MIN..MAX bounds.
- # This alias adds that feature.
- alias original_rand rand
- def rand(arg1=nil, arg2=nil)
- if !arg1.kind_of?(Enumerable) && arg2 == nil
- original_rand(arg1)
- elsif arg1.kind_of? Enumerable
- as_array = arg1.to_a
- as_array[original_rand(as_array.length)]
- elsif arg1 != nil
- arg1 + original_rand(arg2)
- end
- end
-
- # check the existance of a table
- def table_exists?(table='test_ruby')
- begin
- res = @db.query("select * from #{table} where 1=0")
- return true
- rescue
- return false
- end
- end
-
- def drop_table(table='test_ruby')
- res = @db.query("DROP TABLE #{table}")
- end
-
- def setup
- @db = MonetDB.new
- @db.connect(user = "monetdb", passwd = "monetdb", lang = "sql",
host="localhost", port = 50000, db_name = "ruby_test", auth_type = "SHA1")
-
- end
-
- def teardown
- @db.close
- end
-
- # CREATE TABLE test
- def test_create_table(table='test_ruby', cols = [ "First_Name varchar(255)",
"Second_Name varchar(255)"])
-
- if table_exists?(table)
- drop_table(table)
- end
-
- colsdef = ""
- cols.each do |c| colsdef += c + ',' end
-
- colsdef = colsdef.chop # remove last ',' character
-
-
- res = @db.query('CREATE TABLE ' + table + ' (' + colsdef + ')')
- end
-
-
- # perform an inserstion of 'data' into 'table' and check the resulting
- # length
- def test_data_integrity(table='test_ruby', data=["Gabriele", "MODENA"])
- test_create_table
-
- values = ""
- data.each do |d| values += '\'' + d.to_s + '\'' + ',' end
- values = values.chop # remove last ',' character
-
- insert = 'INSERT INTO ' + table + ' VALUES (' + values + ' )'
-
- @db.query(insert)
-
- res = @db.query("SELECT * FROM #{table}")
- rows = res.fetch_all
-
- assert_equal(res.num_rows, rows.size)
- end
-
- # test TRANSACTION, COMMIT, ROLLBACK and SAVEPOINT in auto_commit=off mode
- def test_transactions(table="test_monetdb_transactions", columndefs=['col1
INT', 'col2 VARCHAR(255)'])
- test_create_table(table, columndefs)
-
- data = [1, 'aa']
- values = ""
-
- data.each do |d| values += '\'' + d.to_s + '\'' + ',' end
- values = values.chop # remove last ',' character
-
- insert = "INSERT INTO " + table + " VALUES " + " ( " + values + " )"
-
- @db.query('START TRANSACTION')
- @db.auto_commit(flag=false) # if @db.auto_commit?
- @db.query(insert)
-
- @db.query("COMMIT")
-
- res = @db.query('SELECT * FROM ' + table)
- rows_committed = res.fetch_all
- res.free
-
- # create a save point
- @db.save
- @db.query("SAVEPOINT #{@db.transactions} ;")
-
- @db.query(insert)
-
- # rollback to savepoint
- @db.query("ROLLBACK TO SAVEPOINT #{@db.transactions};")
- @db.release
-
- res = @db.query('SELECT * FROM ' + table)
- rows_rolled_back = res.fetch_all
- res.free
-
- assert_equal(rows_committed, rows_rolled_back)
-
- # restore autocommit for remaining tests
- @db.auto_commit(flag=true)
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list