orientdb 0.0.4-jruby → 0.0.5-jruby
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE +20 -0
- data/Rakefile +54 -8
- data/VERSION +1 -0
- data/bin/orientdb_console +1 -1
- data/jars/orient-commons-0.9.24.jar +0 -0
- data/jars/orientdb-client-0.9.24.jar +0 -0
- data/jars/orientdb-core-0.9.24.jar +0 -0
- data/jars/orientdb-enterprise-0.9.24.jar +0 -0
- data/jars/orientdb-server-0.9.24.jar +0 -0
- data/jars/orientdb-tools-0.9.24.jar +0 -0
- data/jars/persistence-api-1.0.jar +0 -0
- data/lib/orientdb.rb +4 -1
- data/lib/orientdb/constants.rb +47 -0
- data/lib/orientdb/database.rb +111 -74
- data/lib/orientdb/database_pool.rb +0 -2
- data/lib/orientdb/document.rb +11 -6
- data/lib/orientdb/ext.rb +2 -2
- data/lib/orientdb/oclass.rb +16 -47
- data/lib/orientdb/property.rb +39 -0
- data/lib/orientdb/schema.rb +3 -2
- data/lib/orientdb/sql_query.rb +13 -0
- data/lib/orientdb/user.rb +0 -2
- data/orientdb.gemspec +89 -19
- data/spec/database_spec.rb +91 -0
- data/spec/document_spec.rb +75 -0
- data/spec/orientdb_spec.rb +2 -23
- data/spec/spec_helper.rb +56 -9
- metadata +72 -25
- data/jars/orient-commons-0.9.23.jar +0 -0
- data/jars/orientdb-client-0.9.23.jar +0 -0
- data/jars/orientdb-core-0.9.23.jar +0 -0
- data/jars/orientdb-enterprise-0.9.23.jar +0 -0
- data/jars/orientdb-server-0.9.23.jar +0 -0
- data/jars/orientdb-tools-0.9.23.jar +0 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Adrian Madrid
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,10 +1,56 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
3
|
|
4
|
-
|
4
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "orientdb"
|
10
|
+
gem.platform = "jruby"
|
11
|
+
gem.authors = ["Adrian Madrid"]
|
12
|
+
gem.email = ["aemadrid@gmail.com"]
|
13
|
+
gem.homepage = "http://rubygems.org/gems/orientdb"
|
14
|
+
gem.summary = "JRuby wrapper for OrientDB"
|
15
|
+
gem.description = "Simple JRuby wrapper for the OrientDB."
|
16
|
+
|
17
|
+
gem.required_rubygems_version = ">= 1.3.6"
|
18
|
+
gem.rubyforge_project = "orientdb"
|
19
|
+
|
20
|
+
gem.add_development_dependency "awesome_print"
|
21
|
+
gem.add_development_dependency "rspec", ">= 2.4"
|
22
|
+
|
23
|
+
gem.files = `git ls-files`.split("\n")
|
24
|
+
gem.test_files = Dir["test/test*.rb"]
|
25
|
+
gem.executables = `git ls-files`.split("\n").map { |f| f =~ /^bin\/(.*)/ ? $1 : nil }.compact
|
26
|
+
gem.require_path = 'lib'
|
27
|
+
end
|
28
|
+
Jeweler::GemcutterTasks.new
|
29
|
+
rescue LoadError
|
30
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'rspec/core/rake_task'
|
34
|
+
RSpec::Core::RakeTask.new(:spec)
|
35
|
+
|
36
|
+
desc "Run all examples using rcov"
|
37
|
+
RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
|
38
|
+
t.rcov = true
|
39
|
+
t.rcov_opts = %[-Ilib -Ispec --exclude "spec/*,gems/*" --text-report --sort coverage --aggregate coverage.data]
|
40
|
+
end
|
41
|
+
|
42
|
+
task :cleanup_rcov_files do
|
43
|
+
rm_rf 'coverage.data'
|
44
|
+
end
|
45
|
+
|
46
|
+
task :spec => :check_dependencies
|
47
|
+
|
48
|
+
task :default => :spec
|
49
|
+
|
50
|
+
require 'rake/rdoctask'
|
51
|
+
Rake::RDocTask.new do |rdoc|
|
52
|
+
rdoc.rdoc_dir = 'rdoc'
|
53
|
+
rdoc.title = "orientdb #{version}"
|
54
|
+
rdoc.rdoc_files.include('README*')
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.5
|
data/bin/orientdb_console
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/orientdb.rb
CHANGED
@@ -4,7 +4,7 @@ $: << File.dirname(__FILE__)
|
|
4
4
|
$: << File.expand_path('../../jars/', __FILE__)
|
5
5
|
|
6
6
|
require 'java'
|
7
|
-
require 'orientdb-client-0.9.
|
7
|
+
require 'orientdb-client-0.9.24'
|
8
8
|
|
9
9
|
module OrientDB
|
10
10
|
|
@@ -16,9 +16,12 @@ module OrientDB
|
|
16
16
|
end
|
17
17
|
|
18
18
|
require 'orientdb/ext'
|
19
|
+
require 'orientdb/constants'
|
19
20
|
require 'orientdb/version'
|
20
21
|
require 'orientdb/user'
|
22
|
+
require 'orientdb/property'
|
21
23
|
require 'orientdb/schema'
|
22
24
|
require 'orientdb/database'
|
23
25
|
require 'orientdb/document'
|
26
|
+
require 'orientdb/sql_query'
|
24
27
|
require 'orientdb/oclass'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module OrientDB
|
2
|
+
|
3
|
+
ClusterType = com.orientechnologies.orient.core.storage.OStorage::CLUSTER_TYPE
|
4
|
+
Database = com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
|
5
|
+
DatabasePool = com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool
|
6
|
+
Document = com.orientechnologies.orient.core.record.impl.ODocument
|
7
|
+
IndexType = com.orientechnologies.orient.core.metadata.schema.OProperty::INDEX_TYPE
|
8
|
+
OClass = com.orientechnologies.orient.core.metadata.schema.OClass
|
9
|
+
Property = com.orientechnologies.orient.core.metadata.schema.OProperty
|
10
|
+
Schema = com.orientechnologies.orient.core.metadata.schema.OSchema
|
11
|
+
SchemaType = com.orientechnologies.orient.core.metadata.schema.OType
|
12
|
+
SQLQuery = com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
|
13
|
+
SQLCommand = com.orientechnologies.orient.core.sql.OCommandSQL
|
14
|
+
User = com.orientechnologies.orient.core.metadata.security.OUser
|
15
|
+
|
16
|
+
STORAGE_TYPES = %w{ LOGICAL MEMORY PHYSICAL }.inject({}) { |h, s| h[s.downcase.to_sym] = ClusterType.const_get s; h }
|
17
|
+
INDEX_TYPES = %w{ FULLTEXT NOTUNIQUE UNIQUE }.inject({}) { |h, s| h[s.downcase.to_sym] = IndexType.const_get s; h }
|
18
|
+
|
19
|
+
FIELD_TYPES = {
|
20
|
+
:binary => "BINARY",
|
21
|
+
:bool => "BOOLEAN",
|
22
|
+
:boolean => "BOOLEAN",
|
23
|
+
:double => "BYTE",
|
24
|
+
:date => "DATE",
|
25
|
+
:datetime => "DATE",
|
26
|
+
:decimal => "FLOAT",
|
27
|
+
:double => "DOUBLE",
|
28
|
+
:embedded => "EMBEDDED",
|
29
|
+
:embedded_list => "EMBEDDEDLIST",
|
30
|
+
:embedded_map => "EMBEDDEDMAP",
|
31
|
+
:embedded_set => "EMBEDDEDSET",
|
32
|
+
:float => "FLOAT",
|
33
|
+
:int => "INTEGER",
|
34
|
+
:integer => "INTEGER",
|
35
|
+
:link => "LINK",
|
36
|
+
:link_list => "LINKLIST",
|
37
|
+
:link_map => "LINKMAP",
|
38
|
+
:link_set => "LINKSET",
|
39
|
+
:long => "LONG",
|
40
|
+
:short => "SHORT",
|
41
|
+
:string => "STRING",
|
42
|
+
}.inject({}) do |h, (k, v)|
|
43
|
+
h[k] = SchemaType.const_get v
|
44
|
+
h
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/lib/orientdb/database.rb
CHANGED
@@ -1,104 +1,141 @@
|
|
1
|
-
|
1
|
+
class OrientDB::Database
|
2
2
|
|
3
|
-
|
3
|
+
def auth(username, password)
|
4
|
+
open username, password
|
5
|
+
end
|
4
6
|
|
5
|
-
|
7
|
+
alias_method :native_command, :command
|
6
8
|
|
7
|
-
|
9
|
+
def command(sql_command = nil)
|
10
|
+
sql_command = prepare_sql_command sql_command
|
11
|
+
exc_cmd = sql_command.execute
|
12
|
+
native_command exc_cmd
|
13
|
+
end
|
8
14
|
|
9
|
-
|
10
|
-
|
15
|
+
def prepare_sql_command(sql_command)
|
16
|
+
return if sql_command.nil?
|
17
|
+
case sql_command
|
18
|
+
when SQLCommand
|
19
|
+
sql_command
|
20
|
+
when String
|
21
|
+
SQLCommand.new sql_command
|
22
|
+
else
|
23
|
+
raise "Unknown command type"
|
11
24
|
end
|
25
|
+
end
|
12
26
|
|
13
|
-
|
27
|
+
alias_method :native_query, :query
|
14
28
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
29
|
+
def query(sql_query = nil)
|
30
|
+
sql_query = prepare_sql_query sql_query
|
31
|
+
native_query sql_query
|
32
|
+
end
|
19
33
|
|
20
|
-
|
34
|
+
alias :find :query
|
35
|
+
alias :all :query
|
21
36
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
37
|
+
def first(sql_query = nil)
|
38
|
+
sql_query = prepare_sql_query(sql_query).setLimit(1)
|
39
|
+
query(sql_query).first
|
40
|
+
end
|
26
41
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
42
|
+
def prepare_sql_query(sql_query)
|
43
|
+
return if sql_query.nil?
|
44
|
+
case sql_query
|
45
|
+
when com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
|
46
|
+
sql_query
|
47
|
+
when String
|
48
|
+
com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.new sql_query
|
49
|
+
when Hash
|
50
|
+
com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.new sql_query_from_hash(sql_query)
|
51
|
+
else
|
52
|
+
raise "Unknown query type"
|
39
53
|
end
|
54
|
+
end
|
40
55
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
def sql_query_from_hash(options = {})
|
57
|
+
target = options.delete :oclass
|
58
|
+
raise "Missing oclass name" unless target
|
59
|
+
|
60
|
+
columns = options.delete(:columns) || '*'
|
61
|
+
order = options.delete :order
|
62
|
+
order_sql = order ? " ORDER BY #{order}" : ''
|
63
|
+
limit = options.delete :limit
|
64
|
+
limit_sql = limit ? " LIMIT #{limit}" : ''
|
65
|
+
range_low = options.delete(:range_low) || options.delete(:range)
|
66
|
+
range_high = options.delete :range_high
|
67
|
+
range_sql = range_low ? " RANGE #{range_low}#{range_high ? ",#{range_high}" : ''}" : ''
|
68
|
+
fields = options.map { |field, value| "#{field} #{operator_for(value)} #{quote(value)}" }
|
69
|
+
where_sql = fields.size > 0 ? " WHERE #{fields.join(' AND ')}" : ''
|
70
|
+
|
71
|
+
"SELECT #{columns} FROM #{target}" + where_sql + order_sql + limit_sql + range_sql
|
72
|
+
end
|
57
73
|
|
58
|
-
|
59
|
-
|
74
|
+
def operator_for(value)
|
75
|
+
case value
|
76
|
+
when Integer, Float, Symbol
|
77
|
+
"="
|
78
|
+
when String
|
79
|
+
value.index('%') ? "LIKE" : "="
|
80
|
+
when Array
|
81
|
+
"IN"
|
60
82
|
end
|
83
|
+
end
|
61
84
|
|
62
|
-
|
63
|
-
|
85
|
+
def quote(value)
|
86
|
+
case value
|
87
|
+
when Integer, Float, Symbol
|
88
|
+
value.to_s
|
89
|
+
when String
|
90
|
+
"'#{value}'"
|
91
|
+
when Array
|
92
|
+
"[" + value.map { |x| quote(x) }.join(", ") + "]"
|
64
93
|
end
|
94
|
+
end
|
65
95
|
|
66
|
-
|
67
|
-
|
68
|
-
|
96
|
+
def schema
|
97
|
+
metadata.schema
|
98
|
+
end
|
69
99
|
|
70
|
-
|
71
|
-
|
72
|
-
|
100
|
+
def get_class(klass_name)
|
101
|
+
schema.get_class klass_name.to_s
|
102
|
+
end
|
73
103
|
|
74
|
-
|
104
|
+
def create_class(klass_name, fields = {})
|
105
|
+
OrientDB::OClass.create self, klass_name.to_s, fields
|
106
|
+
end
|
75
107
|
|
76
|
-
|
77
|
-
|
78
|
-
|
108
|
+
def get_or_create_class(klass_name)
|
109
|
+
get_class(klass_name) || create_class(klass_name)
|
110
|
+
end
|
79
111
|
|
80
|
-
|
112
|
+
alias :each_in_class :browseClass
|
81
113
|
|
82
|
-
|
83
|
-
|
84
|
-
|
114
|
+
def all_in_class(klass_name)
|
115
|
+
browse_class(klass_name.to_s).map
|
116
|
+
end
|
117
|
+
|
118
|
+
alias :each_in_cluster :browseCluster
|
85
119
|
|
86
|
-
|
120
|
+
def all_in_cluster(cluster_name)
|
121
|
+
browse_cluster(cluster_name.to_s).map
|
122
|
+
end
|
87
123
|
|
88
|
-
|
89
|
-
obj = new(database_url)
|
90
|
-
obj.create
|
91
|
-
obj
|
92
|
-
end
|
124
|
+
class << self
|
93
125
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
126
|
+
def create(database_url)
|
127
|
+
obj = new(database_url)
|
128
|
+
obj.create
|
129
|
+
obj
|
130
|
+
end
|
99
131
|
|
132
|
+
def connect(database_url, username, password)
|
133
|
+
obj = new(database_url)
|
134
|
+
obj.auth(username, password)
|
135
|
+
obj
|
100
136
|
end
|
137
|
+
|
101
138
|
end
|
139
|
+
end
|
102
140
|
|
103
141
|
|
104
|
-
end
|
data/lib/orientdb/document.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module OrientDB
|
2
2
|
|
3
|
-
Document = com.orientechnologies.orient.core.record.impl.ODocument
|
4
|
-
|
5
3
|
class Document
|
6
4
|
|
7
5
|
def values
|
@@ -20,6 +18,8 @@ module OrientDB
|
|
20
18
|
|
21
19
|
def method_missing(method_name, *args, &blk)
|
22
20
|
return self[method_name] if contains_field(method_name.to_s)
|
21
|
+
return nil if schema_class.exists_property?(method_name.to_s)
|
22
|
+
|
23
23
|
match = method_name.to_s.match(/(.*?)([?=!]?)$/)
|
24
24
|
case match[2]
|
25
25
|
when "="
|
@@ -31,9 +31,13 @@ module OrientDB
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def rid
|
35
|
+
identity.to_s
|
36
|
+
end
|
37
|
+
|
34
38
|
def inspect
|
35
|
-
props = values.map { |k, v| "#{k}:#{v}" }.join(' ')
|
36
|
-
%{#<OrientDB::Document:#{
|
39
|
+
props = values.map { |k, v| "#{k}:#{v.inspect}" }.join(' ')
|
40
|
+
%{#<OrientDB::Document:#{class_name}:#{rid}#{props.empty? ? '' : ' ' + props}>}
|
37
41
|
end
|
38
42
|
|
39
43
|
alias :to_s :inspect
|
@@ -43,9 +47,10 @@ module OrientDB
|
|
43
47
|
alias_method :native_new, :new
|
44
48
|
|
45
49
|
def new(db, klass_name, fields = {})
|
46
|
-
|
50
|
+
puts "new : #{db} : #{klass_name} : #{fields.inspect}"
|
51
|
+
obj = native_new db, klass_name.to_s
|
47
52
|
fields.each do |name, value|
|
48
|
-
obj.field name, value
|
53
|
+
obj.field name.to_s, value
|
49
54
|
end
|
50
55
|
obj
|
51
56
|
end
|
data/lib/orientdb/ext.rb
CHANGED
@@ -2,12 +2,12 @@ require 'date'
|
|
2
2
|
|
3
3
|
class Date
|
4
4
|
def proxy_object
|
5
|
-
java.util.Date.new year, month - 1, day
|
5
|
+
java.util.Date.new year, month - 1, day, 0, 0, 0
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
class DateTime
|
10
10
|
def proxy_object
|
11
|
-
java.util.Date.new year, month - 1, day
|
11
|
+
java.util.Date.new year, month - 1, day, hour, min, sec
|
12
12
|
end
|
13
13
|
end
|
data/lib/orientdb/oclass.rb
CHANGED
@@ -1,44 +1,5 @@
|
|
1
1
|
module OrientDB
|
2
2
|
|
3
|
-
|
4
|
-
OClass = com.orientechnologies.orient.core.metadata.schema.OClass
|
5
|
-
|
6
|
-
# SchemaType = com.orientechnologies.orient.core.metadata.schema.OType
|
7
|
-
ClusterType = com.orientechnologies.orient.core.storage.OStorage::CLUSTER_TYPE
|
8
|
-
IndexType = com.orientechnologies.orient.core.metadata.schema.OProperty::INDEX_TYPE
|
9
|
-
|
10
|
-
|
11
|
-
FIELD_TYPES = {
|
12
|
-
:binary => "BINARY",
|
13
|
-
:bool => "BOOLEAN",
|
14
|
-
:boolean => "BOOLEAN",
|
15
|
-
:double => "BYTE",
|
16
|
-
:date => "DATE",
|
17
|
-
:datetime => "DATE",
|
18
|
-
:decimal => "FLOAT",
|
19
|
-
:double => "DOUBLE",
|
20
|
-
:embedded => "EMBEDDED",
|
21
|
-
:embedded_list => "EMBEDDEDLIST",
|
22
|
-
:embedded_map => "EMBEDDEDMAP",
|
23
|
-
:embedded_set => "EMBEDDEDSET",
|
24
|
-
:float => "FLOAT",
|
25
|
-
:int => "INTEGER",
|
26
|
-
:integer => "INTEGER",
|
27
|
-
:link => "LINK",
|
28
|
-
:link_list => "LINKLIST",
|
29
|
-
:link_map => "LINKMAP",
|
30
|
-
:link_set => "LINKSET",
|
31
|
-
:long => "LONG",
|
32
|
-
:short => "SHORT",
|
33
|
-
:string => "STRING",
|
34
|
-
}.inject({}) do |h, (k, v)|
|
35
|
-
h[k] = SchemaType.const_get v
|
36
|
-
h
|
37
|
-
end
|
38
|
-
|
39
|
-
STORAGE_TYPES = %w{ LOGICAL MEMORY PHYSICAL }.inject({}) { |h, s| h[s.downcase.to_sym] = ClusterType.const_get s; h }
|
40
|
-
INDEX_TYPES = %w{ FULLTEXT NOT_UNIQUE UNIQUE }.inject({}) { |h, s| h[s.downcase.to_sym] = IndexType.const_get s; h }
|
41
|
-
|
42
3
|
class OClass
|
43
4
|
|
44
5
|
def add(property_name, type)
|
@@ -55,6 +16,7 @@ module OrientDB
|
|
55
16
|
create_property property_name, FIELD_TYPES[:link], type
|
56
17
|
when Array
|
57
18
|
type[0] = FIELD_TYPES[type[0]] if type[0].is_a?(Symbol)
|
19
|
+
type[1] = FIELD_TYPES[type[1]] if type[1].is_a?(Symbol)
|
58
20
|
create_property property_name, *type
|
59
21
|
when Hash
|
60
22
|
raise "Missing property type for [#{property_name}]" unless type[:type]
|
@@ -68,7 +30,7 @@ module OrientDB
|
|
68
30
|
prop.set_mandatory !!type[:mandatory] unless type[:mandatory].nil?
|
69
31
|
prop.set_not_null type[:not_null] unless type[:not_null].nil?
|
70
32
|
unless type[:index].nil?
|
71
|
-
index_type = type[:index] == true ? INDEX_TYPES[:
|
33
|
+
index_type = type[:index] == true ? INDEX_TYPES[:notunique] : INDEX_TYPES[type[:index]]
|
72
34
|
prop.createIndex index_type
|
73
35
|
end
|
74
36
|
else
|
@@ -91,13 +53,15 @@ module OrientDB
|
|
91
53
|
end
|
92
54
|
|
93
55
|
def inspect
|
94
|
-
props = properties.map { |x| "#{x.name}
|
95
|
-
|
56
|
+
props = properties.map { |x| "#{x.name}=#{x.type.to_s.downcase}#{x.is_indexed? ? '(idx)' : ''}" }.join(' ')
|
57
|
+
"#<OrientDB::OClass:" + name +
|
58
|
+
(getSuperClass ? ' super=' + getSuperClass.name : '') +
|
59
|
+
(props.empty? ? '' : ' ' + props) +
|
60
|
+
">"
|
96
61
|
end
|
97
62
|
|
98
63
|
alias :to_s :inspect
|
99
64
|
|
100
|
-
|
101
65
|
class << self
|
102
66
|
|
103
67
|
def create(db, name, fields = {})
|
@@ -105,11 +69,16 @@ module OrientDB
|
|
105
69
|
add_cluster = fields.delete :add_cluster
|
106
70
|
add_cluster = true if add_cluster.nil?
|
107
71
|
|
108
|
-
if
|
109
|
-
|
110
|
-
klass = db.schema.create_class name, cluster
|
72
|
+
if db.schema.exists_class? name
|
73
|
+
klass = db.get_class name
|
111
74
|
else
|
112
|
-
|
75
|
+
if add_cluster && !db.storage.cluster_names.include?(name.downcase)
|
76
|
+
cluster = db.storage.add_cluster name.downcase, STORAGE_TYPES[:physical]
|
77
|
+
klass = db.schema.create_class name, cluster
|
78
|
+
else
|
79
|
+
klass = db.schema.create_class name
|
80
|
+
cluster = db.storage.get_cluster_by_name name.downcase
|
81
|
+
end
|
113
82
|
end
|
114
83
|
|
115
84
|
super_klass = fields.delete :super
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module OrientDB
|
2
|
+
|
3
|
+
class Property
|
4
|
+
|
5
|
+
def type_short
|
6
|
+
@type_short ||= OrientDB::FIELD_TYPES.select { |k, v| v.name == getType.name }.first.first
|
7
|
+
end
|
8
|
+
|
9
|
+
def linked_type_short
|
10
|
+
@linked_type_short ||= getLinkedType && OrientDB::FIELD_TYPES.select { |k, v| v.name == getLinkedType.name }.first.first
|
11
|
+
end
|
12
|
+
|
13
|
+
def info
|
14
|
+
{
|
15
|
+
:name => name,
|
16
|
+
:type => type_short,
|
17
|
+
:index => indexed? ? getIndex.name : nil,
|
18
|
+
:min => min,
|
19
|
+
:max => max,
|
20
|
+
:mandatory => is_mandatory?,
|
21
|
+
:not_null => is_not_null?,
|
22
|
+
:linked_type => linked_type_short,
|
23
|
+
:linked_class => linked_type_short ? getLinkedClass.name : nil,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def inspect
|
28
|
+
"#<OrientDB::Propery:#{name} type=#{type_short} " +
|
29
|
+
"#{linked_type_short ? "linked_type=#{linked_type_short} linked_class=#{getLinkedClass.name}" : ''}" +
|
30
|
+
"indexed=#{is_indexed?} mandatory=#{is_mandatory?} not_null=#{is_not_null}" +
|
31
|
+
"#{min ? " min=#{min}" : ''}#{max ? " max=#{max}" : ''}" +
|
32
|
+
">"
|
33
|
+
end
|
34
|
+
|
35
|
+
alias :to_s :inspect
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/orientdb/schema.rb
CHANGED
data/lib/orientdb/user.rb
CHANGED
data/orientdb.gemspec
CHANGED
@@ -1,26 +1,96 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path("../lib/orientdb/version", __FILE__)
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
6
|
-
s.version
|
7
|
-
s.platform
|
8
|
-
s.authors = ["Adrian Madrid"]
|
9
|
-
s.email = ["aemadrid@gmail.com"]
|
10
|
-
s.homepage = "http://rubygems.org/gems/orientdb"
|
11
|
-
s.summary = "JRuby wrapper for OrientDB"
|
12
|
-
s.description = "JRuby wrapper for OrientDB"
|
7
|
+
s.name = %q{orientdb}
|
8
|
+
s.version = "0.0.5"
|
9
|
+
s.platform = %q{jruby}
|
13
10
|
|
14
|
-
s.required_rubygems_version = ">= 1.3.6"
|
15
|
-
s.
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.3.6") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Adrian Madrid"]
|
13
|
+
s.date = %q{2011-01-12}
|
14
|
+
s.default_executable = %q{orientdb_console}
|
15
|
+
s.description = %q{Simple JRuby wrapper for the OrientDB.}
|
16
|
+
s.email = ["aemadrid@gmail.com"]
|
17
|
+
s.executables = ["orientdb_console"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
".gitignore",
|
25
|
+
".rvmrc",
|
26
|
+
"Gemfile",
|
27
|
+
"Gemfile.lock",
|
28
|
+
"LICENSE",
|
29
|
+
"README.rdoc",
|
30
|
+
"Rakefile",
|
31
|
+
"VERSION",
|
32
|
+
"bin/orientdb_console",
|
33
|
+
"jars/orient-commons-0.9.24.jar",
|
34
|
+
"jars/orientdb-client-0.9.24.jar",
|
35
|
+
"jars/orientdb-core-0.9.24.jar",
|
36
|
+
"jars/orientdb-enterprise-0.9.24.jar",
|
37
|
+
"jars/orientdb-server-0.9.24.jar",
|
38
|
+
"jars/orientdb-tools-0.9.24.jar",
|
39
|
+
"jars/persistence-api-1.0.jar",
|
40
|
+
"lib/orientdb.rb",
|
41
|
+
"lib/orientdb/constants.rb",
|
42
|
+
"lib/orientdb/database.rb",
|
43
|
+
"lib/orientdb/database_pool.rb",
|
44
|
+
"lib/orientdb/document.rb",
|
45
|
+
"lib/orientdb/ext.rb",
|
46
|
+
"lib/orientdb/oclass.rb",
|
47
|
+
"lib/orientdb/property.rb",
|
48
|
+
"lib/orientdb/schema.rb",
|
49
|
+
"lib/orientdb/sql_query.rb",
|
50
|
+
"lib/orientdb/user.rb",
|
51
|
+
"lib/orientdb/version.rb",
|
52
|
+
"orientdb.gemspec",
|
53
|
+
"spec/database_spec.rb",
|
54
|
+
"spec/document_spec.rb",
|
55
|
+
"spec/orientdb_spec.rb",
|
56
|
+
"spec/spec.opts",
|
57
|
+
"spec/spec_helper.rb"
|
58
|
+
]
|
59
|
+
s.homepage = %q{http://rubygems.org/gems/orientdb}
|
60
|
+
s.require_paths = ["lib"]
|
61
|
+
s.rubyforge_project = %q{orientdb}
|
62
|
+
s.rubygems_version = %q{1.3.6}
|
63
|
+
s.summary = %q{JRuby wrapper for OrientDB}
|
16
64
|
|
17
|
-
s.
|
18
|
-
|
19
|
-
|
20
|
-
s.add_development_dependency "rspec", ">= 2.1"
|
65
|
+
if s.respond_to? :specification_version then
|
66
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
67
|
+
s.specification_version = 3
|
21
68
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
69
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
70
|
+
s.add_runtime_dependency(%q<orientdb>, [">= 0"])
|
71
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
72
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
73
|
+
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
74
|
+
s.add_development_dependency(%q<rspec>, [">= 2.1"])
|
75
|
+
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
76
|
+
s.add_development_dependency(%q<rspec>, [">= 2.4"])
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<orientdb>, [">= 0"])
|
79
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
80
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
81
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
82
|
+
s.add_dependency(%q<rspec>, [">= 2.1"])
|
83
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
84
|
+
s.add_dependency(%q<rspec>, [">= 2.4"])
|
85
|
+
end
|
86
|
+
else
|
87
|
+
s.add_dependency(%q<orientdb>, [">= 0"])
|
88
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
89
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
90
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
91
|
+
s.add_dependency(%q<rspec>, [">= 2.1"])
|
92
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
93
|
+
s.add_dependency(%q<rspec>, [">= 2.4"])
|
94
|
+
end
|
26
95
|
end
|
96
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe "OrientDB" do
|
4
|
+
|
5
|
+
describe "Database" do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
create_classes
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should create a valid simple table" do
|
12
|
+
exp_class = "#<OrientDB::OClass:person name=string>"
|
13
|
+
exp_props = ["#<OrientDB::Propery:name type=string indexed=false mandatory=false not_null=false>"]
|
14
|
+
@person_class.to_s.should == exp_class
|
15
|
+
@person_class.properties.map { |x| x.to_s }.should == exp_props
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should create a valid simple descendant table" do
|
19
|
+
exp_class = "#<OrientDB::OClass:customer super=person tab=float name=string>"
|
20
|
+
exp_props = [
|
21
|
+
"#<OrientDB::Propery:tab type=decimal indexed=false mandatory=false not_null=false>",
|
22
|
+
"#<OrientDB::Propery:name type=string indexed=false mandatory=false not_null=false>"
|
23
|
+
]
|
24
|
+
@customer_class.to_s.should == exp_class
|
25
|
+
@customer_class.properties.map { |x| x.to_s }.should == exp_props
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should create a complex table" do
|
29
|
+
exp_class = "#<OrientDB::OClass:invoice number=integer(idx) customer=link sold_on=date total=float lines=linklist>"
|
30
|
+
exp_props = [
|
31
|
+
"#<OrientDB::Propery:number type=int indexed=true mandatory=true not_null=false>",
|
32
|
+
"#<OrientDB::Propery:customer type=link indexed=false mandatory=false not_null=true>",
|
33
|
+
"#<OrientDB::Propery:sold_on type=date indexed=false mandatory=false not_null=false>",
|
34
|
+
"#<OrientDB::Propery:total type=decimal indexed=false mandatory=false not_null=false>",
|
35
|
+
"#<OrientDB::Propery:lines type=link_list indexed=false mandatory=false not_null=false>"
|
36
|
+
]
|
37
|
+
@invoice_class.to_s.should == exp_class
|
38
|
+
@invoice_class.properties.map { |x| x.to_s }.should == exp_props
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "Query" do
|
42
|
+
|
43
|
+
before :all do
|
44
|
+
create_classes
|
45
|
+
|
46
|
+
@oclass = @employee_class.name
|
47
|
+
@e1 = OrientDB::Document.create DB, @oclass, :name => "Mark", :age => 36, :groups => %w{admin sales}
|
48
|
+
@e2 = OrientDB::Document.create DB, @oclass, :name => "John", :age => 37, :groups => %w{admin tech}
|
49
|
+
@e3 = OrientDB::Document.create DB, @oclass, :name => "Luke", :age => 38, :groups => %w{tech support}
|
50
|
+
@e4 = OrientDB::Document.create DB, @oclass, :name => "Matt", :age => 39, :groups => %w{admin office}
|
51
|
+
@e5 = OrientDB::Document.create DB, @oclass, :name => "Pete", :age => 40, :groups => %w{vp office}
|
52
|
+
@employees = [@e1,@e2,@e3,@e4,@e5]
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should prepare valid queries" do
|
56
|
+
qry1 = DB.prepare_sql_query :oclass => "person"
|
57
|
+
qry1.should be_a_kind_of OrientDB::SQLQuery
|
58
|
+
qry1.text.should == "SELECT * FROM person"
|
59
|
+
|
60
|
+
qry2 = DB.prepare_sql_query :oclass => "person", :name => "John"
|
61
|
+
qry2.should be_a_kind_of OrientDB::SQLQuery
|
62
|
+
qry2.text.should == "SELECT * FROM person WHERE name = 'John'"
|
63
|
+
|
64
|
+
qry3 = DB.prepare_sql_query qry2.text
|
65
|
+
qry3.should be_a_kind_of OrientDB::SQLQuery
|
66
|
+
qry3.text.should == qry2.text
|
67
|
+
|
68
|
+
qry4 = DB.prepare_sql_query qry3
|
69
|
+
qry4.should be_a_kind_of OrientDB::SQLQuery
|
70
|
+
qry4.text.should == qry2.text
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should get all rows for a class" do
|
74
|
+
DB.all(:oclass => @oclass).map.should == @employees
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should find rows by simple field values" do
|
78
|
+
DB.first(:oclass => @oclass, :name => "Mark").should == @e1
|
79
|
+
DB.first(:oclass => @oclass, :age => 37).should == @e2
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should find rows by values in arrays" do
|
83
|
+
qry = DB.prepare_sql_query "SELECT * FROM #{@oclass} WHERE 'admin' IN groups"
|
84
|
+
DB.query(qry).map.should == [@e1,@e2,@e4]
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.expand_path("../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
describe "OrientDB" do
|
4
|
+
|
5
|
+
describe "Document" do
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
create_classes
|
9
|
+
|
10
|
+
@h_fields = {:sku => 'H509', :title => "Hammer", :price => 3.25}
|
11
|
+
@hammer = OrientDB::Document.create DB, @product_class.name, @h_fields
|
12
|
+
|
13
|
+
@n_fields = {:sku => 'N034', :title => "Nail", :price => 0.25}
|
14
|
+
@nail = OrientDB::Document.create DB, @product_class.name, @n_fields
|
15
|
+
|
16
|
+
@line1 = OrientDB::Document.create DB, @line_class.name,
|
17
|
+
:product => @hammer,
|
18
|
+
:quantity => 1,
|
19
|
+
:price => @hammer.price
|
20
|
+
@line2 = OrientDB::Document.create DB, @line_class.name,
|
21
|
+
:product => @nail,
|
22
|
+
:quantity => 10,
|
23
|
+
:price => @nail.price
|
24
|
+
@lines = [@line1, @line2]
|
25
|
+
@total = @lines.inject(0.0) { |a, x| a + x.price * x.quantity }
|
26
|
+
|
27
|
+
@customer = OrientDB::Document.create DB, @customer_class.name,
|
28
|
+
:name => "Mark Dumber",
|
29
|
+
:tab => 500.00
|
30
|
+
|
31
|
+
@invoice = OrientDB::Document.create DB, @invoice_class.name,
|
32
|
+
:number => 10001,
|
33
|
+
:customer => @customer,
|
34
|
+
:total => @total.to_s,
|
35
|
+
:sold_on => Date.civil(2011, 1, 1).proxy_object,
|
36
|
+
:lines => @lines
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should instantiate new documents" do
|
40
|
+
@screw = OrientDB::Document.new DB, @product_class.name, :sku => "S365", :price => 0.33
|
41
|
+
@screw.should be_a_kind_of OrientDB::Document
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should create simple documents" do
|
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
|
+
@h_fields.each { |k, v| @hammer[k].should == v }
|
48
|
+
|
49
|
+
@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
|
+
@n_fields.each { |k, v| @nail.send(k).should == v }
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should create embedded documents" do
|
55
|
+
@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
|
+
@line1.product.should == @hammer
|
58
|
+
@line1.price.should == @hammer.price
|
59
|
+
|
60
|
+
@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
|
+
@line2.product.should == @nail
|
63
|
+
@line2.price.should == @nail.price
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should create complex, embedded documents" do
|
67
|
+
@invoice.should be_a_kind_of OrientDB::Document
|
68
|
+
# @invoice.to_s.should == "#<OrientDB::Document:invoice_line:8:0 product:#<OrientDB::Document:product:7:0 title:Hammer price:5.5 sku:H509> price:5.5 quantity:1>"
|
69
|
+
@invoice.customer.should == @customer
|
70
|
+
@invoice.total = @total
|
71
|
+
@invoice.lines.should == [@line1, @line2]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/spec/orientdb_spec.rb
CHANGED
@@ -2,30 +2,9 @@ require File.expand_path("../spec_helper", __FILE__)
|
|
2
2
|
|
3
3
|
describe "OrientDB" do
|
4
4
|
|
5
|
-
before :all do
|
6
|
-
@db = OrientDB::Database.new("local:#{TEST_DB_PATH}/test").create
|
7
|
-
@person_class = @db.create_class :person, :name => :string
|
8
|
-
@customer_class = @db.create_class :customer, :super => @person_class
|
9
|
-
@product_class = @db.create_class :product, :sku => :string, :title => :string, :price => :float
|
10
|
-
@line_class = @db.create_class :invoice_line, :product => @product_class, :quantity => :int, :price => :float
|
11
|
-
@invoice_class = @db.create_class :invoice,
|
12
|
-
:number => {:type => :int, :mandatory => true, :index => true},
|
13
|
-
:customer => {:type => @customer_class, :not_null => true},
|
14
|
-
:sold_on => :date,
|
15
|
-
:total => {:type => :float, :min => 0.01, :max => 100_000.0},
|
16
|
-
:lines => :embedded_list
|
17
|
-
end
|
18
|
-
|
19
|
-
after :all do
|
20
|
-
@db.close
|
21
|
-
# puts "Removing files in #{TEMP_DIR}/databases/*"
|
22
|
-
# FileUtils.rm_rf "#{TEMP_DIR}/databases/test"
|
23
|
-
end
|
24
|
-
|
25
5
|
it "should create a valid database" do
|
26
|
-
|
27
|
-
|
28
|
-
@db.name.should == "test"
|
6
|
+
DB.should be_a_kind_of OrientDB::Database
|
7
|
+
DB.name.should == "test"
|
29
8
|
end
|
30
9
|
|
31
10
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'orientdb'
|
4
|
+
require 'rspec'
|
5
|
+
#require 'rspec/autorun'
|
6
|
+
require 'fileutils'
|
7
|
+
|
1
8
|
unless defined?(SPEC_HELPER_LOADED)
|
2
9
|
|
3
|
-
GEM_ROOT
|
4
|
-
LIB_ROOT
|
5
|
-
SPEC_ROOT
|
6
|
-
TEMP_DIR
|
10
|
+
GEM_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
11
|
+
LIB_ROOT = GEM_ROOT + '/lib'
|
12
|
+
SPEC_ROOT = GEM_ROOT + '/spec'
|
13
|
+
TEMP_DIR = SPEC_ROOT + '/tmp'
|
7
14
|
|
8
15
|
TEST_DB_PATH = "#{TEMP_DIR}/databases/db_#{rand(999) + 1}"
|
9
16
|
|
@@ -12,13 +19,53 @@ unless defined?(SPEC_HELPER_LOADED)
|
|
12
19
|
|
13
20
|
$LOAD_PATH.unshift(LIB_ROOT) unless $LOAD_PATH.include?(LIB_ROOT)
|
14
21
|
|
15
|
-
require 'orientdb'
|
16
|
-
require 'spec'
|
17
|
-
require 'fileutils'
|
18
|
-
|
19
22
|
FileUtils.mkdir_p TEST_DB_PATH
|
20
23
|
|
21
|
-
|
24
|
+
DB = OrientDB::Database.new("local:#{TEST_DB_PATH}/test").create
|
25
|
+
|
26
|
+
module Helpers
|
27
|
+
def create_classes
|
28
|
+
# People
|
29
|
+
@person_class = DB.create_class :person, :name => :string
|
30
|
+
# Customers
|
31
|
+
@customer_class = DB.create_class :customer,
|
32
|
+
:super => @person_class,
|
33
|
+
:tab => :float
|
34
|
+
# Employees
|
35
|
+
@employee_class = DB.create_class :employee,
|
36
|
+
:super => @person_class,
|
37
|
+
:age => :int,
|
38
|
+
:groups => [:embedded_list, :string]
|
39
|
+
@employee_class.truncate
|
40
|
+
@customer_class.truncate
|
41
|
+
@person_class.truncate
|
42
|
+
# Products
|
43
|
+
@product_class = DB.create_class :product,
|
44
|
+
:sku => :string,
|
45
|
+
:title => :string,
|
46
|
+
:price => :float
|
47
|
+
@product_class.truncate
|
48
|
+
# Invoice Lines
|
49
|
+
@line_class = DB.create_class :invoice_line,
|
50
|
+
:product => @product_class,
|
51
|
+
:quantity => :int,
|
52
|
+
:price => :float
|
53
|
+
@line_class.truncate
|
54
|
+
# Invoices
|
55
|
+
@invoice_class = DB.create_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]
|
61
|
+
@invoice_class.truncate
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
RSpec.configure do |config|
|
66
|
+
include Helpers
|
67
|
+
|
68
|
+
config.color_enabled = true
|
22
69
|
end
|
23
70
|
|
24
71
|
SPEC_HELPER_LOADED = true
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: jruby
|
11
11
|
authors:
|
12
12
|
- Adrian Madrid
|
@@ -14,25 +14,36 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
17
|
+
date: 2011-01-12 00:00:00 -07:00
|
18
|
+
default_executable: orientdb_console
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: orientdb
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 0
|
28
|
+
version: "0"
|
29
|
+
requirement: *id001
|
22
30
|
prerelease: false
|
23
|
-
|
31
|
+
type: :runtime
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: hashie
|
34
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
24
35
|
requirements:
|
25
36
|
- - ">="
|
26
37
|
- !ruby/object:Gem::Version
|
27
38
|
segments:
|
28
39
|
- 0
|
29
40
|
version: "0"
|
41
|
+
requirement: *id002
|
42
|
+
prerelease: false
|
30
43
|
type: :runtime
|
31
|
-
version_requirements: *id001
|
32
44
|
- !ruby/object:Gem::Dependency
|
33
45
|
name: bundler
|
34
|
-
|
35
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
46
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
36
47
|
requirements:
|
37
48
|
- - ">="
|
38
49
|
- !ruby/object:Gem::Version
|
@@ -41,24 +52,24 @@ dependencies:
|
|
41
52
|
- 0
|
42
53
|
- 0
|
43
54
|
version: 1.0.0
|
55
|
+
requirement: *id003
|
56
|
+
prerelease: false
|
44
57
|
type: :development
|
45
|
-
version_requirements: *id002
|
46
58
|
- !ruby/object:Gem::Dependency
|
47
59
|
name: awesome_print
|
48
|
-
|
49
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
60
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
50
61
|
requirements:
|
51
62
|
- - ">="
|
52
63
|
- !ruby/object:Gem::Version
|
53
64
|
segments:
|
54
65
|
- 0
|
55
66
|
version: "0"
|
67
|
+
requirement: *id004
|
68
|
+
prerelease: false
|
56
69
|
type: :development
|
57
|
-
version_requirements: *id003
|
58
70
|
- !ruby/object:Gem::Dependency
|
59
71
|
name: rspec
|
60
|
-
|
61
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
62
73
|
requirements:
|
63
74
|
- - ">="
|
64
75
|
- !ruby/object:Gem::Version
|
@@ -66,41 +77,77 @@ dependencies:
|
|
66
77
|
- 2
|
67
78
|
- 1
|
68
79
|
version: "2.1"
|
80
|
+
requirement: *id005
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: awesome_print
|
85
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
requirement: *id006
|
93
|
+
prerelease: false
|
69
94
|
type: :development
|
70
|
-
|
71
|
-
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
segments:
|
102
|
+
- 2
|
103
|
+
- 4
|
104
|
+
version: "2.4"
|
105
|
+
requirement: *id007
|
106
|
+
prerelease: false
|
107
|
+
type: :development
|
108
|
+
description: Simple JRuby wrapper for the OrientDB.
|
72
109
|
email:
|
73
110
|
- aemadrid@gmail.com
|
74
111
|
executables:
|
75
112
|
- orientdb_console
|
76
113
|
extensions: []
|
77
114
|
|
78
|
-
extra_rdoc_files:
|
79
|
-
|
115
|
+
extra_rdoc_files:
|
116
|
+
- LICENSE
|
117
|
+
- README.rdoc
|
80
118
|
files:
|
119
|
+
- .document
|
81
120
|
- .gitignore
|
82
121
|
- .rvmrc
|
83
122
|
- Gemfile
|
84
123
|
- Gemfile.lock
|
124
|
+
- LICENSE
|
85
125
|
- README.rdoc
|
86
126
|
- Rakefile
|
127
|
+
- VERSION
|
87
128
|
- bin/orientdb_console
|
88
|
-
- jars/orient-commons-0.9.
|
89
|
-
- jars/orientdb-client-0.9.
|
90
|
-
- jars/orientdb-core-0.9.
|
91
|
-
- jars/orientdb-enterprise-0.9.
|
92
|
-
- jars/orientdb-server-0.9.
|
93
|
-
- jars/orientdb-tools-0.9.
|
129
|
+
- jars/orient-commons-0.9.24.jar
|
130
|
+
- jars/orientdb-client-0.9.24.jar
|
131
|
+
- jars/orientdb-core-0.9.24.jar
|
132
|
+
- jars/orientdb-enterprise-0.9.24.jar
|
133
|
+
- jars/orientdb-server-0.9.24.jar
|
134
|
+
- jars/orientdb-tools-0.9.24.jar
|
135
|
+
- jars/persistence-api-1.0.jar
|
94
136
|
- lib/orientdb.rb
|
137
|
+
- lib/orientdb/constants.rb
|
95
138
|
- lib/orientdb/database.rb
|
96
139
|
- lib/orientdb/database_pool.rb
|
97
140
|
- lib/orientdb/document.rb
|
98
141
|
- lib/orientdb/ext.rb
|
99
142
|
- lib/orientdb/oclass.rb
|
143
|
+
- lib/orientdb/property.rb
|
100
144
|
- lib/orientdb/schema.rb
|
145
|
+
- lib/orientdb/sql_query.rb
|
101
146
|
- lib/orientdb/user.rb
|
102
147
|
- lib/orientdb/version.rb
|
103
148
|
- orientdb.gemspec
|
149
|
+
- spec/database_spec.rb
|
150
|
+
- spec/document_spec.rb
|
104
151
|
- spec/orientdb_spec.rb
|
105
152
|
- spec/spec.opts
|
106
153
|
- spec/spec_helper.rb
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|