Forum: Ruby Deployable project with C source code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ruby R. (Guest)
on 2007-08-02 22:06
Hi.  Ruby novice here.  So far, I have had a great experience
programming Ruby where I have only been relying on the standard library.
Lately, I have been wanting to tie some of my tools into a nice GUI
using QT or Tk.  I understand that running "ruby extconf.rb" will
dynamically generate a Makefile for me based on my OS, and that I run
that in order to compile and clean up my code.  I also understand that
the source code that is provided would extend my Ruby API in order to
access lower level code that would enable me to access these C libraries
as objects in Ruby.  What I fail to understand is how to make a project
that relies on such souce code easily deployable.  For example, if I
were writing something that only relied on the Ruby standard library,
all I would do is tar up my project with a README saying "type:  ruby
main.rb" and it would all work nicely.  Now, I want to write something
that will compile code that extends the API if necessary, then clean
everything up and run my main.rb.  How do I go about doing such a thing?

In Java, everything gets tied into a .jar file and when you compile it
goes from source->java bytecode.  I see the transition from
Ruby->c->binary has a setback of having to do a little bit more work
than you would in Java.  I could be wrong though.  Any feedback would be
greatly appreciated.  Thanks for your time.

-Mr. Rubyruby
Ruby R. (Guest)
on 2007-08-03 01:33
/bump!
Alex F. (Guest)
on 2007-08-03 02:20
(Received via mailing list)
Ruby R. wrote:
> Hi.  Ruby novice here.  So far, I have had a great experience
> programming Ruby where I have only been relying on the standard library.
> Lately, I have been wanting to tie some of my tools into a nice GUI
> using QT or Tk.

...

> What I fail to understand is how to make a project
> that relies on such souce code easily deployable.

If I understand you right, you want to create a package that runs your
project application fairly straightforwardly on other machines.

Probably the most popular solution to this is currently
rubyscript2exe[1], which examines your ruby script as it runs, then
creates an executable file (eg an .exe on Windows) which can be
distributed alone to other users to run as if it were a "normal"
compiled binary.

You should also look into tar2rubyscript[2] project, and exerb [3],
which do somewhat similar things, but not quite as simply.

As for packaging a GUI application, it depends on the GUI toolkit you're
using. AFAIK, Qt relies on fairly heavy libs which a user might have to
install separately. wxRuby and fxRuby are very simple to bundle using
rubyscript2exe or exerb. I don't know about TK, but I would imagine it's
fairly easy to include the appropriate dll.

a

[1] http://www.erikveen.dds.nl/rubyscript2exe/index.html
[2] http://www.erikveen.dds.nl/tar2rubyscript/index.html
[3] http://exerb.sourceforge.jp/index.en.html
Alex G. (Guest)
on 2007-08-03 04:24
(Received via mailing list)
On 3 Aug 2007, at 03:06, Ruby R. wrote:

> as objects in Ruby.  What I fail to understand is how to make a
> project
> that relies on such souce code easily deployable.

A correctly packaged gem would be able to do this (depending on
exactly what you want to do), read the Pickaxe book chapters on gems/
extensions for more details. On the other hand you could look at how
_why is packaging Shoes (http://code.whytheluckystiff.net/shoes/).

Alex G.

Bioinformatics Center
Kyoto University
David Mark Weiss (Guest)
on 2007-08-03 04:39
(Received via mailing list)
Hi,

New R. Guy here. Have completed several tutorials and enjoyed it.

Is there a way to connect Ruby to an existing database?

For my next project, i want to reproduce an app I did before in Ruby.
I really don't want to export and reimport records from the old db to
a db created by Ruby, as the tutorials always seem to ask you do do.

So, a db with 4 tables and thousands of records.

Thanks

Mark Weiss
http://trustthechildren.blogspot.com
David Mark Weiss (Guest)
on 2007-08-03 04:52
(Received via mailing list)
OK. I messed up not putting a subjects

Now I have two questions:

First as below:

Is there a way to connect Ruby to an existing database?

For my next project, i want to reproduce an app I did before in Ruby.
I really don't want to export and reimport records from the old db to
a db created by Ruby, as the tutorials always seem to ask you do do.

So, a db with 4 tables and thousands of records.

Second:

How do you format a column when displayed?   In another life ...
format="datetime:%m/%d/%y"

Thanks for any suggestions.

Mark Weiss
http://trustthechildren.blogspot.com
Ryan D. (Guest)
on 2007-08-03 05:53
(Received via mailing list)
On Aug 2, 2007, at 17:50 , David Mark Weiss wrote:

> OK. I messed up not putting a subjects

You also messed up by hijacking a thread. Please start a fresh thread
next time.
Mark G. (Guest)
on 2007-08-03 05:58
(Received via mailing list)
Hi David,

What type of database is it eg mysql, sqlite, access? It shouldn't be
necessary to use a database which has been created with Ruby.

Depending on your database structure, ActiveRecord could be a very easy
way to get up and running with Ruby/db's.

There are many other database interfaces for Ruby. Try a search on
rubyforge.org.

Cheers,
Mark
David Mark Weiss (Guest)
on 2007-08-03 08:07
(Received via mailing list)
Your right, I just grabbed an email, responded to it, and changed the
subject and body.

I am happy to start a new thread next time, but may I ask where that
shows up?

Mark
David Mark Weiss (Guest)
on 2007-08-03 08:30
(Received via mailing list)
Mark,

I am running mySQL, innodb. 5.0.24a
I did the install found at  http://hivelogic.com/narrative/articles/
ruby-rails-mongrel-mysql-osx
Did the install 2 days ago, so it is pretty current.

How do I use ActiveRecord to connect to an existing DB. ie how do I
configure Active Record to do that?
Or since I should do my part, where can I read about it, and perhaps
figure it out myself, like so many others on the list.

Thanks

Mark Weiss
Mark G. (Guest)
on 2007-08-03 09:27
(Received via mailing list)
Mark,

 From your first post I got the impression you weren't using Rails. Are
you? If you want to use Rails you will get a ton of help from the Rails
mailing lists:

http://wiki.rubyonrails.org/rails/pages/MailingLists

If you go without Rails, you can easily use activerecord directly from
Ruby. For example....

Given a table called dmImage with fields:

ObjectID -> varchar
location -> varchar

The code would look like:

//---
require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
    :adapter => 'mysql',
    :database => '<your_db_name>',
    :host=>'<db_host_name>'
    :username => '<db_username>',
    :password => <db_password>
)

class Image < ActiveRecord::Base
  set_primary_key 'ObjectID'
  set_table_name 'dmImage'

end
//---

Now you can do:

"img = Image.find :all" to get a list of all images.

If you are using a database structure which doesn't follow the
activerecord's conventions then you will need to set "set_primary_key"
and "set_table_name" to the appropriate values (as above) for your DB.

Cheers,
Mark
Ryan D. (Guest)
on 2007-08-04 22:21
(Received via mailing list)
On Aug 2, 2007, at 21:06 , David Mark Weiss wrote:

> Your right, I just grabbed an email, responded to it, and changed
> the subject and body.
>
> I am happy to start a new thread next time, but may I ask where
> that shows up?

in threaded mail clients.
Michael G. (Guest)
on 2007-08-05 00:27
(Received via mailing list)
On Aug 4, 2007, at 13:20 , Ryan D. wrote:

>
> On Aug 2, 2007, at 21:06 , David Mark Weiss wrote:
>
>> Your right, I just grabbed an email, responded to it, and changed
>> the subject and body.
>>
>> I am happy to start a new thread next time, but may I ask where
>> that shows up?
>
> in threaded mail clients.

And in threaded mailing list archives, such as online.

Michael G.
grzm seespotcode net
Jeremy H. (Guest)
on 2007-08-05 04:26
(Received via mailing list)
On 2007-08-04, Michael G. <removed_email_address@domain.invalid> wrote:
> And in threaded mailing list archives, such as online.
And threaded newsreaders, such as slrn (which I'm using to post this).

Jeremy H.
Erik V. (Guest)
on 2007-08-05 11:38
(Received via mailing list)
> I am happy to start a new thread next time, but may I ask where that
> shows up?

http://groups.google.com/group/ruby-talk-google/br...

You see? 1 thread, and 3, no, wait, 4 subjects! And at least one of
the posts has 2 questions. It's a good habit to ask one question per
thread. (To avoid forking.)

gegroet,
Erik V. - http://www.erikveen.dds.nl/
This topic is locked and can not be replied to.