orientdb-binary 0.6.0

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.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +64 -0
  7. data/lib/orientdb_binary.rb +25 -0
  8. data/lib/orientdb_binary/base.rb +40 -0
  9. data/lib/orientdb_binary/config.rb +5 -0
  10. data/lib/orientdb_binary/connection.rb +17 -0
  11. data/lib/orientdb_binary/database.rb +24 -0
  12. data/lib/orientdb_binary/database_operations/base_operations.rb +70 -0
  13. data/lib/orientdb_binary/database_operations/data_cluster.rb +116 -0
  14. data/lib/orientdb_binary/database_operations/data_segment.rb +31 -0
  15. data/lib/orientdb_binary/database_operations/query.rb +58 -0
  16. data/lib/orientdb_binary/database_operations/record.rb +105 -0
  17. data/lib/orientdb_binary/database_operations/transaction.rb +8 -0
  18. data/lib/orientdb_binary/operation_types.rb +51 -0
  19. data/lib/orientdb_binary/parser/deserializer.rb +161 -0
  20. data/lib/orientdb_binary/parser/serializer.rb +83 -0
  21. data/lib/orientdb_binary/protocols/base.rb +42 -0
  22. data/lib/orientdb_binary/protocols/bindata_primitives.rb +46 -0
  23. data/lib/orientdb_binary/protocols/command.rb +166 -0
  24. data/lib/orientdb_binary/protocols/config_get.rb +22 -0
  25. data/lib/orientdb_binary/protocols/config_list.rb +24 -0
  26. data/lib/orientdb_binary/protocols/config_set.rb +22 -0
  27. data/lib/orientdb_binary/protocols/connect.rb +26 -0
  28. data/lib/orientdb_binary/protocols/datacluster_add.rb +26 -0
  29. data/lib/orientdb_binary/protocols/datacluster_count.rb +26 -0
  30. data/lib/orientdb_binary/protocols/datacluster_datarange.rb +23 -0
  31. data/lib/orientdb_binary/protocols/datacluster_drop.rb +22 -0
  32. data/lib/orientdb_binary/protocols/datacluster_lh_cluster_is_used.rb +20 -0
  33. data/lib/orientdb_binary/protocols/datasegment_add.rb +24 -0
  34. data/lib/orientdb_binary/protocols/datasegment_drop.rb +23 -0
  35. data/lib/orientdb_binary/protocols/db_close.rb +16 -0
  36. data/lib/orientdb_binary/protocols/db_countrecords.rb +20 -0
  37. data/lib/orientdb_binary/protocols/db_create.rb +23 -0
  38. data/lib/orientdb_binary/protocols/db_drop.rb +22 -0
  39. data/lib/orientdb_binary/protocols/db_exist.rb +23 -0
  40. data/lib/orientdb_binary/protocols/db_freeze.rb +21 -0
  41. data/lib/orientdb_binary/protocols/db_list.rb +26 -0
  42. data/lib/orientdb_binary/protocols/db_open.rb +43 -0
  43. data/lib/orientdb_binary/protocols/db_release.rb +21 -0
  44. data/lib/orientdb_binary/protocols/db_reload.rb +26 -0
  45. data/lib/orientdb_binary/protocols/db_size.rb +20 -0
  46. data/lib/orientdb_binary/protocols/errors.rb +28 -0
  47. data/lib/orientdb_binary/protocols/record_create.rb +35 -0
  48. data/lib/orientdb_binary/protocols/record_delete.rb +25 -0
  49. data/lib/orientdb_binary/protocols/record_load.rb +65 -0
  50. data/lib/orientdb_binary/protocols/record_update.rb +27 -0
  51. data/lib/orientdb_binary/protocols/shutdown.rb +21 -0
  52. data/lib/orientdb_binary/server.rb +71 -0
  53. data/orientdb-binary.gemspec +26 -0
  54. data/test/database/test_database.rb +193 -0
  55. data/test/database/test_deserializer.rb +140 -0
  56. data/test/database/test_serializer.rb +55 -0
  57. data/test/server/test_server.rb +73 -0
  58. data/test/test_helper.rb +9 -0
  59. metadata +162 -0
@@ -0,0 +1,55 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+
4
+ describe OrientdbBinary::Parser do
5
+
6
+ describe 'Serializer' do
7
+ before do
8
+ @parser = OrientdbBinary::Parser::Serializer.new
9
+ end
10
+
11
+ describe "parsing sets" do
12
+ before do
13
+ @should_be = "doc_with_set@a_set:<\"one\",\"two\",3,#12:1>"
14
+ record = {
15
+ :@class => "doc_with_set",
16
+ a_set: Set.new(["one", "two", 3, "#12:1"])
17
+ }
18
+ @result = @parser.serialize_document(record)
19
+ end
20
+
21
+ it "should be set" do
22
+ assert_equal @result, @should_be
23
+ end
24
+ end
25
+
26
+ describe "parsing arrays" do
27
+ before do
28
+ @should_be = "doc_with_array@an_array:[\"one\",\"two\",3,#12:1]"
29
+ record = {
30
+ :@class => "doc_with_array",
31
+ an_array: ["one", "two", 3, "#12:1"]
32
+ }
33
+ @result = @parser.serialize_document(record)
34
+ end
35
+
36
+ it "should be array" do
37
+ assert_equal @result, @should_be
38
+ end
39
+ end
40
+
41
+ describe "parsing hashes" do
42
+ before do
43
+ @should_be = "a_hash:{one:1,two:\"two\"}"
44
+ record = {
45
+ a_hash: {one: 1, two: "two"}
46
+ }
47
+ @result = @parser.serialize_document(record)
48
+ end
49
+
50
+ it "should be hash" do
51
+ assert_equal @result, @should_be
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,73 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+
4
+ describe OrientdbBinary::Server do
5
+ before do
6
+ @server = OrientdbBinary::Server.new(TestHelper::SERVER)
7
+ @server.connect(TestHelper::SERVER_USER)
8
+ end
9
+
10
+ after do
11
+ @server.disconnect
12
+ end
13
+
14
+ describe "connection" do
15
+ it "should set session" do
16
+ assert @server.session > -1
17
+ end
18
+
19
+ it "should be connected" do
20
+ assert @server.connected?
21
+ end
22
+
23
+ it "should return socket" do
24
+ assert_instance_of TCPSocket, @server.socket
25
+ end
26
+ end
27
+
28
+ describe "configuration" do
29
+ it "should list configuration options" do
30
+ assert @server.config_list[:config_list].length > 0
31
+ end
32
+
33
+ it "should get configuration option" do
34
+ option = @server.config_list[:config_list].last
35
+ assert_equal @server.get_config(option[:option_key])[:option_value], option[:option_value]
36
+ end
37
+
38
+ it "should set configuration option" do
39
+ option = @server.config_list[:config_list].last
40
+ new_value = "15001"
41
+ @server.set_config(option[:option_key], new_value)
42
+ assert_equal @server.get_config(option[:option_key])[:option_value], new_value
43
+ # set it back
44
+ @server.set_config(option[:option_key], option[:option_value])
45
+ assert_equal @server.get_config(option[:option_key])[:option_value], option[:option_value]
46
+ end
47
+ end
48
+
49
+ describe "database" do
50
+ before do
51
+ if @server.db_exists? TestHelper::TEST_DB[:db]
52
+ @server.db_drop TestHelper::TEST_DB[:db], TestHelper::TEST_DB[:storage]
53
+ end
54
+ assert(!@server.db_exists?(TestHelper::TEST_DB[:db]))
55
+ end
56
+
57
+ after do
58
+ if @server.db_exists? TestHelper::TEST_DB[:db]
59
+ @server.db_drop TestHelper::TEST_DB[:db], TestHelper::TEST_DB[:storage]
60
+ end
61
+ assert(!@server.db_exists?(TestHelper::TEST_DB[:db]))
62
+ end
63
+
64
+ it "should create database" do
65
+ @server.db_create(TestHelper::TEST_DB[:db], 'document', TestHelper::TEST_DB[:storage])
66
+ assert @server.db_exists? TestHelper::TEST_DB[:db]
67
+ end
68
+
69
+ it "should list databases" do
70
+ assert @server.list[:databases].has_key?(:GratefulDeadConcerts)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,9 @@
1
+ module TestHelper
2
+
3
+ SERVER = { host: 'localhost', port: 2424 }
4
+ SERVER_USER = { user: 'root', password: 'root' }
5
+
6
+ TEST_DB = { db: 'ruby-orientdb-test-database-01', storage: "memory" }
7
+ TEST_DB_USER = { user: 'admin', password: 'admin' }
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orientdb-binary
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Michal Ostrowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bindata
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ description: Graph Database OrientDB native client for Ruby
70
+ email:
71
+ - ostrowski.michal@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/orientdb_binary.rb
82
+ - lib/orientdb_binary/base.rb
83
+ - lib/orientdb_binary/config.rb
84
+ - lib/orientdb_binary/connection.rb
85
+ - lib/orientdb_binary/database.rb
86
+ - lib/orientdb_binary/database_operations/base_operations.rb
87
+ - lib/orientdb_binary/database_operations/data_cluster.rb
88
+ - lib/orientdb_binary/database_operations/data_segment.rb
89
+ - lib/orientdb_binary/database_operations/query.rb
90
+ - lib/orientdb_binary/database_operations/record.rb
91
+ - lib/orientdb_binary/database_operations/transaction.rb
92
+ - lib/orientdb_binary/operation_types.rb
93
+ - lib/orientdb_binary/parser/deserializer.rb
94
+ - lib/orientdb_binary/parser/serializer.rb
95
+ - lib/orientdb_binary/protocols/base.rb
96
+ - lib/orientdb_binary/protocols/bindata_primitives.rb
97
+ - lib/orientdb_binary/protocols/command.rb
98
+ - lib/orientdb_binary/protocols/config_get.rb
99
+ - lib/orientdb_binary/protocols/config_list.rb
100
+ - lib/orientdb_binary/protocols/config_set.rb
101
+ - lib/orientdb_binary/protocols/connect.rb
102
+ - lib/orientdb_binary/protocols/datacluster_add.rb
103
+ - lib/orientdb_binary/protocols/datacluster_count.rb
104
+ - lib/orientdb_binary/protocols/datacluster_datarange.rb
105
+ - lib/orientdb_binary/protocols/datacluster_drop.rb
106
+ - lib/orientdb_binary/protocols/datacluster_lh_cluster_is_used.rb
107
+ - lib/orientdb_binary/protocols/datasegment_add.rb
108
+ - lib/orientdb_binary/protocols/datasegment_drop.rb
109
+ - lib/orientdb_binary/protocols/db_close.rb
110
+ - lib/orientdb_binary/protocols/db_countrecords.rb
111
+ - lib/orientdb_binary/protocols/db_create.rb
112
+ - lib/orientdb_binary/protocols/db_drop.rb
113
+ - lib/orientdb_binary/protocols/db_exist.rb
114
+ - lib/orientdb_binary/protocols/db_freeze.rb
115
+ - lib/orientdb_binary/protocols/db_list.rb
116
+ - lib/orientdb_binary/protocols/db_open.rb
117
+ - lib/orientdb_binary/protocols/db_release.rb
118
+ - lib/orientdb_binary/protocols/db_reload.rb
119
+ - lib/orientdb_binary/protocols/db_size.rb
120
+ - lib/orientdb_binary/protocols/errors.rb
121
+ - lib/orientdb_binary/protocols/record_create.rb
122
+ - lib/orientdb_binary/protocols/record_delete.rb
123
+ - lib/orientdb_binary/protocols/record_load.rb
124
+ - lib/orientdb_binary/protocols/record_update.rb
125
+ - lib/orientdb_binary/protocols/shutdown.rb
126
+ - lib/orientdb_binary/server.rb
127
+ - orientdb-binary.gemspec
128
+ - test/database/test_database.rb
129
+ - test/database/test_deserializer.rb
130
+ - test/database/test_serializer.rb
131
+ - test/server/test_server.rb
132
+ - test/test_helper.rb
133
+ homepage: http://orientdb-binary.espresse.net
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.2.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: OrientDB native client for Ruby 2
157
+ test_files:
158
+ - test/database/test_database.rb
159
+ - test/database/test_deserializer.rb
160
+ - test/database/test_serializer.rb
161
+ - test/server/test_server.rb
162
+ - test/test_helper.rb