orientdb 0.0.17-jruby → 0.0.19-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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.17
1
+ 0.0.19
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ module OrientDB
2
+
3
+ #IndexType = com.orientechnologies.orient.core.metadata.schema::OProperty::INDEX_TYPE
4
+
5
+ #INDEX_TYPES = %w{ FULLTEXT NOTUNIQUE UNIQUE }.inject({}) { |h, s| h[s.downcase.to_sym] = IndexType.const_get s; h }
6
+
7
+ end
data/lib/orientdb.rb CHANGED
@@ -1,25 +1,19 @@
1
1
  raise "OrieentDB-client only runs on JRuby. Sorry!" unless (RUBY_PLATFORM =~ /java/)
2
2
 
3
- $: << File.dirname(__FILE__)
4
- $: << File.expand_path('../../jars/', __FILE__)
5
-
6
- require 'java'
7
- require "orientdb-client-1.0rc7"
8
-
9
3
  module OrientDB
4
+ GEM_PATH = File.dirname File.expand_path(__FILE__) unless const_defined?(:GEM_PATH)
5
+ end
10
6
 
11
- def self.const_missing(missing)
12
- puts "[#{name}:const_missing] #{missing}"
13
- super
14
- end
7
+ $: << OrientDB::GEM_PATH
8
+ $: << File.join(OrientDB::GEM_PATH, 'jars')
15
9
 
16
- end
10
+ require 'java'
11
+ require "orientdb-client-1.0rc7"
17
12
 
13
+ require 'orientdb/version'
18
14
  require 'orientdb/ext'
19
15
  require 'orientdb/rid'
20
16
  require 'orientdb/constants'
21
- require 'orientdb/version'
22
- require 'orientdb/user'
23
17
  require 'orientdb/property'
24
18
  require 'orientdb/schema'
25
19
  require 'orientdb/storage'
@@ -5,26 +5,24 @@ module OrientDB
5
5
  DocumentDatabasePool = com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool
6
6
  DocumentDatabasePooled = com.orientechnologies.orient.core.db.document.ODatabaseDocumentTxPooled
7
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
8
+ OClassImpl = com.orientechnologies.orient.core.metadata.schema.OClassImpl
10
9
  LocalStorage = com.orientechnologies.orient.core.storage.impl.local.OStorageLocal
11
10
  LocalCluster = com.orientechnologies.orient.core.storage.impl.local.OClusterLocal
12
11
  LogicalCluster = com.orientechnologies.orient.core.storage.impl.local.OClusterLogical
13
- Property = com.orientechnologies.orient.core.metadata.schema.OProperty
12
+ PropertyImpl = com.orientechnologies.orient.core.metadata.schema.OPropertyImpl
14
13
  RecordList = com.orientechnologies.orient.core.db.record.ORecordTrackedList
15
- RecordMap = com.orientechnologies.orient.core.db.record.ORecordTrackedMap
16
14
  RecordSet = com.orientechnologies.orient.core.db.record.ORecordTrackedSet
17
15
  RemoteStorage = com.orientechnologies.orient.client.remote.OStorageRemote
18
16
  Schema = com.orientechnologies.orient.core.metadata.schema.OSchema
17
+ SchemaProxy = com.orientechnologies.orient.core.metadata.schema.OSchemaProxy
19
18
  SchemaType = com.orientechnologies.orient.core.metadata.schema.OType
20
- SQLSynchQuery = com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
21
19
  SQLCommand = com.orientechnologies.orient.core.sql.OCommandSQL
20
+ SQLSynchQuery = com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
22
21
  User = com.orientechnologies.orient.core.metadata.security.OUser
23
22
 
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 }
23
+ STORAGE_TYPES = %w{ LOGICAL MEMORY PHYSICAL }.inject({ }) { |h, s| h[s.downcase.to_sym] = ClusterType.const_get s; h }
26
24
 
27
- FIELD_TYPES = {
25
+ FIELD_TYPES = {
28
26
  :binary => "BINARY",
29
27
  :bool => "BOOLEAN",
30
28
  :boolean => "BOOLEAN",
@@ -50,7 +48,7 @@ module OrientDB
50
48
  :long => "LONG",
51
49
  :short => "SHORT",
52
50
  :string => "STRING",
53
- }.inject({}) do |h, (k, v)|
51
+ }.inject({ }) do |h, (k, v)|
54
52
  h[k] = SchemaType.const_get v
55
53
  h
56
54
  end
@@ -59,7 +59,7 @@ module OrientDB
59
59
  end
60
60
 
61
61
  def create_class(klass_name, fields = {})
62
- OrientDB::OClass.create self, klass_name.to_s, fields
62
+ OrientDB::OClassImpl.create self, klass_name.to_s, fields
63
63
  end
64
64
 
65
65
  def get_or_create_class(klass_name, fields = {})
@@ -1,6 +1,6 @@
1
1
  module OrientDB
2
2
 
3
- class OClass
3
+ class OClassImpl
4
4
 
5
5
  def type_for(value)
6
6
  self.class.type_for value
@@ -19,7 +19,7 @@ module OrientDB
19
19
  prop = create_property property_name, type
20
20
  when Symbol
21
21
  prop = create_property property_name, type_for(type)
22
- when OClass
22
+ when OClassImpl
23
23
  prop = create_property property_name, type_for(:link), type
24
24
  when Array
25
25
  type, sub_type = type_for(type.first), type_for(type.last)
@@ -32,10 +32,10 @@ module OrientDB
32
32
  prop.set_max options[:max].to_s unless options[:max].nil?
33
33
  prop.set_mandatory !!options[:mandatory] unless options[:mandatory].nil?
34
34
  prop.set_not_null options[:not_null] unless options[:not_null].nil?
35
- unless options[:index].nil?
36
- index_type = options[:index] == true ? INDEX_TYPES[:notunique] : INDEX_TYPES[options[:index]]
37
- prop.createIndex index_type
38
- end
35
+ #unless options[:index].nil?
36
+ # index_type = options[:index] == true ? INDEX_TYPES[:notunique] : INDEX_TYPES[options[:index]]
37
+ # prop.createIndex index_type
38
+ #end
39
39
 
40
40
  self
41
41
  end
@@ -55,7 +55,7 @@ module OrientDB
55
55
 
56
56
  def inspect
57
57
  props = properties.map { |x| "#{x.name}=#{x.type.name}#{x.is_indexed? ? '(idx)' : ''}" }.join(' ')
58
- "#<OrientDB::OClass:" + name +
58
+ "#<OrientDB::OClassImpl:" + name +
59
59
  (getSuperClass ? ' super=' + getSuperClass.name : '') +
60
60
  (props.empty? ? '' : ' ' + props) +
61
61
  ">"
@@ -68,7 +68,7 @@ module OrientDB
68
68
  def type_for(value)
69
69
  value = value.oclass if value.respond_to?(:oclass)
70
70
  type = case value
71
- when OrientDB::SchemaType, OrientDB::OClass
71
+ when OrientDB::SchemaType, OrientDB::OClassImpl
72
72
  value
73
73
  when String
74
74
  if schema.exists_class?(value)
@@ -105,14 +105,14 @@ module OrientDB
105
105
  end
106
106
 
107
107
  super_klass = fields.delete :super
108
- super_klass = db.get_class(super_klass.to_s) unless super_klass.is_a?(OrientDB::OClass)
108
+ super_klass = db.get_class(super_klass.to_s) unless super_klass.is_a?(OrientDB::OClassImpl)
109
109
  klass.set_super_class super_klass if super_klass
110
110
  db.schema.save
111
111
 
112
112
  unless fields.empty?
113
113
  fields.each do |property_name, type|
114
114
  case type
115
- when Symbol, Array, OrientDB::OClass
115
+ when Symbol, Array, OrientDB::OClassImpl
116
116
  klass.add property_name, type
117
117
  when Hash
118
118
  options = type.dup
@@ -1,6 +1,5 @@
1
1
  module OrientDB
2
-
3
- class Property
2
+ class PropertyImpl
4
3
 
5
4
  def type_short
6
5
  @type_short ||= OrientDB::FIELD_TYPES.select { |k, v| v.name == getType.name }.first.first
@@ -35,5 +34,4 @@ module OrientDB
35
34
  alias :to_s :inspect
36
35
 
37
36
  end
38
-
39
37
  end
@@ -8,14 +8,6 @@ module OrientDB
8
8
  alias :to_s :inspect
9
9
  end
10
10
 
11
- class RecordMap
12
- def inspect
13
- "#<OrientDB::RecordMap:#{toString}>"
14
- end
15
-
16
- alias :to_s :inspect
17
- end
18
-
19
11
  class RecordSet
20
12
  def inspect
21
13
  "#<OrientDB::RecordSet:#{toString}>"
data/lib/orientdb/rid.rb CHANGED
@@ -2,13 +2,13 @@ class OrientDB::RID
2
2
 
3
3
  attr_reader :cluster_id, :document_id
4
4
 
5
- def initialize(rid_str = '-1:-1')
6
- idx = rid_str.index(':')
7
- if idx
8
- self.cluster_id = rid_str[0, idx]
9
- self.document_id = rid_str[idx+1..-1]
5
+ def initialize(rid = '#-1:-1')
6
+ parts = rid.to_s.gsub('#', '').split ":"
7
+ if parts.size == 2
8
+ self.cluster_id = parts.first.to_i
9
+ self.document_id = parts.last.to_i
10
10
  else
11
- raise "Unknown parameters #{args.inspect}"
11
+ raise "Unknown rid [#{rid}]"
12
12
  end
13
13
  end
14
14
 
@@ -21,11 +21,13 @@ class OrientDB::RID
21
21
  end
22
22
 
23
23
  def inspect
24
- "#{cluster_id}:#{@document_id}"
24
+ "##{cluster_id}:#{@document_id}"
25
25
  end
26
26
 
27
+ alias :to_s :inspect
28
+
27
29
  def unsaved?
28
- to_s == '-1:-1'
30
+ to_s == '#-1:-1'
29
31
  end
30
32
 
31
33
  def saved?
@@ -35,8 +37,6 @@ class OrientDB::RID
35
37
  def valid?
36
38
  saved? || unsaved?
37
39
  end
38
-
39
- alias :to_s :inspect
40
40
  end
41
41
 
42
42
  class String
@@ -1,23 +1,33 @@
1
1
  module OrientDB
2
2
 
3
- class Schema
4
-
5
- def inspect
6
- "#<OrientDB::Schema:#{toString}>"
7
- end
8
-
9
- alias :to_s :inspect
10
-
11
- end
12
-
13
- class SchemaType
14
-
15
- def inspect
16
- "#<OrientDB::SchemaType:#{name}>"
17
- end
18
-
19
- alias :to_s :inspect
20
-
21
- end
3
+ #class Schema
4
+ #
5
+ # def inspect
6
+ # "#<OrientDB::Schema:#{toString}>"
7
+ # end
8
+ #
9
+ # alias :to_s :inspect
10
+ #
11
+ #end
12
+ #
13
+ #class SchemaProxy
14
+ #
15
+ # def inspect
16
+ # "#<OrientDB::SchemaProxy:#{toString}>"
17
+ # end
18
+ #
19
+ # alias :to_s :inspect
20
+ #
21
+ #end
22
+ #
23
+ #class SchemaType
24
+ #
25
+ # def inspect
26
+ # "#<OrientDB::SchemaType:#{name}>"
27
+ # end
28
+ #
29
+ # alias :to_s :inspect
30
+ #
31
+ #end
22
32
 
23
33
  end
@@ -1,3 +1,3 @@
1
1
  module OrientDB
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.19"
3
3
  end
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.17"
8
+ s.version = "0.0.19"
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 = [%q{Adrian Madrid}]
13
- s.date = %q{2011-12-09}
13
+ s.date = %q{2011-12-10}
14
14
  s.description = %q{Simple JRuby wrapper for the OrientDB.}
15
15
  s.email = [%q{aemadrid@gmail.com}]
16
16
  s.executables = [%q{orientdb_console}]
@@ -27,13 +27,14 @@ Gem::Specification.new do |s|
27
27
  "Rakefile",
28
28
  "VERSION",
29
29
  "bin/orientdb_console",
30
- "jars/orient-commons-1.0rc7.jar",
31
- "jars/orientdb-client-1.0rc7.jar",
32
- "jars/orientdb-core-1.0rc7.jar",
33
- "jars/orientdb-enterprise-1.0rc7.jar",
34
- "jars/orientdb-server-1.0rc7.jar",
35
- "jars/orientdb-tools-1.0rc7.jar",
36
- "jars/persistence-api-1.0.jar",
30
+ "lib/jars/orient-commons-1.0rc7.jar",
31
+ "lib/jars/orientdb-client-1.0rc7.jar",
32
+ "lib/jars/orientdb-core-1.0rc7.jar",
33
+ "lib/jars/orientdb-enterprise-1.0rc7.jar",
34
+ "lib/jars/orientdb-server-1.0rc7.jar",
35
+ "lib/jars/orientdb-tools-1.0rc7.jar",
36
+ "lib/jars/persistence-api-1.0.jar",
37
+ "lib/old/constants.rb",
37
38
  "lib/orientdb.rb",
38
39
  "lib/orientdb/constants.rb",
39
40
  "lib/orientdb/database.rb",
@@ -52,7 +53,6 @@ Gem::Specification.new do |s|
52
53
  "lib/orientdb/sql/query.rb",
53
54
  "lib/orientdb/sql/update.rb",
54
55
  "lib/orientdb/storage.rb",
55
- "lib/orientdb/user.rb",
56
56
  "lib/orientdb/version.rb",
57
57
  "orientdb.gemspec",
58
58
  "spec/database_spec.rb",
@@ -9,14 +9,14 @@ describe "OrientDB" do
9
9
  end
10
10
 
11
11
  it "should create a valid simple table" do
12
- exp_class = "#<OrientDB::OClass:person name=STRING>"
12
+ exp_class = "#<OrientDB::OClassImpl:person name=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=FLOAT name=STRING>"
19
+ exp_class = "#<OrientDB::OClassImpl:customer super=person tab=FLOAT name=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,12 +26,12 @@ describe "OrientDB" do
26
26
  end
27
27
 
28
28
  it "should create a complex table" do
29
- exp_class = "#<OrientDB::OClass:invoice total=FLOAT sold_on=DATE lines=LINKLIST number=INTEGER(idx) customer=LINK>"
29
+ exp_class = "#<OrientDB::OClassImpl:invoice total=FLOAT sold_on=DATE lines=LINKLIST number=INTEGER customer=LINK>"
30
30
  exp_props = [
31
31
  "#<OrientDB::Propery:total type=decimal indexed=false mandatory=false not_null=false>",
32
32
  "#<OrientDB::Propery:sold_on type=date indexed=false mandatory=false not_null=false>",
33
33
  "#<OrientDB::Propery:lines type=link_list indexed=false mandatory=false not_null=false>",
34
- "#<OrientDB::Propery:number type=int indexed=true mandatory=true not_null=false>",
34
+ "#<OrientDB::Propery:number type=int indexed=false mandatory=true not_null=false>",
35
35
  "#<OrientDB::Propery:customer type=link indexed=false mandatory=false not_null=true>"
36
36
  ]
37
37
  @invoice_class.to_s.should == exp_class
@@ -92,7 +92,7 @@ describe "OrientDB" do
92
92
  # @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>"
93
93
  @invoice.customer.should == @customer
94
94
  @invoice.total = @total
95
- @invoice.lines.should == [@line1, @line2]
95
+ @invoice.lines.map{|x| x}.should == [@line1, @line2]
96
96
  end
97
97
  end
98
98
 
data/spec/spec_helper.rb CHANGED
@@ -33,34 +33,35 @@ unless defined?(SPEC_HELPER_LOADED)
33
33
 
34
34
  module Helpers
35
35
  def create_classes
36
- # People
37
36
  @person_class = DB.recreate_class :person, :name => :string
38
- # Customers
39
37
  @customer_class = DB.recreate_class :customer,
40
38
  :super => @person_class,
41
39
  :tab => :float
42
- # Employees
43
40
  @employee_class = DB.recreate_class :employee,
44
41
  :super => @person_class,
45
42
  :age => :int,
46
43
  :groups => [:embedded_list, :string]
47
- # Products
48
44
  @product_class = DB.recreate_class :product,
49
45
  :sku => :string,
50
46
  :title => :string,
51
47
  :price => :float
52
- # Invoice Lines
53
48
  @line_class = DB.recreate_class :invoice_line,
54
49
  :product => @product_class,
55
50
  :quantity => :int,
56
51
  :price => :float
57
- # Invoices
58
52
  @invoice_class = DB.recreate_class :invoice,
59
53
  :number => {:type => :int, :mandatory => true, :index => true},
60
54
  :customer => {:type => @customer_class, :not_null => true},
61
55
  :sold_on => :date,
62
56
  :total => {:type => :float}, # , :min => java.lang.Float.new('0.01'), :max => java.lang.Float.new('1000.0')
63
57
  :lines => [:link_list, @line_class]
58
+
59
+ #@person_class = DB.recreate_class :person
60
+ #@customer_class = DB.recreate_class :customer
61
+ #@employee_class = DB.recreate_class :employee
62
+ #@product_class = DB.recreate_class :product
63
+ #@line_class = DB.recreate_class :invoice_line
64
+ #@invoice_class = DB.recreate_class :invoice
64
65
  end
65
66
  end
66
67
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: orientdb
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.17
5
+ version: 0.0.19
6
6
  platform: jruby
7
7
  authors:
8
8
  - Adrian Madrid
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-09 00:00:00 Z
13
+ date: 2011-12-10 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: awesome_print
@@ -53,13 +53,14 @@ files:
53
53
  - Rakefile
54
54
  - VERSION
55
55
  - bin/orientdb_console
56
- - jars/orient-commons-1.0rc7.jar
57
- - jars/orientdb-client-1.0rc7.jar
58
- - jars/orientdb-core-1.0rc7.jar
59
- - jars/orientdb-enterprise-1.0rc7.jar
60
- - jars/orientdb-server-1.0rc7.jar
61
- - jars/orientdb-tools-1.0rc7.jar
62
- - jars/persistence-api-1.0.jar
56
+ - lib/jars/orient-commons-1.0rc7.jar
57
+ - lib/jars/orientdb-client-1.0rc7.jar
58
+ - lib/jars/orientdb-core-1.0rc7.jar
59
+ - lib/jars/orientdb-enterprise-1.0rc7.jar
60
+ - lib/jars/orientdb-server-1.0rc7.jar
61
+ - lib/jars/orientdb-tools-1.0rc7.jar
62
+ - lib/jars/persistence-api-1.0.jar
63
+ - lib/old/constants.rb
63
64
  - lib/orientdb.rb
64
65
  - lib/orientdb/constants.rb
65
66
  - lib/orientdb/database.rb
@@ -78,7 +79,6 @@ files:
78
79
  - lib/orientdb/sql/query.rb
79
80
  - lib/orientdb/sql/update.rb
80
81
  - lib/orientdb/storage.rb
81
- - lib/orientdb/user.rb
82
82
  - lib/orientdb/version.rb
83
83
  - orientdb.gemspec
84
84
  - spec/database_spec.rb
data/lib/orientdb/user.rb DELETED
@@ -1,3 +0,0 @@
1
- module OrientDB
2
-
3
- end