Dan
Dan

Reputation: 3377

How should I generate a Rhodes extension from a Ruby gem?

I know there is no direct support for Ruby gems in the Rhomobile framework. I have read their (sparse!) documentation to migrate in gem support through extensions, but I cannot for the life of me figure out how exactly this should be implemented.

Besides the document linked above being very disjointed, what I can find can't be easily translated to what I need. I am trying to bring devise into my app, but the gem structure is very hierarchical and the example given in the Rhomobile documentation suggests that a given library should be a singular .rb file.

The exact example given is as follows:

Assuming your application is called “mynewapp”, create a directory 
under app called lib (or whatever you wish to call it):

$ cd mynewapp
$ mkdir app/lib

$ cp /path/to/my_lib.rb app/lib/my_lib.rb

Then just require lib/my_lib in a given file within my app. Eg:

require 'lib/my_lib'

To translate to the devise gem, my assumption is that I couldn't do something similar, but would instead have to flatten the directory structure out in some way before I could use it. Is that the case or am I missing something? That's a lot of re-writing code...

Also, if anyone knows of any kind of guide to adding gems to the Rhodes framework, I would love to see it! I've looked through most of the official documentation and some non-official and nothing seems to address this at all.

Upvotes: 0

Views: 177

Answers (1)

Dan
Dan

Reputation: 3377

Wow. I don't know how I overlooked this, but it's really simple and nothing like what I was assuming.

If you are using Rhodes via the RubyGems installation, you must add external Ruby libraries to your RubyGems installation directory for the ‘rhodes-framework’ gem. Your RubyGems installation directory can be found with gem env in a terminal.

From the same page linked in question.

My paths didn't match what was listed in that document because I'm using RVM, but I just ran find / -name rhodes-* and just looked for the one followed by /lib/framework.

Upvotes: 1

Related Questions