topofocus / active-orient Goto Github PK
View Code? Open in Web Editor NEWPure Ruby interface to OrientDB
License: MIT License
Pure Ruby interface to OrientDB
License: MIT License
I am using the test_commands.rb file in the examples folder as a standalone ruby script. I have the OrientDB server running locally. When I rub the script I get this error: undefined method `default_server=' for ActiveOrient::OrientDB:Class (NoMethodError).
I thought of removing OrientDB from the line. Now I get this error:
I, [2017-05-10T12:10:48.634338 #31412] INFO -- OrientDB#Connect: Connected to database NewTest
/home/user/.bundle/ruby/2.3.0/active-orient-fdae334715ca/lib/class_utils.rb:44:in `allocate_class_in_ruby': undefined method `const_defined?' for nil:NilClass (NoMethodError)
from /home/user/.bundle/ruby/2.3.0/active-orient-fdae334715ca/lib/database_utils.rb:81:in `block in preallocate_classes'
from /home/user/.bundle/ruby/2.3.0/active-orient-fdae334715ca/lib/database_utils.rb:80:in `each'
from /home/user/.bundle/ruby/2.3.0/active-orient-fdae334715ca/lib/database_utils.rb:80:in `preallocate_classes'
from /home/user/.bundle/ruby/2.3.0/active-orient-fdae334715ca/lib/rest/rest.rb:88:in `initialize'
from test_commands.rb:8:in `new'
from test_commands.rb:8:in `<main>'
Am I missing something or is this an issue?
If a Query is build and transmitted, it fails if a "%" is used in the command:
linked_element = @new_record.ll.where( "att like '3%'" )
fails with
RestClient::HTTPVersionNotSupported:
505 HTTP Version Not Supported
The matches operator is not working in OrientDB 2.1+2.2
See spec/array-spec.rb
"get one element from the embedded array by condition"
I am on Ruby 2.4 and OrientDB 2.2.14 (+ Rails 5.0). I can't seem to initiate the database in a way that it can create the database classes in Ruby. I have also tried installing the gem from Github as well, to no avail.
I run the following:
require 'bundler/setup'
require 'active-orient'
require 'logger'
load 'helpers.rb'
logger = Logger.new '/dev/stdout'
ActiveOrient::Model.logger = logger
ActiveOrient::OrientDB.logger = logger
ActiveOrient.default_server = {server: 'localhost', user: 'root', password: 'xxx', database: 'gems', port: 2480}
@g = ActiveOrient::OrientDB.new database: 'gems'
Upon the execution, I receive:
E, [2017-02-10T16:06:17.330945 #89252] ERROR -- ModelClass#OrientDBClass: ModelClass "_v" cannot be initialized.
E, [2017-02-10T16:06:17.332666 #89252] ERROR -- ModelClass#OrientDBClass: undefined method `const_get' for nil:NilClass
E, [2017-02-10T16:06:17.332779 #89252] ERROR -- ModelClass#OrientDBClass: /usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/model/the_class.rb:77:in `orientdb_class'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:67:in `block in allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:99:in `block in allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:97:in `map'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:97:in `allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:101:in `block in allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:97:in `map'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:97:in `allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:101:in `block in allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:97:in `map'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/class_utils.rb:97:in `allocate_classes_in_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/database_utils.rb:94:in `preallocate_classes'
/usr/local/lib/ruby/gems/2.4.0/gems/active-orient-0.6/lib/rest/rest.rb:74:in `initialize'
(pry):8:in `new'
(pry):8:in `__pry__'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `eval'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:355:in `evaluate_ruby'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:323:in `handle_line'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:242:in `catch'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:242:in `block in eval'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:241:in `catch'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_instance.rb:241:in `eval'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:77:in `block in repl'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:67:in `loop'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:67:in `repl'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:38:in `block in start'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/input_lock.rb:61:in `__with_ownership'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/input_lock.rb:79:in `with_ownership'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:38:in `start'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/repl.rb:15:in `start'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/pry_class.rb:169:in `start'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:219:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:83:in `block in parse_options'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:83:in `each'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/lib/pry/cli.rb:83:in `parse_options'
/usr/local/lib/ruby/gems/2.4.0/gems/pry-0.10.4/bin/pry:16:in `<top (required)>'
/usr/local/bin/pry:22:in `load'
/usr/local/bin/pry:22:in `<main>'
The log continues with more errors similar to this one.
The database object seems to initialize successfully, but create_class
won't work.
It seems that you have a hard dependency on activemodel but don't list it in the gemspec?
Your example in the README doesn't work as is.
Unless I'm missing something. Had to add 'activemodel' gem as well
Thanks.
I am stuck at this error when trying to use active-orient with Rails 6.
/Library/Ruby/Gems/2.6.0/gems/rest-client-2.1.0/lib/restclient/abstract_response.rb:249:in exception_with_response': 401 Unauthorized (RestClient::Unauthorized) from /Library/Ruby/Gems/2.6.0/gems/rest-client-2.1.0/lib/restclient/abstract_response.rb:129:in
return!'
from /Library/Ruby/Gems/2.6.0/gems/rest-client-2.1.0/lib/restclient/request.rb:836:in process_result' from /Library/Ruby/Gems/2.6.0/gems/rest-client-2.1.0/lib/restclient/request.rb:743:in
block in transmit'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/net/http.rb:920:in `start'
I am using rails Rails 6.0.3.3
Every dataset transfered from the database is stored in a rid-store, simply an array.
Any allocated ruby object refers to that and is thus updated automatically.
We have to implement a mechanism to shrink the array from time to time.
Edges are automatically translated into methods/attributes aka: (in)(out)_(classname)
These attributes just reflect the morphology of the database.
To reveal their oo-behavior a query has to send: select (in)(out)E('classname') form class
Some metaprogramming is required to automatically build a method record.classname which gives any edge with respect to the oo-tree.
Problem is: normally not the edge is queried, its the vertex connected to it.
Thus active-record: "has_many :through " has to be redefined
I try some of the examples in your readme files and in your repository and I had some problems that I am not able to solve. To install your gem I used gem install active-orient
Here a short list.
require 'bundler/setup'
require 'active-orient'
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'password' }
r = ActiveOrient::OrientDB.new database: 'First'
Vertex = r.create_vertex_class 'd1'
Edge = r.create_edge_class 'e1' # <--- Note, here I changed your Eedge in Edge
start = Vertex.create something: 'nice'
the_end = Vertex.create something: 'not_nice'
the_edge = Edge.create_edge attributes: { transform_to: 'very bad' },
from: start,
to: the_end
print start.e1[0]
The vertex and edge are created, but when I want to print the result I receive:
I, [2016-03-16T10:13:44.185332 #1229] INFO -- OrientDB#Connect: Connected to database First
D, [2016-03-16T10:13:51.499534 #1229] DEBUG -- ActiveOrient::OrientDB#NexusEdge: creating edge E1 from #13:0 to #13:1
testActiveOrient.rb:76:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
require 'bundler/setup'
require 'active-orient'
ActiveOrient::OrientDB.default_server= { user: 'root', password: 'password' }
r = ActiveOrient::OrientDB.new database: 'First'`
ach = ActiveOrient::Query.new
ach.queries << 'create class Contracts ABSTRACT'
ach.queries << 'create property Contracts.subcategory link'
ach.queries << 'create property Contracts.details link'
ach.queries << 'create class Stocks extends Contracts'
ach.queries << 'create class Futures extends Contracts'
result = ach.execute_queries transaction: false
print result
but the only result is the following:
I, [2016-03-16T10:22:40.414749 #1304] INFO -- OrientDB#Connect: Connected to database First
testActiveOrient.rb:78:in `<main>': uninitialized constant ActiveOrient::Query (NameError)
strassen = doc.css('#strassen-in-deutschland_main a' )
strassen = doc.css("td[data-header='Straßenname: '] a")
I cloned repo and execute bundle install and rewrote config/connect.yml .
But I failed rspec.
Can I work well ?
=>:~$ sudo gem install active-orient
ERROR: Could not find a valid gem 'rest-client' (~> 2.0) in any repository
ERROR: Possible alternatives: rest-client
I'm getting error messages like below when a new vertex of class AirPort is created. As you see below I'm creating two vertices NY and LA. I have noticed that first vertex would however created in the database, but after it throws an error, second vertex LA would not be created. Any help is greatly appreciated.
/home/nash/.rvm/gems/[email protected]/gems/active-orient-0.41/lib/base.rb:51:in `initialize': undefined method `progname=' for nil:NilClass (NoMethodError)
from /home/nash/.rvm/gems/[email protected]/gems/active-orient-0.41/lib/rest.rb:661:in `new'
from /home/nash/.rvm/gems/[email protected]/gems/active-orient-0.41/lib/rest.rb:661:in `create_document'
from /home/nash/.rvm/gems/[email protected]/gems/active-orient-0.41/lib/rest.rb:805:in `update_or_create_documents'
from /home/nash/.rvm/gems/[email protected]/gems/active-orient-0.41/lib/rest.rb:785:in `create_or_update_document'
from /home/nash/.rvm/gems/[email protected]/gems/active-orient-0.41/lib/model.rb:140:in `create'
from flights.rb:16:in `<main>'
require 'rubygems'
require 'bundler/setup'
require 'active-orient'
ActiveOrient::OrientDB.default_server= { user: 'xxx', password: '123' }
r = ActiveOrient::OrientDB.new database: 'TravelEngine'
A = r.create_vertex_class 'AirPort'
NY = A.create id: "NY", name: "New York"
LA = A.create id: "LA", name: "Los Angeles"
`rescue in block in connect': Failed to open TCP connection to localhost:2480 (Connection refused - connect(2) for "localhost" port 2480) (Errno::ECONNREFUSED)
Hii @topofocus
Hey, I'm trying out this package with jruby
- it works fine on the mri
I installed the active-orient
and active-model
gems via
> jruby -S gem install active-orient
> jruby -S gem install activemodel -v 4.2.6
But when I try to do a simple ActiveOrient::OrientDB.new database: 'GamesOfThrones'
in the jirb
it gives the following error TypeError: no implicit conversion of nil into Hash
Stack trace is as follows
TypeError: no implicit conversion of nil into Hash
from org/jruby/RubyHash.java:1708:in `merge!'
from org/jruby/RubyHash.java:1744:in `merge'
from /Users/eklavya/.jruby/lib/ruby/gems/shared/gems/active-orient-0.42/lib/rest.rb:50:in `initialize'
from (irb):3:in `<eval>'
from org/jruby/RubyKernel.java:995:in `eval'
from org/jruby/RubyKernel.java:1296:in `loop'
from org/jruby/RubyKernel.java:1115:in `catch'
from org/jruby/RubyKernel.java:1115:in `catch'
from /Users/eklavya/.jruby/bin//jirb:13:in `<main>'
Is there a solution to this ?
First of all - it's great to see a gem supporting OrientDB!
How about naming it rest-orient
? There is not that much ActiveRecord pattern there yet.
I would also suggest using RESTOrient
or similar namespace instead of a more general REST
namespace:
RESTOrient::Model
RESTOrient.orientdb = RESTOrient::OrientDB.new
Is there #
missing here?
r.get_document '21:1'
Hi again @topofocus
Hey, last night I installed Rails 5.0.0.1
and after that when I tried using the active-model
gem, the repl throws the following error.
pry(main)> require 'active-orient'
NameError: uninitialized constant ActiveModel::Serializers::Xml
from /Users/eklavya/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/active-orient-0.42/lib/base.rb:10:in `<class:Base>'
I did google around and came across rails/rails#24558 apparently ActiveModel::Serializers::Xml
has been removed from Rails5
but how dose all that related to active-orient
is beyond me.
I've already tried installing
gem 'activemodel-serializers-xml'
gem 'active_model_serializers'
but that doesn't seem to solve the problem. Do you have any suggestions?
Currently active-orient picks server details from a connect.yml
file.
The following lines takes the config in the activeorient.rb file.
username = eval(connectyml[:user])
password = eval(connectyml[:pass])
server = eval(serveryml[:server])
port = eval(serveryml[:port])
However I have setup OrientDB in a distributed mode. Is there a way active-orient can communicate with all the nodes in the distributed configuration?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.