MacRuby - ActiveRecord for storage? - ruby

Is it possible to use ActiveRecord for storage and query in a MacRuby Cocoa application?
If it is, are there any resources that shows how?
Are there any reason why ActiveRecord should not be used?

Yes, it is. It's a Ruby library, you can use it without any problem.
However, ActiveRecord is a quite huge library. You might not need all its features. If you simply need to connect to a database and perform operations, I strongly encourage you to give Sequel gem a try.

Related

Does exist any BoltDB Ruby gem binding?

Bolt is an amazing embedded key/value database for Go:
https://www.progville.com/go/bolt-embedded-db-golang/
https://github.com/boltdb/bolt
There is any binding (gem) for Ruby language ?
It shouldn't be a driver for any language rather than Go because as you say it's embedded e.i. it works like a Go library that just do data manipulation over a file.
What I know for sure there's HTTP or other network protocols wrappers on top of BoltDB, for example: https://github.com/skyec/boltdb-server and even with Raft: https://github.com/hashicorp/raft-boltdb. As you may see it's pretty easy create your own network layer, I've been thinking in do my own.
Maybe this's not your answer, but it's too big for a comment :)

Ruby and graph DB w/o Jruby

I'm hoping to introduce a graph DB into my project w/o having to move to jRuby. As I see it, given this restriction I've got two options:
Use a graph DB that provides a RESTful interface. I don't know what impact this will have on performance. I'm planning for a crapload of data.
Find a graph DB that has a ruby interface not requiring jRuby. In my search thus far I've not found anything but most of the posts and blog entries I've found have been fairly dated. I'd prefer the DB and interface to be somewhat mature and reliable, of course.
Does anyone know of anything that would meet #2 above?
If you're concerned about performance, I'd recommend trying JRuby and neo4j.rb
because it interacts directly with the embedded, high performance neo4j-Java-API. Ultimately I think that would be the highest-performance solution.
If you're not willing to entertain JRuby at all, there are options. Neo4j has a REST API and neography is a thin wrapper for it.
Or you use the Neo4j Server - (J)Ruby extension. This is a JRuby Rack application that exposes a REST API. It contains the Neo4J server, so it can be installed and used as a JRuby app, and your stack is Ruby all the way down, even if it is mostly MRI Ruby and the JRuby part is isolated to persistence.

Best practice for gem that creates its own database

I have a gem that I want to be capable of creating its own database (and later making migrations to that database if necessary). The gem uses ActiveRecord when reading and writing to the database. Short of embedding my gem in a non-serving Rails application just to get the necessary rake tasks, is there a best practice or community-promoted method for doing this? Attaching a whole Rails infrastructure to my little command-line only app just to get future migration upgrades seems like way too much overhead.
You can use DataMapper, which is a relatively lightweight ORM system (compared to ActiveRecord) in combination with an SQLite database. You don't need to use Rails for this, DataMapper drops nicely into a regular app, even something that isn't web-based.
You can use standalone_migrations gem to manage ActiveRecord environment outside of Rails: https://github.com/thuss/standalone-migrations. If you include your migrations or schema into a gem package, consumers of your gem can recreate db structure from scratch. I agree with robbrit that SQLite is the easiest choice for a database.

How difficult is it to switch from ActiveRecord to DataMapper in Rails 3.1?

I'm starting a new project and I have maybe three resources defined. Not a lot of code so far. (Rails 3.1)
But I'm interested in trying out DataMapper. I'm used to ActiveRecord (and actually enjoy it) but I'm always on the lookout for new things. Plus, my application uses Backbone.js but I don't believe that's relevant.
So how hard is it to switch out the ORM "mid-app" like this and do you think the learning curve to DM is that hard?
PS, there is a chance that I might be using other engines alongside my application. Such as MongoDB running along with Postgres. Will DM be at an advantage there?
To use Datamapper itself, there isn't much to it but it is some of the Rails niceties that require additional work (like the SQL execution times in "rails s") and there is also the rake tasks.
Check out dm-rails - They have a template that you use to provision the initial Rails project that sets it up with everything for Datamapper. You can also look through the source and see how it hooks everything. There is a small issue if you use database-backed session stores with Datamapper, which involves a monkey patch.

Is there a database or persistent storage, packaged in a Ruby gem?

I have a simple Sinatra application that needs some persistence storage. If possible, that database should offer some access by id, and keyword search/find options.
Considering the nature of the to-be stored items, a document-based database seems the best fit.
Obviously I have considered MongoDB and CouchDB, but all have one problem: they introduce dependencies on third party services. I don't want that.
My users should install the Sinatra app as a gem, with its dependencies, run a single command and have everything running.
I am looking for solutions that come as a gem, run under the current user and are really simple. A prepackaged mongoDB would do, too, but I cannot find such a thing. Is SQLlite my only option?
It sounds like you want DBM (which gives you access by id) and Ruby/odeum which gives you keyword search.
You may want to consider either a self-standing database like SQLite and Redis (no-SQL), or an ORM like DataMapper.

Resources