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.
A2a23083ac608d6238dfb7cff20acc9b?d=identicon&s=25 Ruby Rubyruby (rubyruby)
on 2007-08-02 20: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
A2a23083ac608d6238dfb7cff20acc9b?d=identicon&s=25 Ruby Rubyruby (rubyruby)
on 2007-08-02 23:33
/bump!
669b7046f02e5dfc4bda4421f1069731?d=identicon&s=25 Alex Fenton (Guest)
on 2007-08-03 00:20
(Received via mailing list)
Ruby Rubyruby 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
807270f56f26ad90755eef71f2c228fe?d=identicon&s=25 Alex Gutteridge (Guest)
on 2007-08-03 02:24
(Received via mailing list)
On 3 Aug 2007, at 03:06, Ruby Rubyruby 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 Gutteridge

Bioinformatics Center
Kyoto University
899b0c977b12d48452bd468bfd449d21?d=identicon&s=25 David Mark Weiss (Guest)
on 2007-08-03 02:39
(Received via mailing list)
Hi,

New Ruby 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
899b0c977b12d48452bd468bfd449d21?d=identicon&s=25 David Mark Weiss (Guest)
on 2007-08-03 02: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
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2007-08-03 03: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.
E31f2af2c1f5cde7eff16cafe6fc2d39?d=identicon&s=25 Mark Gallop (Guest)
on 2007-08-03 03: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
899b0c977b12d48452bd468bfd449d21?d=identicon&s=25 David Mark Weiss (Guest)
on 2007-08-03 06: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
899b0c977b12d48452bd468bfd449d21?d=identicon&s=25 David Mark Weiss (Guest)
on 2007-08-03 06: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
E31f2af2c1f5cde7eff16cafe6fc2d39?d=identicon&s=25 Mark Gallop (Guest)
on 2007-08-03 07: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
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2007-08-04 20: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.
Ae82cad40a0caca9c932d45c7a9eb3cd?d=identicon&s=25 Michael Glaesemann (Guest)
on 2007-08-04 22:27
(Received via mailing list)
On Aug 4, 2007, at 13:20 , Ryan Davis 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 Glaesemann
grzm seespotcode net
15f985dc1d6a150767736a0c65e9ef35?d=identicon&s=25 Jeremy Henty (Guest)
on 2007-08-05 02:26
(Received via mailing list)
On 2007-08-04, Michael Glaesemann <grzm@seespotcode.net> wrote:
> And in threaded mailing list archives, such as online.
And threaded newsreaders, such as slrn (which I'm using to post this).

Jeremy Henty
6b0967f63d03e99b6c07a3f5ed224c77?d=identicon&s=25 Erik Veenstra (Guest)
on 2007-08-05 09: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.