active-orient 0.4 → 0.80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.graphs.txt.swp +0 -0
  4. data/Gemfile +9 -5
  5. data/Guardfile +12 -4
  6. data/README.md +70 -281
  7. data/VERSION +1 -1
  8. data/active-orient.gemspec +9 -7
  9. data/bin/active-orient-0.6.gem +0 -0
  10. data/bin/active-orient-console +97 -0
  11. data/changelog.md +60 -0
  12. data/config/boot.rb +70 -17
  13. data/config/config.yml +10 -0
  14. data/config/connect.yml +11 -6
  15. data/examples/books.rb +154 -65
  16. data/examples/streets.rb +89 -85
  17. data/graphs.txt +70 -0
  18. data/lib/active-orient.rb +78 -6
  19. data/lib/base.rb +266 -168
  20. data/lib/base_properties.rb +76 -65
  21. data/lib/class_utils.rb +187 -0
  22. data/lib/database_utils.rb +99 -0
  23. data/lib/init.rb +80 -0
  24. data/lib/java-api.rb +442 -0
  25. data/lib/jdbc.rb +211 -0
  26. data/lib/model/custom.rb +29 -0
  27. data/lib/model/e.rb +6 -0
  28. data/lib/model/edge.rb +114 -0
  29. data/lib/model/model.rb +134 -0
  30. data/lib/model/the_class.rb +657 -0
  31. data/lib/model/the_record.rb +313 -0
  32. data/lib/model/vertex.rb +371 -0
  33. data/lib/orientdb_private.rb +48 -0
  34. data/lib/other.rb +423 -0
  35. data/lib/railtie.rb +68 -0
  36. data/lib/rest/change.rb +150 -0
  37. data/lib/rest/create.rb +287 -0
  38. data/lib/rest/delete.rb +150 -0
  39. data/lib/rest/operations.rb +222 -0
  40. data/lib/rest/read.rb +189 -0
  41. data/lib/rest/rest.rb +120 -0
  42. data/lib/rest_disabled.rb +24 -0
  43. data/lib/support/conversions.rb +42 -0
  44. data/lib/support/default_formatter.rb +7 -0
  45. data/lib/support/errors.rb +41 -0
  46. data/lib/support/logging.rb +38 -0
  47. data/lib/support/orient.rb +305 -0
  48. data/lib/support/orientquery.rb +647 -0
  49. data/lib/support/query.rb +92 -0
  50. data/rails.md +154 -0
  51. data/rails/activeorient.rb +32 -0
  52. data/rails/config.yml +10 -0
  53. data/rails/connect.yml +17 -0
  54. metadata +89 -30
  55. data/lib/model.rb +0 -461
  56. data/lib/orient.rb +0 -98
  57. data/lib/query.rb +0 -88
  58. data/lib/rest.rb +0 -1036
  59. data/lib/support.rb +0 -347
  60. data/test.rb +0 -4
  61. data/usecase.md +0 -91
@@ -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
+
@@ -0,0 +1,154 @@
1
+ # Active Orient and Rails
2
+
3
+ The usage of Orientdb via ActiveOrient in Rails requires just a few steps.
4
+ Based on a Rails 5 installation
5
+
6
+ ```ruby
7
+ rvm install 2.4
8
+ rvm use 2.4
9
+ gem install bundler
10
+ gem install nokogiri
11
+ gem install rails
12
+ rails -v # Rails 5.0.1
13
+
14
+ ```
15
+
16
+ create your working directory and initialize the system
17
+
18
+ ```ruby
19
+ mkdir rails_project; cd rails_project
20
+ rails new -OCT .
21
+ ```
22
+ This initializes a Rails-Stack, without active-record, action-cable and the test-suite.
23
+ (We will use rspec later)
24
+
25
+ This can be checked by inspecting «/config/application.rb «
26
+
27
+ ```ruby
28
+ rails s puma
29
+ ```
30
+ should work at this stage.
31
+
32
+ ## Modify the Gemfile
33
+ Inform rails to use orientdb and active-orient
34
+
35
+ ```
36
+ echo " gem 'active-orient' , :path => '/home/your_cloned_active_orient_path/activeorient' " >> Gemfile
37
+ # or
38
+
39
+ echo " gem 'active-orient' , :git => 'https://github.com/topofocus/active-orient.git' " >> Gemfile
40
+
41
+ ```
42
+
43
+ Run the bundler
44
+
45
+ ```
46
+ bundle install & bundle update
47
+ ```
48
+ ## Copy Initializer and Configuration Files
49
+ change to the base-dir of the gem
50
+ --> bundle show active-orient
51
+ then copy
52
+
53
+ * rails/activeorient.rb to config/initializers in the rails-project dir
54
+ * rails/connect.yml to config in the rails project
55
+ * rails/config.yml to config in the rails project
56
+
57
+ and modify the yml-files accordingly.
58
+ (Depending on your settings, you might have to adjust tab-levels)
59
+
60
+
61
+ The database is present in the rails console, and
62
+ ```ruby
63
+ rails c
64
+ puts ActiveOrient:show_classes
65
+
66
+ V.count
67
+ V.first
68
+ E.count
69
+
70
+ ```
71
+ should display details.
72
+
73
+
74
+ **Notice** The spring-facility is running in the background. Stop the server prior reloading
75
+ the console ( ./bin/spring stop ).
76
+
77
+ ## Model-files
78
+ The final step is to generate Model-Files.
79
+
80
+ In «/config/config.yml» the «:model_dir»-var points to
81
+ the location of the model-files. The default is 'lib/orient'. Change to your needs.
82
+ Don't use the app directory, as its autoloaded too early.
83
+
84
+ Upon startup, present model-classes are destroyed and overridden by present files in the autoload directory.
85
+
86
+ After envoking the rails console, the logfile displays sucessfully loaded and missing files, ie.
87
+
88
+ ```
89
+ 14.01.(08:28:45) INFO->ModelClass#RequireModelFile:..:model-file not present: /home/topo/workspace/orient-rails/lib/orient/followed_by.rb
90
+ 14.01.(08:28:45) INFO->ModelClass#RequireModelFile:..:/home/topo/workspace/orient-rails/lib/orient/v.rb sucessfully loaded
91
+ ```
92
+
93
+ ## Model-file Example
94
+
95
+ To query the GratefulDeadConcerts Database, «v.rb» hosts the essential model methods.
96
+ As always, use «def self.{method}« for class methods and simply «def {method}» for methods working on the record level.
97
+
98
+ ```
99
+ 1 class V
100
+ 2 def self.artists **attributes
101
+ 3 names 'artist', **attributes
102
+ 4 end
103
+ 5
104
+ 6 def self.songs **attributes
105
+ 7 names 'song', **attributes
106
+ 8 end
107
+ 9
108
+ 10 def self.types
109
+ 11 oo = OrientSupport::OrientQuery
110
+ 12 this_query = oo.new distinct: [:type, :a ] # --> "select distinct( type ) as a "
111
+ 13 query_database( this_query ).a # returns an array of types, i.e. ["artist", "song"]
112
+ 14 end
113
+ 15 private
114
+ 16 def self.names type, sort: :asc, limit: 20, skip: 0
115
+ 17 puts "in names"
116
+ 18 oo = OrientSupport::OrientQuery
117
+ 19 query_database oo.new( where: {type: type },
118
+ 20 order: { name: sort } ,
119
+ 21 limit: limit ,
120
+ 22 skip: skip )
121
+ 23 end
122
+ 24 end
123
+
124
+ ```
125
+
126
+ Now
127
+
128
+ ```ruby
129
+ V.types
130
+ V.artists limit: 15, skip: 34, sort: :desc
131
+ ```
132
+ queries the database, fetches 15 artists.
133
+
134
+ ## Routing
135
+
136
+ for now, restful routing has some restrictions.
137
+
138
+ Rails-routing is depending on the "id"-attribute. Even if this is remapped to rid, the ressources-entries in "config/routes.rb" have to be modified by
139
+
140
+ ```ruiby
141
+ resources :{controller}, id: /[^\/]+/
142
+ ```
143
+ this enables the usage of id: "xx:yy"
144
+
145
+ In the controller the record is fetched as usual:
146
+ ```ruby
147
+ def show
148
+ @{your coice} = {ActiveOrient-Model-Class}.autoload_object params[:id]
149
+ end
150
+ ```
151
+
152
+
153
+
154
+
@@ -0,0 +1,32 @@
1
+
2
+ ## This is an init-script intented to be copied to
3
+ ## rails-root/config/initializers
4
+
5
+ ## Integrate a namespaced model
6
+ #module HC
7
+ #
8
+ #end
9
+ #
10
+ #Hc = HC
11
+ #ActiveOrient::Model.keep_models_without_file = false
12
+ #ActiveOrient::Init.define_namespace { HC }
13
+ #ActiveOrient::OrientDB.new preallocate: true
14
+ #
15
+ # class ActiveOrient::Model
16
+ # def self.namespace_prefix
17
+ # ""
18
+ # end
19
+ # end
20
+ #
21
+ # At the end: include everything which is not yet allocated to some namespaced model
22
+ ActiveOrient::Init.connect
23
+ ActiveOrient::Model.keep_models_without_file = true
24
+
25
+ ActiveOrient::OrientDB.new preallocate: true
26
+
27
+
28
+
29
+
30
+
31
+
32
+
@@ -0,0 +1,10 @@
1
+ ---
2
+ :active_orient:
3
+ ## Namespace: Prefix of Model-Objects. :self -> ActiveOrient::Model::{name}
4
+ ## :object => No Prefix
5
+ ## :active_orient => ActiveOrient::{name}
6
+ :namespace: :object
7
+ ## model_dir: Path to model-files relative to the root of the application
8
+ ## ie. app/model or model
9
+ :model_dir: 'lib/orient'
10
+
@@ -0,0 +1,17 @@
1
+ ---
2
+ :orientdb:
3
+ :server: localhost # 172.28.50.109
4
+ :port: 2480
5
+ :logger: stdout # 'file' or 'stdout'
6
+ :database:
7
+ :development: GratefulDeadConcerts
8
+ :production: hcn_data
9
+ :test: temp
10
+ :admin:
11
+ :user: root
12
+ :pass: root
13
+ :auth:
14
+ :user: root
15
+ :pass: root
16
+
17
+ # hfx: 101
metadata CHANGED
@@ -1,72 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-orient
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
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: 2015-09-11 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
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '4.2'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '4.2'
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rest-client
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pond
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
60
88
  - !ruby/object:Gem::Version
61
- version: '2.0'
89
+ version: '0'
62
90
  type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - "~>"
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
- version: '2.0'
69
- description: Persistent ORM for OrientDB, based on ActiveModel
96
+ version: '0'
97
+ description: Persistent ORM for OrientDB(V.3), based on ActiveModel
70
98
  email:
71
99
  - topofocus@gmail.com
72
100
  executables: []
@@ -74,6 +102,7 @@ extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
76
104
  - ".gitignore"
105
+ - ".graphs.txt.swp"
77
106
  - ".rspec"
78
107
  - Gemfile
79
108
  - Guardfile
@@ -81,20 +110,51 @@ files:
81
110
  - README.md
82
111
  - VERSION
83
112
  - active-orient.gemspec
113
+ - bin/active-orient-0.6.gem
114
+ - bin/active-orient-console
115
+ - changelog.md
84
116
  - config/boot.rb
117
+ - config/config.yml
85
118
  - config/connect.yml
86
119
  - examples/books.rb
87
120
  - examples/streets.rb
121
+ - graphs.txt
88
122
  - lib/active-orient.rb
89
123
  - lib/base.rb
90
124
  - lib/base_properties.rb
91
- - lib/model.rb
92
- - lib/orient.rb
93
- - lib/query.rb
94
- - lib/rest.rb
95
- - lib/support.rb
96
- - test.rb
97
- - usecase.md
125
+ - lib/class_utils.rb
126
+ - lib/database_utils.rb
127
+ - lib/init.rb
128
+ - lib/java-api.rb
129
+ - lib/jdbc.rb
130
+ - lib/model/custom.rb
131
+ - lib/model/e.rb
132
+ - lib/model/edge.rb
133
+ - lib/model/model.rb
134
+ - lib/model/the_class.rb
135
+ - lib/model/the_record.rb
136
+ - lib/model/vertex.rb
137
+ - lib/orientdb_private.rb
138
+ - lib/other.rb
139
+ - lib/railtie.rb
140
+ - lib/rest/change.rb
141
+ - lib/rest/create.rb
142
+ - lib/rest/delete.rb
143
+ - lib/rest/operations.rb
144
+ - lib/rest/read.rb
145
+ - lib/rest/rest.rb
146
+ - lib/rest_disabled.rb
147
+ - lib/support/conversions.rb
148
+ - lib/support/default_formatter.rb
149
+ - lib/support/errors.rb
150
+ - lib/support/logging.rb
151
+ - lib/support/orient.rb
152
+ - lib/support/orientquery.rb
153
+ - lib/support/query.rb
154
+ - rails.md
155
+ - rails/activeorient.rb
156
+ - rails/config.yml
157
+ - rails/connect.yml
98
158
  homepage: https://github.com/topofocus/active-orient
99
159
  licenses:
100
160
  - MIT
@@ -107,16 +167,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
167
  requirements:
108
168
  - - ">="
109
169
  - !ruby/object:Gem::Version
110
- version: 2.2.0
170
+ version: '2.5'
111
171
  required_rubygems_version: !ruby/object:Gem::Requirement
112
172
  requirements:
113
173
  - - ">="
114
174
  - !ruby/object:Gem::Version
115
175
  version: '0'
116
176
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.4.6
177
+ rubygems_version: 3.0.4
119
178
  signing_key:
120
179
  specification_version: 4
121
- summary: Pure ruby client for OrientDB based on ActiveModel
180
+ summary: Pure ruby client for OrientDB(V.3) based on ActiveModel
122
181
  test_files: []