activerecord-jdbcnuodb-adapter 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.bundle
2
+ *.log
3
+ *.o
4
+ *.so
5
+ ext/nuodb/Makefile
6
+ coverage/
7
+ doc/
8
+ rdoc/
9
+ pkg/
10
+ tmp
11
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - jruby-head
5
+
6
+ env:
7
+ - NUODB_ROOT=/opt/nuodb
8
+
9
+ notifications:
10
+ recipients:
11
+ - buck.robert.j@gmail.com
12
+ - rbuck@nuodb.com
13
+
14
+ before_script:
15
+ - wget http://www.nuodb.com/latest/nuodb-1.0-GA.linux.x86_64.deb --output-document=/var/tmp/nuodb.deb
16
+ - sudo dpkg -i /var/tmp/nuodb.deb
17
+
18
+ script:
19
+ - NUODB_ROOT=/opt/nuodb bundle exec rake test install
20
+
21
+ after_script:
22
+ - sudo dpkg -r nuodb
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2012 - 2013, NuoDB, Inc.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ * Neither the name of NuoDB, Inc. nor the names of its contributors may
13
+ be used to endorse or promote products derived from this software
14
+ without specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL NUODB, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.rdoc ADDED
@@ -0,0 +1,99 @@
1
+ = ActiveRecord JDBC NuoDB Adapter
2
+
3
+ {<img src="https://api.travis-ci.org/nuodb/activerecord-jdbcnuodb-adapter.png?branch=master" alt="Build Status" />}[http://travis-ci.org/nuodb/activerecord-jdbcnuodb-adapter]
4
+ {<img src="https://gemnasium.com/nuodb/activerecord-jdbcnuodb-adapter.png?travis" alt="Dependency Status" />}[https://gemnasium.com/nuodb/activerecord-jdbcnuodb-adapter]
5
+ {<img src="https://codeclimate.com/github/nuodb/activerecord-jdbcnuodb-adapter.png" />}[https://codeclimate.com/github/nuodb/activerecord-jdbcnuodb-adapter]
6
+
7
+ == DESCRIPTION
8
+
9
+ An ActiveRecord JDBC Adapter for NuoDB.
10
+
11
+ == Usage
12
+
13
+ 1. Include NuoDB information in the database.yml file as:
14
+
15
+ development:
16
+ adapter: nuodb
17
+ database: test
18
+ username: cloud
19
+ password: user
20
+
21
+ 2. In the Gemfile, call the nuodb gem with:
22
+
23
+ gem 'activerecord-jdbcnuodb-adapter'
24
+
25
+ == BUILDING THE GEM
26
+
27
+ To compile and test run this command:
28
+
29
+ rake clean build rdoc spec
30
+
31
+ == INSTALLING THE GEM
32
+
33
+ gem install activerecord-jdbcnuodb-adapter-1.0.0.gem
34
+
35
+ Or from the source tree:
36
+
37
+ gem install pkg/activerecord-jdbcnuodb-adapter-1.0.0.gem
38
+
39
+ == TESTING THE GEM
40
+
41
+ Start up a minimal chorus as follows:
42
+
43
+ java -jar ${NUODB_ROOT}/jar/nuoagent.jar --broker &
44
+ ${NUODB_ROOT}/bin/nuodb --chorus test --password bar --dba-user dba --dba-password baz --verbose debug --archive /var/tmp/nuodb --initialize --force &
45
+ ${NUODB_ROOT}/bin/nuodb --chorus test --password bar --dba-user dba --dba-password baz &
46
+
47
+ Create a user in the database:
48
+
49
+ ${NUODB_ROOT}/bin/nuosql test@localhost --user dba --password baz
50
+ > create user cloud password 'user';
51
+ > exit
52
+
53
+ Run the tests:
54
+
55
+ rake spec
56
+
57
+ == TRYING THE SAMPLE
58
+
59
+ 1. Install the NuoDB gems:
60
+
61
+ gem install jdbc-nuodb-1.0.0.gem
62
+ gem install activerecord-jdbcnuodb-adapter-1.0.0.gem
63
+
64
+ 2. Verify the gems are installed:
65
+
66
+ gem list
67
+
68
+ 3. Run the sample:
69
+
70
+ jruby samples/sample.rb
71
+
72
+ == PUBLISHING THE GEM
73
+
74
+ === TAGGING
75
+
76
+ Tag the product using tags per the SemVer specification; our tags have a v-prefix:
77
+
78
+ git tag -a v1.0.0 -m "SemVer Version: v1.0.0"
79
+
80
+ If you make a mistake, take it back quickly:
81
+
82
+ git tag -d v1.0.0
83
+ git push origin :refs/tags/v1.0.0
84
+
85
+ ===PUBLISHING
86
+
87
+ Here are the commands used to publish:
88
+
89
+ gem push pkg/activerecord-jdbcnuodb-adapter-1.0.0.gem
90
+
91
+ == INSPECTING THE GEM
92
+
93
+ It is often useful to inspect the contents of a Gem before distribution.
94
+ To do this you dump the contents of a gem thus:
95
+
96
+ gem unpack pkg/activerecord-jdbcnuodb-adapter-1.0.0.gem
97
+
98
+ == REFERENCES
99
+
data/Rakefile ADDED
@@ -0,0 +1,168 @@
1
+ #
2
+ # Copyright (c) 2012 - 2013, NuoDB, Inc.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ # * Neither the name of NuoDB, Inc. nor the names of its contributors may
14
+ # be used to endorse or promote products derived from this software
15
+ # without specific prior written permission.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ # DISCLAIMED. IN NO EVENT SHALL NUODB, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
21
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ #
28
+
29
+ require 'rubygems'
30
+ require 'rake'
31
+ require 'rake/clean'
32
+ require 'rake/testtask'
33
+ require 'date'
34
+
35
+ require 'bundler'
36
+ require 'bundler/gem_tasks'
37
+
38
+ require File.expand_path(File.dirname(__FILE__)) + "/spec/support/config"
39
+ require File.expand_path(File.dirname(__FILE__)) + "/tasks/rspec"
40
+
41
+ Bundler::GemHelper.install_tasks
42
+
43
+ load 'activerecord-jdbcnuodb-adapter.gemspec'
44
+
45
+ #############################################################################
46
+ #
47
+ # Helper functions
48
+ #
49
+ #############################################################################
50
+
51
+ def name
52
+ @name ||= Dir['*.gemspec'].first.split('.').first
53
+ end
54
+
55
+ def version
56
+ require File.expand_path('../lib/activerecord-jdbcnuodb-adapter', __FILE__)
57
+ ArJdbc::NuoDB::VERSION
58
+ end
59
+
60
+ def rubyforge_project
61
+ name
62
+ end
63
+
64
+ def date
65
+ Date.today.to_s
66
+ end
67
+
68
+ def gemspec_file
69
+ "#{name}.gemspec"
70
+ end
71
+
72
+ def gem_file
73
+ "#{name}-#{version}.gem"
74
+ end
75
+
76
+ def replace_header(head, header_name)
77
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'" }
78
+ end
79
+
80
+ #############################################################################
81
+ #
82
+ # Standard tasks
83
+ #
84
+ #############################################################################
85
+
86
+ CLEAN.include('pkg')
87
+
88
+ Dir['tasks/**/*.rb'].each { |file| load file }
89
+
90
+ namespace :nuodb do
91
+
92
+ task :install do
93
+ if ENV['NUODB_ROOT'].nil?
94
+ case RUBY_PLATFORM
95
+ when /linux/i
96
+ unless File.exists? '/etc/redhat-release'
97
+ puts %x(wget http://www.nuodb.com/latest/nuodb-1.0-GA.linux.x86_64.deb --output-document=/var/tmp/nuodb.deb)
98
+ puts %x(sudo dpkg -i /var/tmp/nuodb.deb)
99
+ end
100
+ else
101
+ puts "Unsupported platform '#{RUBY_PLATFORM}'. Supported platforms are BSD, DARWIN, SOLARIS, and LINUX."
102
+ end
103
+ end
104
+ end
105
+
106
+ task :remove do
107
+ if ENV['NUODB_ROOT'].nil?
108
+ case RUBY_PLATFORM
109
+ when /linux/i
110
+ unless File.exists? '/etc/redhat-release'
111
+ puts %x(sudo dpkg -r nuodb)
112
+ end
113
+ else
114
+ puts "Unsupported platform '#{RUBY_PLATFORM}'. Supported platforms are BSD, DARWIN, SOLARIS, and LINUX."
115
+ end
116
+ end
117
+ end
118
+
119
+ task :create_user do
120
+ #puts %x( echo "create user arunit password 'arunit';" | nuosql arunit@localhost --user dba --password baz )
121
+ end
122
+
123
+ task :start_server do
124
+ end
125
+
126
+ task :stop_server do
127
+ end
128
+
129
+ task :restart_server => [:stop_server, :start_server, :create_user]
130
+ end
131
+
132
+ task :spec => :build
133
+
134
+ task :default => :spec
135
+
136
+ #############################################################################
137
+ #
138
+ # Packaging tasks
139
+ #
140
+ #############################################################################
141
+
142
+ desc "Build #{gem_file} into the pkg directory"
143
+ task :build do
144
+ sh "mkdir -p pkg"
145
+ sh "gem build #{gemspec_file}"
146
+ sh "mv #{gem_file} pkg"
147
+ end
148
+
149
+ task :install => :build do
150
+ sh %{gem install pkg/#{name}-#{version}}
151
+ end
152
+
153
+ task :uninstall do
154
+ sh %{gem uninstall #{name} -x -v #{version}}
155
+ end
156
+
157
+ desc "Tags git with the latest gem version"
158
+ task :tag do
159
+ sh %{git tag v#{version}}
160
+ end
161
+
162
+ desc "Push gem packages"
163
+ task :push => :build do
164
+ sh "gem push pkg/#{name}*.gem"
165
+ end
166
+
167
+ desc "Release version #{version}"
168
+ task :release => [:tag, :push]
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'activerecord-jdbcnuodb-adapter'
5
+ spec.version = '1.0.0'
6
+ spec.authors = ['Dave Meppelink', 'Robert Buck']
7
+ spec.email = 'rbuck@nuodb.com'
8
+ spec.description = 'ActiveRecord adapter for NuoDB. Only for use with JRuby. Requires separate Cache JDBC driver.'
9
+ spec.summary = 'ActiveRecord adapter for NuoDB.'
10
+ spec.homepage = 'http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter'
11
+ spec.license = 'BSD'
12
+
13
+ spec.require_paths = %w[lib]
14
+ spec.rdoc_options = %w(--charset=UTF-8)
15
+ spec.extra_rdoc_files = %w[README.rdoc LICENSE]
16
+
17
+ spec.files = `git ls-files`.split($\)
18
+
19
+ spec.test_files = spec.files.select { |path| path =~ /^test\/.*test.*\.rb/ }
20
+
21
+ spec.add_dependency 'jdbc-nuodb', '~> 1.0.0'
22
+ spec.add_dependency 'activerecord-jdbc-adapter', '>= 1.0.0'
23
+
24
+ %w(rake).each { |gem| spec.add_development_dependency gem }
25
+ %w(rspec rspec-core rspec-expectations rspec-mocks).each { |gem| spec.add_development_dependency gem, "~> 2.11.0" }
26
+
27
+ spec.rubygems_version = %q{1.3.7}
28
+ spec.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if spec.respond_to? :required_rubygems_version=
29
+ if spec.respond_to? :specification_version
30
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
31
+ spec.specification_version = 3
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ require 'arjdbc/nuodb'
@@ -0,0 +1,5 @@
1
+ module ArJdbc
2
+ module NuoDB
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ module Arel
2
+ module Visitors
3
+ class NuoDB < Arel::Visitors::ToSql
4
+ def visit_Arel_Nodes_Lock o
5
+ visit o.expr
6
+ end
7
+
8
+ def visit_Arel_Nodes_Limit o
9
+ "FETCH FIRST #{visit o.expr} ROWS ONLY"
10
+ end
11
+
12
+ def visit_Arel_Nodes_Matches o
13
+ "#{visit o.left} LIKE #{visit o.right}"
14
+ end
15
+
16
+ def visit_Arel_Nodes_DoesNotMatch o
17
+ "#{visit o.left} NOT LIKE #{visit o.right}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,8 @@
1
+ module ::ArJdbc
2
+ extension :NuoDB do |name|
3
+ if name =~ /nuodb/i
4
+ require 'arjdbc/nuodb'
5
+ true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,80 @@
1
+ module ::ArJdbc
2
+ module NuoDB
3
+
4
+ def self.column_selector
5
+ [/nuodb/i, lambda { |cfg, col| col.extend(::ArJdbc::NuoDB::Column) }]
6
+ end
7
+
8
+ module Column
9
+ end
10
+
11
+ def self.arel2_visitors(config)
12
+ {}.tap { |v| %w(nuodb).each { |a| v[a] = ::Arel::Visitors::NuoDB } }
13
+ end
14
+
15
+ def modify_types(tp)
16
+ tp[:primary_key] = 'int not null generated always primary key'
17
+ tp[:boolean] = {:name => 'boolean'}
18
+ tp[:integer] = {:name => 'int', :limit => 4}
19
+ tp[:decimal] = {:name => 'decimal'}
20
+ tp[:string] = {:name => 'string'}
21
+ tp[:timestamp] = {:name => 'datetime'}
22
+ tp[:datetime][:limit] = nil
23
+ tp
24
+ end
25
+
26
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
27
+ limit = nil if %w(text binary string).include? type.to_s
28
+ return 'uniqueidentifier' if (type.to_s == 'uniqueidentifier')
29
+ return super unless type.to_s == 'integer'
30
+
31
+ if limit.nil? || limit == 4
32
+ 'int'
33
+ elsif limit == 2
34
+ 'smallint'
35
+ elsif limit == 1
36
+ 'smallint'
37
+ else
38
+ 'bigint'
39
+ end
40
+ end
41
+
42
+ def quote(value, column = nil)
43
+ case value
44
+ when TrueClass, FalseClass
45
+ value.to_s
46
+ else
47
+ super
48
+ end
49
+ end
50
+
51
+ def exec_insert(sql, name, binds)
52
+ sql = substitute_binds(sql, binds)
53
+ @connection.execute_insert(sql)
54
+ end
55
+
56
+ def primary_keys(table)
57
+ @connection.primary_keys(qualify_table(table))
58
+ end
59
+
60
+ def columns(table_name, name=nil)
61
+ @connection.columns_internal(table_name.to_s, name, nuodb_schema)
62
+ end
63
+
64
+ private
65
+
66
+ def qualify_table(table)
67
+ if (table.include? '.') || @config[:schema].blank?
68
+ table
69
+ else
70
+ nuodb_schema + "." + table
71
+ end
72
+ end
73
+
74
+ def nuodb_schema
75
+ config[:schema] || ''
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -0,0 +1,12 @@
1
+ class ActiveRecord::Base
2
+ class << self
3
+ def nuodb_connection(config)
4
+ config[:schema] ||= config[:database]
5
+ config[:url] ||= "jdbc:com.nuodb://#{config[:host]}/#{config[:database]}?schema=#{config[:schema]}"
6
+ config[:driver] ||= "com.nuodb.jdbc.Driver"
7
+ config[:adapter_spec] ||= ::ArJdbc::NuoDB
8
+ config[:connection_alive_sql] ||= "select 1 from system.tables fetch first 1 rows"
9
+ jdbc_connection(config)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ require 'arjdbc'
2
+ require 'arjdbc/nuodb/connection_methods'
3
+ require 'arjdbc/nuodb/adapter'
4
+ require 'arel/visitors/nuodb'
data/samples/sample.rb ADDED
@@ -0,0 +1,109 @@
1
+ require 'rubygems'
2
+ require 'active_record'
3
+
4
+ puts "Connecting to database..."
5
+
6
+ ActiveRecord::Base.establish_connection(
7
+ :adapter => 'nuodb',
8
+ :database => 'test',
9
+ :username => 'cloud',
10
+ :password => 'user'
11
+ )
12
+
13
+ puts "Create tables..."
14
+
15
+ class User < ActiveRecord::Base
16
+ has_one :addr, :class_name => 'Addr'
17
+
18
+ def to_s
19
+ "User(#{id}), Username: #{user_name}, Name: #{first_name} #{last_name}, #{admin ? "admin" : "member"}\n" +
20
+ " Address: #{addr}\n"
21
+ end
22
+ end
23
+
24
+ class Addr < ActiveRecord::Base
25
+ belongs_to :User
26
+
27
+ def to_s
28
+ "Addr(#{id}:#{user_id}) Street: #{street} City: #{city} Zip: #{zip}"
29
+ end
30
+ end
31
+
32
+ ActiveRecord::Schema.drop_table(User.table_name) rescue nil
33
+ ActiveRecord::Schema.drop_table(Addr.table_name) rescue nil
34
+
35
+ ActiveRecord::Schema.define do
36
+ create_table User.table_name do |t|
37
+ t.string :first_name, :limit => 20
38
+ t.string :last_name, :limit => 20
39
+ t.string :email, :limit => 20
40
+ t.string :user_name, :limit => 20
41
+ t.boolean :admin
42
+ end
43
+ create_table Addr.table_name do |t|
44
+ t.integer :user_id
45
+ t.string :street, :limit => 20
46
+ t.string :city, :limit => 20
47
+ t.string :zip, :limit => 6
48
+ end
49
+ end
50
+
51
+ puts "Create user records..."
52
+
53
+ user = User.create do |user_instance|
54
+ user_instance.first_name = "Fred"
55
+ user_instance.last_name = "Flintstone"
56
+ user_instance.email = "fredf@example.com"
57
+ user_instance.user_name = "fred"
58
+ user_instance.admin = true
59
+ end
60
+
61
+ user.create_addr do |address|
62
+ address.street = "301 Cobblestone Way"
63
+ address.city = "Bedrock"
64
+ address.zip = "00001"
65
+ end
66
+
67
+ puts "Created #{user}"
68
+
69
+ user = User.create do |user_instance|
70
+ user_instance.first_name = "Barney"
71
+ user_instance.last_name = "Rubble"
72
+ user_instance.email = "barney@example.com"
73
+ user_instance.user_name = "barney"
74
+ user_instance.admin = false
75
+ end
76
+
77
+ user.create_addr do |address|
78
+ address.street = "303 Cobblestone Way"
79
+ address.city = "Bedrock"
80
+ address.zip = "00001"
81
+ end
82
+
83
+ puts "Created #{user}"
84
+
85
+ puts "Print user records..."
86
+
87
+ puts "Found #{User.count} records:"
88
+ User.find do |entry|
89
+ puts entry
90
+ end
91
+
92
+ puts "Modify user records..."
93
+
94
+ User.all.each do |entry|
95
+ entry.first_name = entry.first_name.upcase
96
+ entry.last_name = entry.last_name.upcase
97
+ entry.admin = !entry.admin
98
+ entry.addr.street = entry.addr.street.upcase
99
+ entry.addr.save
100
+ entry.save
101
+ end
102
+
103
+ puts "Print user records..."
104
+
105
+ puts "Found #{User.count} records:"
106
+ User.find_each do |entry|
107
+ puts entry
108
+ end
109
+
File without changes
File without changes
data/spec/rcov.opts ADDED
@@ -0,0 +1,2 @@
1
+ --exclude
2
+ spec,bin,/Library/Ruby
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ -c
2
+ -b
3
+ -fs
@@ -0,0 +1,13 @@
1
+ $:.unshift File.expand_path("../..", __FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'rspec/mocks'
5
+
6
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
7
+ $:.unshift(File.expand_path("../lib", __FILE__))
8
+ $:.unshift(File.dirname(__FILE__))
9
+
10
+ require 'java'
11
+ require 'jdbc/nuodb'
12
+ require 'support/config'
13
+ require 'support/connection'
@@ -0,0 +1,41 @@
1
+ #require 'yaml'
2
+ #require 'fileutils'
3
+ #require 'pathname'
4
+ #
5
+ #SPEC_ROOT = File.expand_path(File.dirname(__FILE__))
6
+ #
7
+ #class Hash
8
+ # def symbolize_keys!
9
+ # keys.each do |key|
10
+ # self[(key.to_sym rescue key) || key] = delete(key)
11
+ # end
12
+ # self
13
+ # end
14
+ #end
15
+ #
16
+ #module BaseTest
17
+ # class << self
18
+ # def config
19
+ # @config ||= read_config
20
+ # end
21
+ #
22
+ # private
23
+ #
24
+ # def config_file
25
+ # Pathname.new(ENV['NUODB_CONFIG'] || File.join(SPEC_ROOT, 'config.yml'))
26
+ # end
27
+ #
28
+ # def read_config
29
+ # unless config_file.exist?
30
+ # FileUtils.cp(File.join(SPEC_ROOT, 'config.example.yml'), config_file)
31
+ # end
32
+ #
33
+ # erb = Erubis::Eruby.new(config_file.read)
34
+ # expand_config(YAML.parse(erb.result(binding)).transform)
35
+ # end
36
+ #
37
+ # def expand_config(config)
38
+ # config
39
+ # end
40
+ # end
41
+ #end
@@ -0,0 +1,9 @@
1
+ default_connection: development
2
+
3
+ connections:
4
+ development:
5
+ database: 'test'
6
+ username: 'cloud'
7
+ password: 'user'
8
+ schema: 'test'
9
+
@@ -0,0 +1,15 @@
1
+ #require 'logger'
2
+ #
3
+ #module BaseTest
4
+ # def self.connection_name
5
+ # ENV['NUODB_CONN'] || config['default_connection']
6
+ # end
7
+ #
8
+ # def self.connection_config
9
+ # config['connections'][connection_name].symbolize_keys!
10
+ # end
11
+ #
12
+ # def self.connect
13
+ # NuoDB::Connection.new connection_config
14
+ # end
15
+ #end
File without changes
data/tasks/rspec.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ GEM_ROOT ||= File.expand_path(File.join(File.dirname(__FILE__), ".."))
5
+
6
+ begin
7
+
8
+ require 'rspec/core/rake_task'
9
+
10
+ task :default => :spec
11
+
12
+ desc "Run all specs in spec directory"
13
+ RSpec::Core::RakeTask.new(:spec) do |t|
14
+ t.rspec_opts = ['--options', "\"#{GEM_ROOT}/.rspec\""]
15
+ t.pattern = FileList['spec/**/*_spec.rb']
16
+ end
17
+
18
+ desc "Run all rspec functional tests (in functional/ directory)"
19
+ RSpec::Core::RakeTask.new(:functional) do |t|
20
+ t.rspec_opts = ['--options', "\"#{GEM_ROOT}/spec/spec.opts\""]
21
+ t.pattern = FileList['spec/functional/**/*_spec.rb']
22
+ end
23
+
24
+ desc "Run all rspec unit tests (in unit/ directory)"
25
+ RSpec::Core::RakeTask.new(:spec_unit) do |t|
26
+ t.rspec_opts = ['--options', "\"#{GEM_ROOT}/.rspec\""]
27
+ t.pattern = FileList['spec/unit/**/*_spec.rb']
28
+ end
29
+
30
+ namespace :spec do
31
+ desc "Print Specdoc for all specs"
32
+ RSpec::Core::RakeTask.new(:doc) do |t|
33
+ t.rspec_opts = %w(--format specdoc --dry-run)
34
+ t.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ [:unit].each do |sub|
38
+ desc "Run the specs under spec/#{sub}"
39
+ RSpec::Core::RakeTask.new(sub) do |t|
40
+ t.rspec_opts = ['--options', "\"#{GEM_ROOT}/spec/spec.opts\""]
41
+ t.pattern = FileList["spec/#{sub}/**/*_spec.rb"]
42
+ end
43
+ end
44
+ end
45
+
46
+ rescue LoadError
47
+ STDERR.puts "\n*** RSpec not available. (sudo) gem install rspec to run unit tests. ***\n\n"
48
+ end
data/tasks/stats.rb ADDED
@@ -0,0 +1,24 @@
1
+ desc "Prints lines of code metrics"
2
+ task :stats do
3
+ lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
4
+
5
+ FileList["lib/nuodb/**/*.rb", "ext/nuodb/*.cpp"].each { |file_name|
6
+ next if file_name =~ /vendor/
7
+ f = File.open(file_name)
8
+
9
+ while (line = f.gets)
10
+ lines += 1
11
+ next if line =~ /^\s*$/
12
+ next if line =~ /^\s*#/
13
+ codelines += 1
14
+ end
15
+ puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
16
+
17
+ total_lines += lines
18
+ total_codelines += codelines
19
+
20
+ lines, codelines = 0, 0
21
+ }
22
+
23
+ puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
24
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-jdbcnuodb-adapter
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Dave Meppelink
9
+ - Robert Buck
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-02-08 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: jdbc-nuodb
17
+ version_requirements: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ none: false
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 1.0.0
28
+ none: false
29
+ prerelease: false
30
+ type: :runtime
31
+ - !ruby/object:Gem::Dependency
32
+ name: activerecord-jdbc-adapter
33
+ version_requirements: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 1.0.0
38
+ none: false
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ none: false
45
+ prerelease: false
46
+ type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: !binary |-
54
+ MA==
55
+ none: false
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: !binary |-
61
+ MA==
62
+ none: false
63
+ prerelease: false
64
+ type: :development
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: 2.11.0
72
+ none: false
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: 2.11.0
78
+ none: false
79
+ prerelease: false
80
+ type: :development
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec-core
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: 2.11.0
88
+ none: false
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: 2.11.0
94
+ none: false
95
+ prerelease: false
96
+ type: :development
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-expectations
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.11.0
104
+ none: false
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 2.11.0
110
+ none: false
111
+ prerelease: false
112
+ type: :development
113
+ - !ruby/object:Gem::Dependency
114
+ name: rspec-mocks
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: 2.11.0
120
+ none: false
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: 2.11.0
126
+ none: false
127
+ prerelease: false
128
+ type: :development
129
+ description: ActiveRecord adapter for NuoDB. Only for use with JRuby. Requires separate Cache JDBC driver.
130
+ email: rbuck@nuodb.com
131
+ executables: []
132
+ extensions: []
133
+ extra_rdoc_files:
134
+ - README.rdoc
135
+ - LICENSE
136
+ files:
137
+ - ".gitignore"
138
+ - ".travis.yml"
139
+ - Gemfile
140
+ - LICENSE
141
+ - README.rdoc
142
+ - Rakefile
143
+ - activerecord-jdbcnuodb-adapter.gemspec
144
+ - lib/active_record/connection_adapters/nuodb_adapter.rb
145
+ - lib/activerecord-jdbcnuodb-adapter.rb
146
+ - lib/arel/visitors/nuodb.rb
147
+ - lib/arjdbc/discover.rb
148
+ - lib/arjdbc/nuodb.rb
149
+ - lib/arjdbc/nuodb/adapter.rb
150
+ - lib/arjdbc/nuodb/connection_methods.rb
151
+ - samples/sample.rb
152
+ - spec/data/.gitignore
153
+ - spec/functional/connection_spec.rb
154
+ - spec/rcov.opts
155
+ - spec/spec.opts
156
+ - spec/spec_helper.rb
157
+ - spec/support/config.rb
158
+ - spec/support/config.yml
159
+ - spec/support/connection.rb
160
+ - spec/unit/.gitignore
161
+ - tasks/rspec.rb
162
+ - tasks/stats.rb
163
+ homepage: http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter
164
+ licenses:
165
+ - BSD
166
+ post_install_message:
167
+ rdoc_options:
168
+ - "--charset=UTF-8"
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: !binary |-
176
+ MA==
177
+ none: false
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - !binary |-
181
+ Pg==
182
+ - !ruby/object:Gem::Version
183
+ version: 1.3.1
184
+ none: false
185
+ requirements: []
186
+ rubyforge_project:
187
+ rubygems_version: 1.8.24
188
+ signing_key:
189
+ specification_version: 3
190
+ summary: ActiveRecord adapter for NuoDB.
191
+ test_files: []