active-orient 0.79 → 0.80

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.
@@ -0,0 +1,92 @@
1
+ module OrientSupport
2
+ class Query
3
+ include Support
4
+
5
+
6
+ # initialize with
7
+ # Query.new :s)elect, :t)raverse, :m)atch
8
+ # Query.new select: '', where: { a: 5 }
9
+ def initialize kind = ''
10
+ @kind = case kind.to_s[0]
11
+ when 's'
12
+ 'SELECT'
13
+ when 'm'
14
+ 'MATCH'
15
+ when 't'
16
+ 'TRAVERSE'
17
+ else
18
+ ''
19
+ end
20
+
21
+ end
22
+
23
+
24
+ def modify
25
+ c = @uri.clone
26
+ yield c
27
+ Iri.new(c)
28
+ end
29
+
30
+ def modify_query
31
+ modify do |c|
32
+ params = CGI.parse(@uri.query || '').map { |p, a| [p.to_s, a.clone] }.to_h
33
+ yield(params)
34
+ c.query = URI.encode_www_form(params)
35
+ end
36
+ end
37
+ end
38
+
39
+
40
+ def cut(path = '/')
41
+ modify do |c|
42
+ c.query = nil
43
+ c.path = path
44
+ c.fragment = nil
45
+ end
46
+ end
47
+
48
+
49
+ # Replace the query part of the URI.
50
+ def query(val)
51
+ modify do |c|
52
+ c.query = val
53
+ end
54
+ end
55
+
56
+ # Replace query argument(s).
57
+ #
58
+ # Iri.new('https://google.com?q=test').over(q: 'hey you!')
59
+ #
60
+ def over(hash)
61
+ modify_query do |params|
62
+ hash.each do |k, v|
63
+ params[k.to_s] = [] unless params[k]
64
+ params[k.to_s] = [v]
65
+ end
66
+ end
67
+ end
68
+
69
+
70
+ # Makes a new object.
71
+ #
72
+ # You can even ignore the argument, which will produce an empty URI.
73
+ def initialize(uri = '')
74
+ @uri = URI(uri)
75
+ end
76
+
77
+ # Convert it to a string.
78
+ def to_s
79
+ @uri.to_s
80
+ end
81
+
82
+ # Convert it to an object of class +URI+.
83
+ def to_uri
84
+ @uri.clone
85
+ end
86
+
87
+
88
+
89
+ end
90
+ end
91
+
92
+
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-orient
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.79'
4
+ version: '0.80'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hartmut Bischoff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-19 00:00:00.000000000 Z
11
+ date: 2020-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,21 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Persistent ORM for OrientDB(V.3), based on ActiveModel. Rails 5 compatible
83
+ - !ruby/object:Gem::Dependency
84
+ name: pond
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Persistent ORM for OrientDB(V.3), based on ActiveModel
84
98
  email:
85
99
  - topofocus@gmail.com
86
100
  executables: []
@@ -88,6 +102,7 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - ".gitignore"
105
+ - ".graphs.txt.swp"
91
106
  - ".rspec"
92
107
  - Gemfile
93
108
  - Guardfile
@@ -97,17 +112,13 @@ files:
97
112
  - active-orient.gemspec
98
113
  - bin/active-orient-0.6.gem
99
114
  - bin/active-orient-console
115
+ - changelog.md
100
116
  - config/boot.rb
101
117
  - config/config.yml
102
118
  - config/connect.yml
103
119
  - examples/books.rb
104
120
  - examples/streets.rb
105
- - examples/test_commands.rb
106
- - examples/test_commands_2.rb
107
- - examples/test_commands_2.rb~
108
- - examples/test_commands_3.rb
109
- - examples/test_commands_4.rb
110
- - examples/time_graph.md
121
+ - graphs.txt
111
122
  - lib/active-orient.rb
112
123
  - lib/base.rb
113
124
  - lib/base_properties.rb
@@ -117,6 +128,7 @@ files:
117
128
  - lib/java-api.rb
118
129
  - lib/jdbc.rb
119
130
  - lib/model/custom.rb
131
+ - lib/model/e.rb
120
132
  - lib/model/edge.rb
121
133
  - lib/model/model.rb
122
134
  - lib/model/the_class.rb
@@ -132,9 +144,13 @@ files:
132
144
  - lib/rest/read.rb
133
145
  - lib/rest/rest.rb
134
146
  - lib/rest_disabled.rb
147
+ - lib/support/conversions.rb
148
+ - lib/support/default_formatter.rb
149
+ - lib/support/errors.rb
135
150
  - lib/support/logging.rb
136
151
  - lib/support/orient.rb
137
152
  - lib/support/orientquery.rb
153
+ - lib/support/query.rb
138
154
  - rails.md
139
155
  - rails/activeorient.rb
140
156
  - rails/config.yml
@@ -158,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
174
  - !ruby/object:Gem::Version
159
175
  version: '0'
160
176
  requirements: []
161
- rubygems_version: 3.0.1
177
+ rubygems_version: 3.0.4
162
178
  signing_key:
163
179
  specification_version: 4
164
180
  summary: Pure ruby client for OrientDB(V.3) based on ActiveModel
@@ -1,97 +0,0 @@
1
- ### OUTDATED ####
2
- ### Please do not use anymore.
3
- ### Insteed take a look to the Rspec-files in /spec/lib
4
-
5
-
6
- require 'awesome_print'
7
- require_relative "../lib/active-orient.rb"
8
-
9
- # Start server
10
- ActiveOrient::OrientDB.default_server = { user: 'root', password: 'tretretre' }
11
-
12
- # Select database
13
- r = ActiveOrient::OrientDB.new database: 'NewTest'
14
- r.delete_database database: 'NewTest'
15
- r = ActiveOrient::OrientDB.new database: 'NewTest'
16
-
17
- print "\n"+"*"*20+"DATABASE"+"*"*20+"\n"
18
-
19
- print "#{r.get_resource} \n" # <--- See the address of the server
20
- print "#{r.get_databases} \n" # <--- List available databases
21
-
22
- # r.create_database(database: "Onetwothree") # <--- Create a new database
23
- print "#{r.database} \n" # <--- See the working database
24
-
25
- # r.delete_database database: "Onetwothree" # <--- Delete an old database
26
-
27
- print "\n"+"*"*20+"CLASSES"+"*"*20+"\n"
28
-
29
- ap r.get_classes, :indent => -2 # <--- See available classes
30
- print "#{r.get_classes 'name'} \n" # <--- See the names of the available classes
31
-
32
- print "#{r.class_hierarchy} \n" # <--- See hierarchy of the classes
33
- print "#{r.class_hierarchy base_class: 'V'} \n" # <--- See hierarchy under V (Vectors classes)
34
- print "#{r.class_hierarchy base_class: 'E'} \n" # <--- See hierarchy under E (Edges classes)
35
-
36
- print "#{r.database_classes} \n" # See classes without including System classes
37
- print "#{r.database_classes include_system_classes: true} \n " # See classes including System classes
38
- print "#{r.inspect_classes} \n" # Same as r.database_classes
39
-
40
-
41
- doc1 = r.create_class "DocumentTest" # Create Document/Vertex/Edge class
42
- doc2 = r.create_class "DocumentArriveTest"
43
- ver1 = r.create_vertex_class "VertexTest"
44
- ver2 = r.create_vertex_class "Vertex_ArriveTest"
45
- edg1 = r.create_edge_class "EdgeTest"
46
- ver1 = r.open_class "VertexTest" # Same as create_class
47
-
48
- print "\n"+"*"*20+"RECORDS"+"*"*20+"\n"
49
-
50
- a = doc1.create name: "Doc1"
51
- a2 = doc1.create name: "Doc12"
52
- b = doc2.create name: "Doc2"
53
- b2 = doc2.create name: "Doc22"
54
- aver = ver1.create vname: "Ver1"
55
- aver2 = ver1.create vname: "Ver12"
56
- bver = ver2.create vname: "Ver2"
57
- bver2 = ver2.create vname: "Ver22"
58
-
59
- edg1.create_edge attributes: {famname: "edg1"}, from: aver, to: [bver, bver2], unique: true
60
- nex = edg1.create_edge attributes: {familyname: "edg2"}, from: aver, to: [bver, bver2], unique: true # <--- We don't overwrite since we select a unique
61
- nex1 = edg1.create_edge attributes: {familyname: "edg3"}, from: aver, to: [bver, bver2]
62
- nex2 = edg1.create_edge attributes: {familyname: "edg4"}, from: aver, to: [bver, bver2]
63
-
64
- print "#{nex1}"
65
- print "\n\n BVER = #{bver.rid} \n" # Check the RID of the vertex
66
- r.delete_edge nex1, nex2 # Used to delete edges
67
- r.delete_class doc2 # Used to delete a class
68
- doc2 = r.create_class "Document_Arrive_Test"
69
-
70
- print "\n"+"*"*20+"PROPERTY"+"*"*20+"\n"
71
-
72
- r.create_property doc2, :name, type: :string, index: :string #add one property
73
- doc2.create_property :familyname, type: :string, index: :string #the same but starting directly from the class
74
- r.create_properties doc2, {age: {type: :integer}, address: {type: :string}} #add more properties
75
- doc2.create_properties({feetsize: {type: :integer}, country: {type: :string}})
76
- b = doc2.create name: "Lucas", age: 91 #add more properties directly from the class
77
-
78
- print "\n"+"*"*20+"\n"
79
- r.delete_property doc2, "age" #delete one property
80
- doc2.delete_property "country" #delete one property directly from the class
81
- print "\n"+"*"*20+"\n"
82
-
83
- ap r.get_class_properties doc2 #get the properties of a class
84
- ap doc2.get_class_properties #get the properties of a class directly from the class
85
-
86
- print "\n"+"*"*20+"\n"
87
-
88
- r.print_class_properties doc2 #get the properties of a class in nice way
89
- doc2.print_class_properties #get the properties of a class in nice way directly from the class
90
-
91
- gg = r.create_document doc2, attributes: {name: "Test"}
92
- hh = doc2.create_document attributes: {name: "Code"}
93
-
94
- r.delete_document gg, hh # delete a document from database
95
- doc2.delete_document hh # delete a document from a class
96
-
97
- r.create_index doc2, name: "name" #Create index
@@ -1,59 +0,0 @@
1
- ### OUTDATED ####
2
- ### Please do not use anymore.
3
- ### Insteed take a look to the Rspec-files in /spec/lib
4
-
5
-
6
- require 'awesome_print'
7
- require_relative "../lib/active-orient.rb"
8
-
9
- # Start server
10
- ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
11
-
12
- # Select database
13
- r = ActiveOrient::OrientDB.new database: 'NewTest'
14
-
15
- #r.delete_class "Document_Test"
16
- doc1 = r.create_class "DocumentTest" # Create Document/Vertex/Edge class
17
- doc2 = r.create_class "DocumentArrive_Test"
18
- ver1 = r.create_vertex_class "VertexTest"
19
- ver2 = r.create_vertex_class "VertexArriveTest"
20
- edg1 = r.create_edge_class "EdgeTest"
21
- ver1 = r.open_class "VertexTest" # Same as create_class
22
-
23
- par = r.get_documents from: "DocumentTest", where: {name: "Doc1"} # Get documents
24
- par = doc1.get_documents where: {name: "Doc1"} # Same as above
25
- print "0 "
26
- ap par, :indent => -2
27
-
28
- num = r.count_documents from: "DocumentTest", where: {name: "Doc1"}
29
- num2 = doc1.count where: {name: "Doc1"}
30
- print "\n1 COUNT: #{num2} \n\n"
31
-
32
- r.create_or_update_document doc1, set: {familyname: "John"}, where: {name: "Doc1"}
33
- r.update_or_create_documents doc1, where: {name: "Doc1"}, set: {age: 91}
34
- doc1.update_or_create_documents where: {name: "Doc1"}, set: {age: 91}
35
- doc1.update_or_create_documents where: {name: "Doc2"}, set: {age: 91}
36
- par = doc1.get_documents where: {name: "Doc1"}
37
- #ap par, :indent => -2
38
-
39
- print "2 #{par[0].attributes} \n\n" # Access attributes
40
- print "3 #{par[0].metadata} \n\n" # Access metadata
41
-
42
- r.delete_documents doc1, where: {name: "Doc2"}
43
- doc1.delete_documents where: {name: "Doc2"}
44
-
45
- a = r.get_document "1:0" # Get by RID
46
-
47
- r.patch_document "1:0" do {name: "is a test"} end
48
-
49
- r.update_documents doc1, set: {age: 191}, where: {name: "Doc1"} # Update a document
50
- doc1.update_documents set: {age: 191}, where: {name: "Doc1"}
51
-
52
- a = r.execute "Document_Test" do # To execute commands
53
- [{type: "cmd", language: 'sql', command: "SELECT * FROM DocumentTest WHERE name = 'Doc1'"}]
54
- end
55
- print "\n4 #{a} \n \n"
56
-
57
- a = r.classname doc1
58
- a = doc1.classname
59
- print "5 #{a} \n \n"
@@ -1,55 +0,0 @@
1
- ### OUTDATED ####
2
- ### Please do not use anymore.
3
- ### Insteed take a look to the Rspec-files in /spec/lib
4
-
5
-
6
-
7
-
8
- require 'awesome_print'
9
- require_relative "../lib/active-orient.rb"
10
-
11
- # Start server
12
- ActiveOrient::OrientDB.default_server= { user: 'root', password: 'tretretre' }
13
-
14
- # Select database
15
- r = ActiveOrient::OrientDB.new database: 'NewTest'
16
-
17
- doc1 = r.create_class "DocumentTest"
18
- ver1 = r.create_vertex_class "VertexTest"
19
- a = doc1.create name: "Doc1"
20
- v = ver1.create name: "Ver"
21
-
22
- out = doc1.orientdb_class name: "Doc2345" # Used to instantiate an ActiveOrient Model
23
- print "1 #{out} \n"
24
-
25
- out = ver1.autoload_object "16:35" # Used to get a record by rid
26
- print "2 #{out} \n"
27
-
28
- print "3 #{ver1.superClass} \n" # Check superClass of the class
29
-
30
- print "4 #{v.class} \n"
31
-
32
- print "5 #{doc1} \n"
33
-
34
- print "6 #{a} \n"
35
-
36
- print "7 #{v} \n"
37
-
38
- a = v.classname # Class of v
39
- print "8 #{a} \n"
40
-
41
- a = v.rid
42
- print "9 #{a} \n" # RID of v
43
-
44
- a = ver1.count where: {name: "Ver"}
45
- print "10 #{a} \n"
46
-
47
- print "11 #{v.to_human} \n" # Human version
48
-
49
- print "12 #{v.content_attributes} \n" # Return attributes
50
-
51
- print "13 #{v.default_attributes} \n" # Return created and updated
52
-
53
- print "14 #{v.set_attribute_defaults} \n" # Set up
54
-
55
- print "15 #{v.metadata} \n" # Set up
@@ -1,33 +0,0 @@
1
-
2
- ### OUTDATED ####
3
- ### Please do not use anymore.
4
- ### Insteed take a look to the Rspec-files in /spec/lib
5
-
6
- require_relative "../lib/active-orient.rb"
7
-
8
- ActiveOrient::OrientDB.default_server = { user: 'root', password: 'tretretre' }
9
- r = ActiveOrient::OrientDB.new database: 'NewTest'
10
-
11
- doc1 = r.open_class "DocumentTest" # Create Document/Vertex/Edge class
12
- doc2 = r.open_class "DocumentArrive_Test"
13
- doc1.create_property :familyname, type: :string
14
- doc1.create_property :family, type: :linkset, other_class: "DocumentTest"
15
-
16
- a1 = doc1.create name: "DocA", value: 34
17
- a2 = doc1.create name: "DocB", value: 34
18
- a3 = doc1.create name: "DocC", value: 34
19
- a4 = doc1.create name: "DocD", value: 30
20
- doc1.create name: "DocE", value: 30
21
- doc1.create name: "DocF", value: 30
22
-
23
- print "#{a1.ciao} \n"
24
- a1.family = [a2, a3]
25
- print "#{a1["family"].name} \n"
26
- print "---> #{a1.family.class}\n"
27
- a1["family"] << a4
28
- print "#{a1.family.name} \n"
29
-
30
-
31
- # ActiveOrient::OrientDB.methods.each do |m|
32
- # print "#{m} \n"
33
- # end