orientdb 0.0.11-jruby → 0.0.12-jruby
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +12 -0
- data/VERSION +1 -1
- data/bin/orientdb_console +2 -1
- data/lib/orientdb/constants.rb +23 -22
- data/lib/orientdb/database.rb +88 -69
- data/lib/orientdb/oclass.rb +2 -2
- data/lib/orientdb/sql.rb +0 -5
- data/lib/orientdb.rb +1 -1
- data/orientdb.gemspec +4 -6
- data/spec/database_spec.rb +6 -6
- data/spec/document_spec.rb +0 -4
- data/spec/orientdb_spec.rb +1 -1
- data/spec/spec_helper.rb +44 -32
- metadata +8 -20
- data/lib/orientdb/database_pool.rb +0 -11
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use jruby
|
1
|
+
rvm use jruby-1.6.0.RC1
|
data/README.rdoc
CHANGED
@@ -16,7 +16,7 @@ Let's get the gem installed and test out the interactive console.
|
|
16
16
|
shell> gem install orientdb
|
17
17
|
shell> orientdb_console
|
18
18
|
|
19
|
-
>> db = OrientDB::
|
19
|
+
>> db = OrientDB::DocumentDatabase.connect "remote:localhost/demo", 'admin', 'admin'
|
20
20
|
=> #<OrientDB::Database:0x6a346239 @proxy_object=#<Java::ComOrientechnologiesOrientCoreDbDocument::ODatabaseDocumentTx:0x14860315>
|
21
21
|
>> customer = db.get_class "Customer"
|
22
22
|
=> #<OrientDB::OClass:Customer name:string>
|
data/Rakefile
CHANGED
@@ -31,6 +31,18 @@ rescue LoadError
|
|
31
31
|
end
|
32
32
|
|
33
33
|
require 'rspec/core/rake_task'
|
34
|
+
|
35
|
+
#
|
36
|
+
# Test a local database:
|
37
|
+
# rake spec
|
38
|
+
#
|
39
|
+
# Test a remote database:
|
40
|
+
# ORIENTDB_TEST_URL=remote:localhost/test ORIENTDB_TEST_USERNAME=admin ORIENTDB_TEST_PASSWORD=admin ORIENTDB_TEST_POOLED=true rake spec
|
41
|
+
#
|
42
|
+
# Test a pooled remote database:
|
43
|
+
# ORIENTDB_TEST_URL=remote:localhost/test ORIENTDB_TEST_USERNAME=admin ORIENTDB_TEST_PASSWORD=admin ORIENTDB_TEST_POOLED=true rake spec
|
44
|
+
#
|
45
|
+
desc "Run specs"
|
34
46
|
RSpec::Core::RakeTask.new(:spec)
|
35
47
|
|
36
48
|
desc "Run all examples using rcov"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
data/bin/orientdb_console
CHANGED
@@ -11,8 +11,9 @@ if ARGV.include?('test:db')
|
|
11
11
|
puts ">> TEST_DB PATH : #{TEST_DB_PATH}"
|
12
12
|
|
13
13
|
require 'fileutils'
|
14
|
+
FileUtils.remove_dir TEST_DB_PATH
|
14
15
|
FileUtils.mkdir_p TEST_DB_PATH
|
15
|
-
DB = OrientDB::
|
16
|
+
DB = OrientDB::DocumentDatabase.new("local:#{TEST_DB_PATH}/test").create
|
16
17
|
end
|
17
18
|
|
18
19
|
include OrientDB
|
data/lib/orientdb/constants.rb
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
module OrientDB
|
2
2
|
|
3
|
-
ClusterType
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
3
|
+
ClusterType = com.orientechnologies.orient.core.storage.OStorage::CLUSTER_TYPE
|
4
|
+
DocumentDatabase = com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
|
5
|
+
DocumentDatabasePool = com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool
|
6
|
+
DocumentDatabasePooled = com.orientechnologies.orient.core.db.document.ODatabaseDocumentTxPooled
|
7
|
+
Document = com.orientechnologies.orient.core.record.impl.ODocument
|
8
|
+
IndexType = com.orientechnologies.orient.core.metadata.schema.OProperty::INDEX_TYPE
|
9
|
+
OClass = com.orientechnologies.orient.core.metadata.schema.OClass
|
10
|
+
LocalStorage = com.orientechnologies.orient.core.storage.impl.local.OStorageLocal
|
11
|
+
LocalCluster = com.orientechnologies.orient.core.storage.impl.local.OClusterLocal
|
12
|
+
LogicalCluster = com.orientechnologies.orient.core.storage.impl.local.OClusterLogical
|
13
|
+
Property = com.orientechnologies.orient.core.metadata.schema.OProperty
|
14
|
+
RecordList = com.orientechnologies.orient.core.db.record.ORecordTrackedList
|
15
|
+
RecordMap = com.orientechnologies.orient.core.db.record.ORecordTrackedMap
|
16
|
+
RecordSet = com.orientechnologies.orient.core.db.record.ORecordTrackedSet
|
17
|
+
RemoteStorage = com.orientechnologies.orient.client.remote.OStorageRemote
|
18
|
+
Schema = com.orientechnologies.orient.core.metadata.schema.OSchema
|
19
|
+
SchemaType = com.orientechnologies.orient.core.metadata.schema.OType
|
20
|
+
SQLSynchQuery = com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
|
21
|
+
SQLCommand = com.orientechnologies.orient.core.sql.OCommandSQL
|
22
|
+
User = com.orientechnologies.orient.core.metadata.security.OUser
|
22
23
|
|
23
|
-
STORAGE_TYPES
|
24
|
-
INDEX_TYPES
|
24
|
+
STORAGE_TYPES = %w{ LOGICAL MEMORY PHYSICAL }.inject({}) { |h, s| h[s.downcase.to_sym] = ClusterType.const_get s; h }
|
25
|
+
INDEX_TYPES = %w{ FULLTEXT NOTUNIQUE UNIQUE }.inject({}) { |h, s| h[s.downcase.to_sym] = IndexType.const_get s; h }
|
25
26
|
|
26
|
-
FIELD_TYPES
|
27
|
+
FIELD_TYPES = {
|
27
28
|
:binary => "BINARY",
|
28
29
|
:bool => "BOOLEAN",
|
29
30
|
:boolean => "BOOLEAN",
|
data/lib/orientdb/database.rb
CHANGED
@@ -1,98 +1,117 @@
|
|
1
|
-
|
1
|
+
module OrientDB
|
2
|
+
module DocumentDatabaseMixin
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
def run_command(sql_command = nil)
|
5
|
+
sql_command = prepare_sql_command sql_command
|
6
|
+
command(sql_command).execute(true)
|
7
|
+
end
|
6
8
|
|
7
|
-
|
9
|
+
def prepare_sql_command(sql_command)
|
10
|
+
return if sql_command.nil?
|
11
|
+
case sql_command
|
12
|
+
when OrientDB::SQLCommand
|
13
|
+
sql_command
|
14
|
+
when String
|
15
|
+
OrientDB::SQLCommand.new sql_command
|
16
|
+
else
|
17
|
+
raise "Unknown command type"
|
18
|
+
end
|
19
|
+
end
|
8
20
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
21
|
+
def all(sql_query = nil)
|
22
|
+
sql_query = prepare_sql_query sql_query
|
23
|
+
query sql_query
|
24
|
+
end
|
14
25
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
when SQLCommand
|
19
|
-
sql_command
|
20
|
-
when String
|
21
|
-
SQLCommand.new sql_command
|
22
|
-
else
|
23
|
-
raise "Unknown command type"
|
26
|
+
def first(sql_query = nil)
|
27
|
+
sql_query = prepare_sql_query(sql_query).setLimit(1)
|
28
|
+
query(sql_query).first
|
24
29
|
end
|
25
|
-
end
|
26
30
|
|
27
|
-
|
31
|
+
def prepare_sql_query(sql_query)
|
32
|
+
return if sql_query.nil?
|
33
|
+
case sql_query
|
34
|
+
when OrientDB::SQLSynchQuery
|
35
|
+
sql_query
|
36
|
+
when OrientDB::SQL::Query
|
37
|
+
sql_query.to_sql_synch_query
|
38
|
+
when String
|
39
|
+
OrientDB::SQLSynchQuery.new(sql_query)
|
40
|
+
else
|
41
|
+
raise "Unknown query type"
|
42
|
+
end
|
43
|
+
end
|
28
44
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
45
|
+
def schema
|
46
|
+
metadata.schema
|
47
|
+
end
|
33
48
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
49
|
+
def get_class(klass_name)
|
50
|
+
schema.get_class klass_name.to_s
|
51
|
+
end
|
38
52
|
|
39
|
-
|
40
|
-
|
41
|
-
case sql_query
|
42
|
-
when OrientDB::SQLSynchQuery
|
43
|
-
sql_query
|
44
|
-
when OrientDB::SQL::Query
|
45
|
-
sql_query.to_sql_synch_query
|
46
|
-
when String
|
47
|
-
OrientDB::SQLSynchQuery.new(sql_query)
|
48
|
-
else
|
49
|
-
raise "Unknown query type"
|
53
|
+
def create_class(klass_name, fields = {})
|
54
|
+
OrientDB::OClass.create self, klass_name.to_s, fields
|
50
55
|
end
|
51
|
-
end
|
52
56
|
|
53
|
-
|
54
|
-
|
55
|
-
|
57
|
+
def get_or_create_class(klass_name, fields = {})
|
58
|
+
get_class(klass_name) || create_class(klass_name, fields)
|
59
|
+
end
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
def drop_class(klass_name)
|
62
|
+
schema.remove_class(klass_name) if schema.exists_class(klass_name)
|
63
|
+
end
|
60
64
|
|
61
|
-
|
62
|
-
|
63
|
-
|
65
|
+
def recreate_class(klass_name, fields = {})
|
66
|
+
run_command("DELETE FROM #{klass_name}") rescue nil
|
67
|
+
drop_class(klass_name) rescue nil
|
68
|
+
create_class klass_name, fields
|
69
|
+
end
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
71
|
+
def all_in_class(klass_name)
|
72
|
+
browse_class(klass_name.to_s).map
|
73
|
+
end
|
68
74
|
|
69
|
-
|
75
|
+
def all_in_cluster(cluster_name)
|
76
|
+
browse_cluster(cluster_name.to_s).map
|
77
|
+
end
|
70
78
|
|
71
|
-
def all_in_class(klass_name)
|
72
|
-
browse_class(klass_name.to_s).map
|
73
79
|
end
|
74
80
|
|
75
|
-
|
81
|
+
class DocumentDatabase
|
76
82
|
|
77
|
-
|
78
|
-
browse_cluster(cluster_name.to_s).map
|
79
|
-
end
|
83
|
+
include DocumentDatabaseMixin
|
80
84
|
|
81
|
-
|
85
|
+
def self.create(database_url)
|
86
|
+
new(database_url).create
|
87
|
+
end
|
82
88
|
|
83
|
-
def
|
84
|
-
|
85
|
-
obj.create
|
86
|
-
obj
|
89
|
+
def self.connect(database_url, username, password)
|
90
|
+
new(database_url).open(username, password)
|
87
91
|
end
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
alias :each_in_class :browseClass
|
94
|
+
alias :each_in_cluster :browseCluster
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
class DocumentDatabasePool
|
99
|
+
|
100
|
+
def self.connect(url, username, password)
|
101
|
+
global.acquire(url, username, password)
|
93
102
|
end
|
94
103
|
|
95
104
|
end
|
105
|
+
|
106
|
+
class DocumentDatabasePooled
|
107
|
+
|
108
|
+
include DocumentDatabaseMixin
|
109
|
+
|
110
|
+
alias :each_in_class :browseClass
|
111
|
+
alias :each_in_cluster :browseCluster
|
112
|
+
|
113
|
+
end
|
114
|
+
|
96
115
|
end
|
97
116
|
|
98
117
|
|
data/lib/orientdb/oclass.rb
CHANGED
@@ -84,13 +84,13 @@ module OrientDB
|
|
84
84
|
else
|
85
85
|
if use_cluster
|
86
86
|
cluster = db.storage.get_cluster use_cluster
|
87
|
-
klass = db.schema.create_class name,
|
87
|
+
klass = db.schema.create_class name, cluster
|
88
88
|
elsif add_cluster && !db.storage.cluster_names.include?(name.downcase)
|
89
89
|
cluster = db.storage.add_cluster name.downcase, STORAGE_TYPES[:physical]
|
90
90
|
klass = db.schema.create_class name, cluster
|
91
91
|
else
|
92
92
|
klass = db.schema.create_class name
|
93
|
-
cluster = db.storage.get_cluster klass.cluster_ids.first
|
93
|
+
cluster = db.storage.get_cluster klass.cluster_ids.first rescue nil
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
data/lib/orientdb/sql.rb
CHANGED
@@ -17,20 +17,15 @@ module OrientDB
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def add(*conds)
|
20
|
-
puts "add : #{conds.inspect}"
|
21
20
|
conds.each do |cond|
|
22
21
|
case cond
|
23
22
|
when ConditionExpression
|
24
|
-
puts "ConditionExpression : #{cond.class.name} : #{cond.inspect}"
|
25
23
|
conditions << cond.to_s
|
26
24
|
when Hash
|
27
|
-
puts "Hash : #{cond.class.name} : #{cond.inspect}"
|
28
25
|
cond.each { |k, v| conditions << "#{k} = #{Query.quote(v)}" }
|
29
26
|
when Array
|
30
|
-
puts "Array : #{cond.class.name} : #{cond.inspect}"
|
31
27
|
cond.each { |x| conditions << x.to_s }
|
32
28
|
else
|
33
|
-
puts "else : #{cond.class.name} : #{cond.inspect}"
|
34
29
|
conditions << cond.to_s
|
35
30
|
end
|
36
31
|
end
|
data/lib/orientdb.rb
CHANGED
data/orientdb.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{orientdb}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.12"
|
9
9
|
s.platform = %q{jruby}
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Adrian Madrid"]
|
13
|
-
s.date = %q{2011-01-
|
13
|
+
s.date = %q{2011-01-20}
|
14
14
|
s.default_executable = %q{orientdb_console}
|
15
15
|
s.description = %q{Simple JRuby wrapper for the OrientDB.}
|
16
16
|
s.email = ["aemadrid@gmail.com"]
|
@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
|
|
38
38
|
"lib/orientdb.rb",
|
39
39
|
"lib/orientdb/constants.rb",
|
40
40
|
"lib/orientdb/database.rb",
|
41
|
-
"lib/orientdb/database_pool.rb",
|
42
41
|
"lib/orientdb/document.rb",
|
43
42
|
"lib/orientdb/ext.rb",
|
44
43
|
"lib/orientdb/oclass.rb",
|
@@ -63,14 +62,13 @@ Gem::Specification.new do |s|
|
|
63
62
|
s.homepage = %q{http://rubygems.org/gems/orientdb}
|
64
63
|
s.require_paths = ["lib"]
|
65
64
|
s.rubyforge_project = %q{orientdb}
|
66
|
-
s.rubygems_version = %q{1.
|
65
|
+
s.rubygems_version = %q{1.4.2}
|
67
66
|
s.summary = %q{JRuby wrapper for OrientDB}
|
68
67
|
|
69
68
|
if s.respond_to? :specification_version then
|
70
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
71
69
|
s.specification_version = 3
|
72
70
|
|
73
|
-
if Gem::Version.new(Gem::
|
71
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
74
72
|
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
75
73
|
s.add_development_dependency(%q<rspec>, [">= 2.4"])
|
76
74
|
else
|
data/spec/database_spec.rb
CHANGED
@@ -2,21 +2,21 @@ require File.expand_path("../spec_helper", __FILE__)
|
|
2
2
|
|
3
3
|
describe "OrientDB" do
|
4
4
|
|
5
|
-
describe "
|
5
|
+
describe "DocumentDatabase" do
|
6
6
|
|
7
7
|
before :all do
|
8
8
|
create_classes
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should create a valid simple table" do
|
12
|
-
exp_class = "#<OrientDB::OClass:person name
|
12
|
+
exp_class = "#<OrientDB::OClass:person name=#<orientdb::schematype:string>>"
|
13
13
|
exp_props = ["#<OrientDB::Propery:name type=string indexed=false mandatory=false not_null=false>"]
|
14
14
|
@person_class.to_s.should == exp_class
|
15
15
|
@person_class.properties.map { |x| x.to_s }.should == exp_props
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should create a valid simple descendant table" do
|
19
|
-
exp_class = "#<OrientDB::OClass:customer super=person tab
|
19
|
+
exp_class = "#<OrientDB::OClass:customer super=person tab=#<orientdb::schematype:float> name=#<orientdb::schematype:string>>"
|
20
20
|
exp_props = [
|
21
21
|
"#<OrientDB::Propery:tab type=decimal indexed=false mandatory=false not_null=false>",
|
22
22
|
"#<OrientDB::Propery:name type=string indexed=false mandatory=false not_null=false>"
|
@@ -26,7 +26,7 @@ describe "OrientDB" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should create a complex table" do
|
29
|
-
exp_class = "#<OrientDB::OClass:invoice number
|
29
|
+
exp_class = "#<OrientDB::OClass:invoice number=#<orientdb::schematype:integer>(idx) customer=#<orientdb::schematype:link> sold_on=#<orientdb::schematype:date> total=#<orientdb::schematype:float> lines=#<orientdb::schematype:linklist>>"
|
30
30
|
exp_props = [
|
31
31
|
"#<OrientDB::Propery:number type=int indexed=true mandatory=true not_null=false>",
|
32
32
|
"#<OrientDB::Propery:customer type=link indexed=false mandatory=false not_null=true>",
|
@@ -72,7 +72,7 @@ describe "OrientDB" do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should get all rows for a class" do
|
75
|
-
DB.
|
75
|
+
DB.all('SELECT FROM employee').map { |x| x.name }.sort.should == @employees.map { |x| x.name }.sort
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should create a valid query and return the right results" do
|
@@ -87,7 +87,7 @@ describe "OrientDB" do
|
|
87
87
|
|
88
88
|
it "should find rows by values in arrays" do
|
89
89
|
qry = DB.prepare_sql_query "SELECT * FROM #{@oclass} WHERE 'admin' IN groups"
|
90
|
-
DB.
|
90
|
+
DB.all(qry).map { |x| x.name }.sort.should == [@e1, @e2, @e4].map { |x| x.name }.sort
|
91
91
|
end
|
92
92
|
|
93
93
|
end
|
data/spec/document_spec.rb
CHANGED
@@ -43,22 +43,18 @@ describe "OrientDB" do
|
|
43
43
|
|
44
44
|
it "should create simple documents" do
|
45
45
|
@hammer.should be_a_kind_of OrientDB::Document
|
46
|
-
@hammer.to_s.should == "#<OrientDB::Document:product:8:0 title:\"Hammer\" price:3.25 sku:\"H509\">"
|
47
46
|
@h_fields.each { |k, v| @hammer[k].should == v }
|
48
47
|
|
49
48
|
@nail.should be_a_kind_of OrientDB::Document
|
50
|
-
@nail.to_s.should == "#<OrientDB::Document:product:8:1 title:\"Nail\" price:0.25 sku:\"N034\">"
|
51
49
|
@n_fields.each { |k, v| @nail.send(k).should == v }
|
52
50
|
end
|
53
51
|
|
54
52
|
it "should create embedded documents" do
|
55
53
|
@line1.should be_a_kind_of OrientDB::Document
|
56
|
-
@line1.to_s.should == "#<OrientDB::Document:invoice_line:9:0 product:#<OrientDB::Document:product:8:0 title:\"Hammer\" price:3.25 sku:\"H509\"> price:3.25 quantity:1>"
|
57
54
|
@line1.product.should == @hammer
|
58
55
|
@line1.price.should == @hammer.price
|
59
56
|
|
60
57
|
@line2.should be_a_kind_of OrientDB::Document
|
61
|
-
@line2.to_s.should == "#<OrientDB::Document:invoice_line:9:1 product:#<OrientDB::Document:product:8:1 title:\"Nail\" price:0.25 sku:\"N034\"> price:0.25 quantity:10>"
|
62
58
|
@line2.product.should == @nail
|
63
59
|
@line2.price.should == @nail.price
|
64
60
|
end
|
data/spec/orientdb_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -4,48 +4,60 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
4
4
|
|
5
5
|
require 'spec_basic_helper'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
TEST_URL = ENV["ORIENTDB_TEST_URL"]
|
8
|
+
TEST_USERNAME = ENV["ORIENTDB_TEST_USERNAME"]
|
9
|
+
TEST_PASSWORD = ENV["ORIENTDB_TEST_PASSWORD"]
|
10
|
+
TEST_POOLED = ENV["ORIENTDB_TEST_POOLED"].to_s[0, 1].downcase == 't'
|
10
11
|
|
11
|
-
|
12
|
+
puts "ENV :: TEST_URL : #{TEST_URL} | TEST_USERNAME : #{TEST_USERNAME} | TEST_PASSWORD : #{TEST_PASSWORD} | TEST_POOLED : #{TEST_POOLED}"
|
13
|
+
|
14
|
+
if TEST_URL && TEST_USERNAME && TEST_PASSWORD
|
15
|
+
if TEST_POOLED
|
16
|
+
puts ">> Testing [#{TEST_URL[0,TEST_URL.index(':')]}] Pooled Database :: TEST_DB URL : #{TEST_URL} : #{TEST_USERNAME} : #{TEST_PASSWORD}"
|
17
|
+
DB = OrientDB::DocumentDatabasePool.connect(TEST_URL, TEST_USERNAME, TEST_PASSWORD)
|
18
|
+
else
|
19
|
+
puts ">> Testing [#{TEST_URL[0,TEST_URL.index(':')]}] Database :: TEST_DB URL : #{TEST_URL} : #{TEST_USERNAME} : #{TEST_PASSWORD}"
|
20
|
+
DB = OrientDB::DocumentDatabase.connect(TEST_URL, TEST_USERNAME, TEST_PASSWORD)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
TEST_DB_PATH = "#{TEMP_DIR}/databases/db_#{rand(999) + 1}"
|
24
|
+
puts ">> Testing [local] Database :: TEST_DB PATH : #{TEST_DB_PATH}"
|
25
|
+
FileUtils.remove_dir "#{TEMP_DIR}/databases/"
|
26
|
+
FileUtils.mkdir_p TEST_DB_PATH
|
27
|
+
puts ">> TEST_DB PATH : #{TEST_DB_PATH}"
|
28
|
+
DB = OrientDB::DocumentDatabase.new("local:#{TEST_DB_PATH}/test").create
|
29
|
+
end
|
12
30
|
|
13
31
|
module Helpers
|
14
32
|
def create_classes
|
15
33
|
# People
|
16
|
-
@person_class = DB.
|
34
|
+
@person_class = DB.recreate_class :person, :name => :string
|
17
35
|
# Customers
|
18
|
-
@customer_class = DB.
|
19
|
-
|
20
|
-
|
36
|
+
@customer_class = DB.recreate_class :customer,
|
37
|
+
:super => @person_class,
|
38
|
+
:tab => :float
|
21
39
|
# Employees
|
22
|
-
@employee_class = DB.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@employee_class.truncate
|
27
|
-
@customer_class.truncate
|
28
|
-
@person_class.truncate
|
40
|
+
@employee_class = DB.recreate_class :employee,
|
41
|
+
:super => @person_class,
|
42
|
+
:age => :int,
|
43
|
+
:groups => [:embedded_list, :string]
|
29
44
|
# Products
|
30
|
-
@product_class
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
@product_class.truncate
|
45
|
+
@product_class = DB.recreate_class :product,
|
46
|
+
:sku => :string,
|
47
|
+
:title => :string,
|
48
|
+
:price => :float
|
35
49
|
# Invoice Lines
|
36
|
-
@line_class
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
@line_class.truncate
|
50
|
+
@line_class = DB.recreate_class :invoice_line,
|
51
|
+
:product => @product_class,
|
52
|
+
:quantity => :int,
|
53
|
+
:price => :float
|
41
54
|
# Invoices
|
42
|
-
@invoice_class
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@invoice_class.truncate
|
55
|
+
@invoice_class = DB.recreate_class :invoice,
|
56
|
+
:number => {:type => :int, :mandatory => true, :index => true},
|
57
|
+
:customer => {:type => @customer_class, :not_null => true},
|
58
|
+
:sold_on => :date,
|
59
|
+
:total => {:type => :float}, # , :min => java.lang.Float.new('0.01'), :max => java.lang.Float.new('1000.0')
|
60
|
+
:lines => [:link_list, @line_class]
|
49
61
|
end
|
50
62
|
end
|
51
63
|
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orientdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 11
|
9
|
-
version: 0.0.11
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.12
|
10
6
|
platform: jruby
|
11
7
|
authors:
|
12
8
|
- Adrian Madrid
|
@@ -14,18 +10,17 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-01-
|
13
|
+
date: 2011-01-20 00:00:00 -07:00
|
18
14
|
default_executable: orientdb_console
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
17
|
name: awesome_print
|
22
18
|
prerelease: false
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
24
21
|
requirements:
|
25
22
|
- - ">="
|
26
23
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
24
|
version: "0"
|
30
25
|
type: :development
|
31
26
|
version_requirements: *id001
|
@@ -33,12 +28,10 @@ dependencies:
|
|
33
28
|
name: rspec
|
34
29
|
prerelease: false
|
35
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
36
32
|
requirements:
|
37
33
|
- - ">="
|
38
34
|
- !ruby/object:Gem::Version
|
39
|
-
segments:
|
40
|
-
- 2
|
41
|
-
- 4
|
42
35
|
version: "2.4"
|
43
36
|
type: :development
|
44
37
|
version_requirements: *id002
|
@@ -71,7 +64,6 @@ files:
|
|
71
64
|
- lib/orientdb.rb
|
72
65
|
- lib/orientdb/constants.rb
|
73
66
|
- lib/orientdb/database.rb
|
74
|
-
- lib/orientdb/database_pool.rb
|
75
67
|
- lib/orientdb/document.rb
|
76
68
|
- lib/orientdb/ext.rb
|
77
69
|
- lib/orientdb/oclass.rb
|
@@ -102,25 +94,21 @@ rdoc_options: []
|
|
102
94
|
require_paths:
|
103
95
|
- lib
|
104
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
105
98
|
requirements:
|
106
99
|
- - ">="
|
107
100
|
- !ruby/object:Gem::Version
|
108
|
-
segments:
|
109
|
-
- 0
|
110
101
|
version: "0"
|
111
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
112
104
|
requirements:
|
113
105
|
- - ">="
|
114
106
|
- !ruby/object:Gem::Version
|
115
|
-
segments:
|
116
|
-
- 1
|
117
|
-
- 3
|
118
|
-
- 6
|
119
107
|
version: 1.3.6
|
120
108
|
requirements: []
|
121
109
|
|
122
110
|
rubyforge_project: orientdb
|
123
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.4.2
|
124
112
|
signing_key:
|
125
113
|
specification_version: 3
|
126
114
|
summary: JRuby wrapper for OrientDB
|