orientdb 0.0.6-jruby → 0.0.7-jruby
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/orientdb/constants.rb +3 -0
- data/lib/orientdb/document.rb +13 -1
- data/lib/orientdb/oclass.rb +35 -22
- data/orientdb.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/orientdb/constants.rb
CHANGED
@@ -27,8 +27,11 @@ module OrientDB
|
|
27
27
|
:double => "DOUBLE",
|
28
28
|
:embedded => "EMBEDDED",
|
29
29
|
:embedded_list => "EMBEDDEDLIST",
|
30
|
+
:list => "EMBEDDEDLIST",
|
30
31
|
:embedded_map => "EMBEDDEDMAP",
|
32
|
+
:map => "EMBEDDEDMAP",
|
31
33
|
:embedded_set => "EMBEDDEDSET",
|
34
|
+
:set => "EMBEDDEDSET",
|
32
35
|
:float => "FLOAT",
|
33
36
|
:int => "INTEGER",
|
34
37
|
:integer => "INTEGER",
|
data/lib/orientdb/document.rb
CHANGED
@@ -16,6 +16,18 @@ module OrientDB
|
|
16
16
|
field field_name.to_s, value
|
17
17
|
end
|
18
18
|
|
19
|
+
def field?(name)
|
20
|
+
contains_field(name.to_s) || schema_class.exists_property?(name.to_s)
|
21
|
+
end
|
22
|
+
|
23
|
+
def respond_to?(method_name)
|
24
|
+
return true if field?(method_name.to_s)
|
25
|
+
match = method_name.to_s.match(/(.*?)([?=!]?)$/)
|
26
|
+
return true if match[2] == '='
|
27
|
+
return true if match[2] == '?' && field?(match[1])
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
19
31
|
def method_missing(method_name, *args, &blk)
|
20
32
|
return self[method_name] if contains_field(method_name.to_s)
|
21
33
|
return nil if schema_class.exists_property?(method_name.to_s)
|
@@ -25,7 +37,7 @@ module OrientDB
|
|
25
37
|
when "="
|
26
38
|
self[match[1]] = args.first
|
27
39
|
when "?"
|
28
|
-
!!self[match[1]]
|
40
|
+
field(match[1]) ? !!self[match[1]] : super
|
29
41
|
else
|
30
42
|
super
|
31
43
|
end
|
data/lib/orientdb/oclass.rb
CHANGED
@@ -2,7 +2,25 @@ module OrientDB
|
|
2
2
|
|
3
3
|
class OClass
|
4
4
|
|
5
|
-
def
|
5
|
+
def type_for(value)
|
6
|
+
type = case value
|
7
|
+
when SchemaType
|
8
|
+
value
|
9
|
+
when Symbol
|
10
|
+
FIELD_TYPES[value]
|
11
|
+
else
|
12
|
+
FIELD_TYPES[value.to_s.to_sym]
|
13
|
+
end
|
14
|
+
raise "Uknown schema type for [#{value}]" unless type
|
15
|
+
type
|
16
|
+
end
|
17
|
+
|
18
|
+
def add(property_name, type, options = {})
|
19
|
+
if type.is_a?(Hash)
|
20
|
+
real_type = type.delete(:type)
|
21
|
+
return add(property_name, real_type, type)
|
22
|
+
end
|
23
|
+
|
6
24
|
property_name = property_name.to_s
|
7
25
|
if exists_property(property_name)
|
8
26
|
puts "We already have that property name [#{property_name}]"
|
@@ -11,31 +29,26 @@ module OrientDB
|
|
11
29
|
|
12
30
|
case type
|
13
31
|
when Symbol
|
14
|
-
create_property property_name,
|
32
|
+
prop = create_property property_name, type_for(type)
|
15
33
|
when OrientDB::OClass
|
16
|
-
create_property property_name,
|
34
|
+
prop = create_property property_name, type_for(:link), type
|
17
35
|
when Array
|
18
|
-
type[0] =
|
19
|
-
type[1] =
|
20
|
-
create_property property_name, *type
|
21
|
-
when Hash
|
22
|
-
raise "Missing property type for [#{property_name}]" unless type[:type]
|
23
|
-
if type[:type].is_a?(OrientDB::OClass)
|
24
|
-
prop = create_property property_name, FIELD_TYPES[:link], type[:type]
|
25
|
-
else
|
26
|
-
prop = create_property property_name, FIELD_TYPES[type[:type]]
|
27
|
-
end
|
28
|
-
prop.set_min type[:min].to_s unless type[:min].nil?
|
29
|
-
prop.set_max type[:max].to_s unless type[:max].nil?
|
30
|
-
prop.set_mandatory !!type[:mandatory] unless type[:mandatory].nil?
|
31
|
-
prop.set_not_null type[:not_null] unless type[:not_null].nil?
|
32
|
-
unless type[:index].nil?
|
33
|
-
index_type = type[:index] == true ? INDEX_TYPES[:notunique] : INDEX_TYPES[type[:index]]
|
34
|
-
prop.createIndex index_type
|
35
|
-
end
|
36
|
+
type[0] = type_for(type[0]) if type[0].is_a?(Symbol)
|
37
|
+
type[1] = type_for(type[1]) if type[1].is_a?(Symbol)
|
38
|
+
prop = create_property property_name, *type
|
36
39
|
else
|
37
|
-
|
40
|
+
raise "ERROR! Unknown type [ #{property_name} | #{type} : #{type.class.name} ]"
|
38
41
|
end
|
42
|
+
|
43
|
+
prop.set_min options[:min].to_s unless options[:min].nil?
|
44
|
+
prop.set_max options[:max].to_s unless options[:max].nil?
|
45
|
+
prop.set_mandatory !!options[:mandatory] unless options[:mandatory].nil?
|
46
|
+
prop.set_not_null options[:not_null] unless options[:not_null].nil?
|
47
|
+
unless options[:index].nil?
|
48
|
+
index_type = options[:index] == true ? INDEX_TYPES[:notunique] : INDEX_TYPES[options[:index]]
|
49
|
+
prop.createIndex index_type
|
50
|
+
end
|
51
|
+
|
39
52
|
self
|
40
53
|
end
|
41
54
|
|
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.7"
|
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-13}
|
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"]
|
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
|
+
- 7
|
9
|
+
version: 0.0.7
|
10
10
|
platform: jruby
|
11
11
|
authors:
|
12
12
|
- Adrian Madrid
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-13 00:00:00 -07:00
|
18
18
|
default_executable: orientdb_console
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|