diametric 0.1.1-java → 0.1.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +627 -179
- data/ext/diametric/DiametricCollection.java +696 -66
- data/ext/diametric/DiametricCommon.java +165 -0
- data/ext/diametric/DiametricDatabase.java +10 -3
- data/ext/diametric/DiametricPeer.java +12 -4
- data/ext/diametric/DiametricService.java +35 -2
- data/ext/diametric/DiametricSet.java +270 -0
- data/ext/diametric/DiametricUtils.java +52 -10
- data/lib/diametric/entity.rb +7 -5
- data/lib/diametric/persistence/common.rb +3 -3
- data/lib/diametric/persistence/peer.rb +3 -12
- data/lib/diametric/persistence/rest.rb +1 -1
- data/lib/diametric/query.rb +26 -14
- data/lib/diametric/version.rb +1 -1
- data/lib/diametric_service.jar +0 -0
- data/spec/developer_query_spec.rb +3 -3
- data/spec/diametric/peer_api_spec.rb +425 -8
- data/spec/diametric/persistence/peer_many2many_spec.rb +10 -9
- data/spec/parent_child_sample.rb +21 -16
- data/spec/peer_integration_spec.rb +43 -9
- data/spec/support/entities.rb +2 -0
- metadata +24 -22
@@ -21,7 +21,7 @@ describe Diametric::Persistence::Peer, :jruby do
|
|
21
21
|
author.update(:books => [book])
|
22
22
|
result = Diametric::Persistence::Peer.q("[:find ?e ?name ?books :in $ :where [?e :author/name ?name] [?e :author/books ?books]]", @conn.db)
|
23
23
|
boo_dbid = result.first[2]
|
24
|
-
boo = Author.
|
24
|
+
boo = Author.reify(boo_dbid, @conn)
|
25
25
|
boo.title.should == "Candy"
|
26
26
|
end
|
27
27
|
|
@@ -35,11 +35,12 @@ describe Diametric::Persistence::Peer, :jruby do
|
|
35
35
|
author.update(:books => [book1, book2])
|
36
36
|
result = Diametric::Persistence::Peer.q("[:find ?e ?name ?books :in $ :where [?e :author/name ?name] [?e :author/books ?books]]", @conn.db)
|
37
37
|
result.size.should == 2
|
38
|
-
|
39
|
-
|
38
|
+
result_in_array = result.to_a
|
39
|
+
boo_dbid = result_in_array[0][2]
|
40
|
+
boo = Book.reify(boo_dbid, @conn)
|
40
41
|
boo.title.should match(/Honey|Chips/)
|
41
|
-
foo_dbid =
|
42
|
-
foo = Book.
|
42
|
+
foo_dbid = result_in_array[1][2]
|
43
|
+
foo = Book.reify(boo_dbid, @conn)
|
43
44
|
foo.title.should match(/Honey|Chips/)
|
44
45
|
end
|
45
46
|
|
@@ -58,19 +59,19 @@ describe Diametric::Persistence::Peer, :jruby do
|
|
58
59
|
result = Diametric::Persistence::Peer.q("[:find ?e :in $ [?name] :where [?e :author/name ?name]]", @conn.db, ["Ms. Wilber"])
|
59
60
|
result.size.should == 1
|
60
61
|
result.first.first.to_s.should == author1.dbid.to_s
|
61
|
-
a = Author.
|
62
|
+
a = Author.reify(result.first.first, @conn)
|
62
63
|
a.books.size.should == 2
|
63
64
|
a.books.each do |b|
|
64
|
-
Author.
|
65
|
+
Author.reify(b, @conn).title.should match(/Pie|Donuts/)
|
65
66
|
end
|
66
67
|
|
67
68
|
result = Diametric::Persistence::Peer.q("[:find ?e :in $ [?title] :where [?e :book/title ?title]]", @conn.db, ["Pie"])
|
68
69
|
result.size.should == 1
|
69
70
|
result.first.first.to_s.should == book1.dbid.to_s
|
70
|
-
b = Book.
|
71
|
+
b = Book.reify(result.first.first, @conn)
|
71
72
|
b.authors.size.should == 2
|
72
73
|
b.authors.each do |a|
|
73
|
-
Book.
|
74
|
+
Book.reify(a, @conn).name.should match(/Ms\.\sWilber|Mr\.\sSmith/)
|
74
75
|
end
|
75
76
|
end
|
76
77
|
end
|
data/spec/parent_child_sample.rb
CHANGED
@@ -5,7 +5,9 @@ class Somebody
|
|
5
5
|
include Diametric::Persistence::Peer
|
6
6
|
|
7
7
|
attribute :name, String
|
8
|
-
attribute :
|
8
|
+
attribute :mom, Ref, :cardinality => :one
|
9
|
+
attribute :dad, Ref, :cardinality => :one
|
10
|
+
attribute :kids, Ref, :cardinality => :many
|
9
11
|
end
|
10
12
|
|
11
13
|
describe "RailsConf 2013", :jruby => true do
|
@@ -13,30 +15,33 @@ describe "RailsConf 2013", :jruby => true do
|
|
13
15
|
before(:all) do
|
14
16
|
datomic_uri = "datomic:mem://somebody-#{SecureRandom.uuid}"
|
15
17
|
@conn = Diametric::Persistence::Peer.connect(datomic_uri)
|
18
|
+
Somebody.create_schema(@conn).get
|
16
19
|
end
|
20
|
+
|
17
21
|
after(:all) do
|
18
22
|
@conn.release
|
19
23
|
end
|
20
24
|
|
21
|
-
it "should create schema" do
|
22
|
-
binding.pry
|
23
|
-
Sombody.create_schema(@conn)
|
24
|
-
end
|
25
|
-
|
26
25
|
it "should create instances" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
mom = Somebody.new(name: "Snow White")
|
27
|
+
mom.save(@conn)
|
28
|
+
dad = Somebody.new(name: "Prince Brave")
|
29
|
+
dad.save(@conn)
|
31
30
|
binding.pry
|
32
|
-
|
33
|
-
clinton = Developer.new(:name => "Clinton N. Dreisbach", :friends => [yoko])
|
34
|
-
clinton.save
|
31
|
+
Somebody.new(name: "Alice Wonderland", mom: mom, dad: dad).save(@conn)
|
35
32
|
binding.pry
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
me = Diametric::Query.new(Somebody, @conn, true).where(name: "Alice Wonderland").first
|
34
|
+
binding.pry
|
35
|
+
puts "me: #{me.name}, me's mom: #{me.mom.name}, me's dad: #{me.dad.name}"
|
36
|
+
mario = Somebody.new(name: "Mario", mom: me)
|
37
|
+
mario.save
|
38
|
+
luigi = Somebody.new(name: "Luigi", mom: me)
|
39
|
+
luigi.save
|
40
|
+
me.update_attributes(kids: [mario, luigi])
|
41
|
+
me = Diametric::Query.new(Somebody, @conn, true).where(name: "Alice Wonderland").first
|
42
|
+
puts me.kids.inspect
|
39
43
|
binding.pry
|
44
|
+
puts Somebody.reify(me.kids.first.mom).name
|
40
45
|
end
|
41
46
|
end
|
42
47
|
end
|
@@ -18,28 +18,62 @@ describe Diametric::Entity, :integration => true, :jruby => true do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:query) { Diametric::Query.new(Penguin, @conn, true) }
|
21
|
+
|
21
22
|
it "should update entity" do
|
22
|
-
|
23
|
+
bday = DateTime.parse('2005-01-01')
|
24
|
+
penguin = Penguin.new(:name => "Mary", :age => 2, :birthday => bday)
|
23
25
|
penguin.save(@conn)
|
24
26
|
penguin.update(:age => 3)
|
25
27
|
penguin.name.should == "Mary"
|
26
28
|
penguin.age.should == 3
|
29
|
+
penguin.birthday.should == bday
|
27
30
|
end
|
28
31
|
|
29
32
|
it "should search upadated attributes" do
|
30
|
-
|
31
|
-
penguin.name
|
32
|
-
penguin.
|
33
|
+
bday = DateTime.parse('1900-02-02')
|
34
|
+
penguin = Penguin.new(:name => "Mary J.", :age => 200, :birthday => bday)
|
35
|
+
penguin.save(@conn)
|
36
|
+
penguin = query.where(:name => "Mary J.").first
|
37
|
+
penguin.name.should == "Mary J."
|
38
|
+
penguin.age.should == 200
|
39
|
+
penguin.birthday == bday
|
33
40
|
end
|
34
41
|
|
35
42
|
it "should destroy entity" do
|
36
|
-
penguin = Penguin.new(:name => "Mary", :age => 2)
|
43
|
+
penguin = Penguin.new(:name => "Mary Jo.", :age => 2)
|
37
44
|
penguin.save(@conn)
|
38
45
|
number_of_penguins = Penguin.all.size
|
39
46
|
number_of_penguins.should >= 1
|
40
47
|
penguin.destroy
|
41
48
|
Penguin.all.size.should == (number_of_penguins -1)
|
42
49
|
end
|
50
|
+
|
51
|
+
it "should find by where query" do
|
52
|
+
Penguin.new(name: "Mary Jo.", birthday: DateTime.parse('1900-12-31')).save
|
53
|
+
Penguin.new(name: "Mary Jen.", birthday: DateTime.parse('1999-12-31')).save
|
54
|
+
Penguin.new(name: "Mary Jr.", birthday: DateTime.parse('2013-01-01')).save
|
55
|
+
Penguin.new(name: "Mary Jay.", birthday: DateTime.parse('2011-01-01')).save
|
56
|
+
query = Penguin.where(birthday: DateTime.parse('1999-12-31'))
|
57
|
+
query.each do |entity|
|
58
|
+
entity.birthday.should == DateTime.parse('1999-12-31')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should find by filter query" do
|
63
|
+
Penguin.new(name: "Mary Jo.", birthday: DateTime.parse('1890-12-31'), awesomeness: true).save
|
64
|
+
Penguin.new(name: "Mary Jen.", birthday: DateTime.parse('1999-12-31'), awesomeness: true).save
|
65
|
+
Penguin.new(name: "Mary Jr.", birthday: DateTime.parse('2013-01-01'), awesomeness: false).save
|
66
|
+
Penguin.new(name: "Mary Jay.", birthday: DateTime.parse('1850-02-22'), awesomeness: false).save
|
67
|
+
query = Penguin.filter(:<, :birthday, DateTime.parse('1900-01-01'))
|
68
|
+
result = query.all
|
69
|
+
result.size.should == 2
|
70
|
+
result.collect(&:name).should =~ ["Mary Jay.", "Mary Jo."]
|
71
|
+
|
72
|
+
query = Penguin.where(awesomeness: true).filter(:<, :birthday, DateTime.parse('1900-01-01'))
|
73
|
+
result = query.all
|
74
|
+
result.size.should == 1
|
75
|
+
result.first.name.should == "Mary Jo."
|
76
|
+
end
|
43
77
|
end
|
44
78
|
|
45
79
|
context Choice do
|
@@ -57,7 +91,7 @@ describe Diametric::Entity, :integration => true, :jruby => true do
|
|
57
91
|
choice = Choice.new(:item => "Boots", :checked => true)
|
58
92
|
choice.save.should_not be_nil
|
59
93
|
result = Diametric::Persistence::Peer.q("[:find ?e :in $ :where [?e :choice/checked]]", @conn2.db)
|
60
|
-
choice = Choice.
|
94
|
+
choice = Choice.reify(result.first.first, @conn2.db)
|
61
95
|
choice.checked.should be_true
|
62
96
|
end
|
63
97
|
end
|
@@ -78,7 +112,7 @@ describe Diametric::Entity, :integration => true, :jruby => true do
|
|
78
112
|
customer = Customer.new(:name => "John Smith", :id => id)
|
79
113
|
customer.save.should_not be_nil
|
80
114
|
result = Diametric::Persistence::Peer.q("[:find ?e :in $ :where [?e :customer/name]]", @conn3.db)
|
81
|
-
customer2 = Customer.
|
115
|
+
customer2 = Customer.reify(result.first.first, @conn3.db)
|
82
116
|
customer2.name.should == "John Smith"
|
83
117
|
customer2.id.to_s.should == id.to_s
|
84
118
|
end
|
@@ -89,7 +123,7 @@ describe Diametric::Entity, :integration => true, :jruby => true do
|
|
89
123
|
customer = Customer.new(:name => "Wilber Hoe", :id => id)
|
90
124
|
customer.save.should_not be_nil
|
91
125
|
result = Diametric::Persistence::Peer.q("[:find ?e :in $ [?name] :where [?e :customer/name ?name]]", @conn3.db, ["Wilber Hoe"])
|
92
|
-
customer2 = Customer.
|
126
|
+
customer2 = Customer.reify(result.first.first, @conn3.db)
|
93
127
|
customer2.name.should == "Wilber Hoe"
|
94
128
|
customer2.id.to_s.should == id.to_s
|
95
129
|
end
|
@@ -110,7 +144,7 @@ describe Diametric::Entity, :integration => true, :jruby => true do
|
|
110
144
|
account = Account.new(:name => "This month's deposits", :deposit => [100.0, 200.0], :amount => 0.0)
|
111
145
|
account.save.should_not be_nil
|
112
146
|
result = Diametric::Persistence::Peer.q("[:find ?e :in $ :where [?e :account/name]]", @conn4.db)
|
113
|
-
account2 = Customer.
|
147
|
+
account2 = Customer.reify(result.first.first, @conn4.db)
|
114
148
|
account2.name.should == account.name
|
115
149
|
account2.amount.should == 0.0
|
116
150
|
account2.deposit.should include(100.0)
|
data/spec/support/entities.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diametric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Clinton N. Dreisbach
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-11-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -18,140 +18,140 @@ dependencies:
|
|
18
18
|
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.0.2
|
21
|
-
name: edn
|
22
21
|
requirement: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - ~>
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: 1.0.2
|
27
|
-
type: :runtime
|
28
26
|
prerelease: false
|
27
|
+
type: :runtime
|
28
|
+
name: edn
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
version_requirements: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 3.2.14
|
35
|
-
name: activesupport
|
36
35
|
requirement: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - ~>
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: 3.2.14
|
41
|
-
type: :runtime
|
42
40
|
prerelease: false
|
41
|
+
type: :runtime
|
42
|
+
name: activesupport
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 3.2.14
|
49
|
-
name: activemodel
|
50
49
|
requirement: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - ~>
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: 3.2.14
|
55
|
-
type: :runtime
|
56
54
|
prerelease: false
|
55
|
+
type: :runtime
|
56
|
+
name: activemodel
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 0.4.1
|
63
|
-
name: datomic-client
|
64
63
|
requirement: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - ~>
|
67
66
|
- !ruby/object:Gem::Version
|
68
67
|
version: 0.4.1
|
69
|
-
type: :runtime
|
70
68
|
prerelease: false
|
69
|
+
type: :runtime
|
70
|
+
name: datomic-client
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 0.9.9
|
77
|
-
name: rubyzip
|
78
77
|
requirement: !ruby/object:Gem::Requirement
|
79
78
|
requirements:
|
80
79
|
- - ~>
|
81
80
|
- !ruby/object:Gem::Version
|
82
81
|
version: 0.9.9
|
83
|
-
type: :runtime
|
84
82
|
prerelease: false
|
83
|
+
type: :runtime
|
84
|
+
name: rubyzip
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 0.7.5
|
91
|
-
name: lock_jar
|
92
91
|
requirement: !ruby/object:Gem::Requirement
|
93
92
|
requirements:
|
94
93
|
- - ~>
|
95
94
|
- !ruby/object:Gem::Version
|
96
95
|
version: 0.7.5
|
97
|
-
type: :runtime
|
98
96
|
prerelease: false
|
97
|
+
type: :runtime
|
98
|
+
name: lock_jar
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ~>
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: 0.8.8
|
105
|
-
name: jruby-openssl
|
106
105
|
requirement: !ruby/object:Gem::Requirement
|
107
106
|
requirements:
|
108
107
|
- - ~>
|
109
108
|
- !ruby/object:Gem::Version
|
110
109
|
version: 0.8.8
|
111
|
-
type: :runtime
|
112
110
|
prerelease: false
|
111
|
+
type: :runtime
|
112
|
+
name: jruby-openssl
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ~>
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 2.3.7
|
119
|
-
name: uuid
|
120
119
|
requirement: !ruby/object:Gem::Requirement
|
121
120
|
requirements:
|
122
121
|
- - ~>
|
123
122
|
- !ruby/object:Gem::Version
|
124
123
|
version: 2.3.7
|
125
|
-
type: :runtime
|
126
124
|
prerelease: false
|
125
|
+
type: :runtime
|
126
|
+
name: uuid
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ~>
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 2.14.1
|
133
|
-
name: rspec
|
134
133
|
requirement: !ruby/object:Gem::Requirement
|
135
134
|
requirements:
|
136
135
|
- - ~>
|
137
136
|
- !ruby/object:Gem::Version
|
138
137
|
version: 2.14.1
|
139
|
-
type: :runtime
|
140
138
|
prerelease: false
|
139
|
+
type: :runtime
|
140
|
+
name: rspec
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - ~>
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: 0.9.1
|
147
|
-
name: rake-compiler
|
148
147
|
requirement: !ruby/object:Gem::Requirement
|
149
148
|
requirements:
|
150
149
|
- - ~>
|
151
150
|
- !ruby/object:Gem::Version
|
152
151
|
version: 0.9.1
|
153
|
-
type: :runtime
|
154
152
|
prerelease: false
|
153
|
+
type: :runtime
|
154
|
+
name: rake-compiler
|
155
155
|
description: |
|
156
156
|
Diametric is a library for building schemas, queries, and transactions
|
157
157
|
for Datomic from Ruby objects. It is also used to map Ruby objects
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- lib/tasks/create_schema.rb
|
197
197
|
- lib/tasks/diametric_config.rb
|
198
198
|
- ext/diametric/DiametricCollection.java
|
199
|
+
- ext/diametric/DiametricCommon.java
|
199
200
|
- ext/diametric/DiametricConnection.java
|
200
201
|
- ext/diametric/DiametricDatabase.java
|
201
202
|
- ext/diametric/DiametricEntity.java
|
@@ -203,6 +204,7 @@ files:
|
|
203
204
|
- ext/diametric/DiametricObject.java
|
204
205
|
- ext/diametric/DiametricPeer.java
|
205
206
|
- ext/diametric/DiametricService.java
|
207
|
+
- ext/diametric/DiametricSet.java
|
206
208
|
- ext/diametric/DiametricUtils.java
|
207
209
|
- ext/diametric/DiametricUUID.java
|
208
210
|
- spec/conf_helper.rb
|