[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Deployable project with C source code

Ruby Rubyruby

8/2/2007 6:06:00 PM

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
--
Posted via http://www.ruby-....

13 Answers

Ruby Rubyruby

8/2/2007 9:33:00 PM

0

/bump!
--
Posted via http://www.ruby-....

Alex Fenton

8/2/2007 10:15:00 PM

0

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/...
[2] http://www.erikveen.dds.nl/tar2rubyscript/...
[3] http://exerb.sourceforge.jp/ind...

Alex Gutteridge

8/3/2007 12:23:00 AM

0

On 3 Aug 2007, at 03:06, 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. 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.

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....).

Alex Gutteridge

Bioinformatics Center
Kyoto University



David Mark Weiss

8/3/2007 12:50:00 AM

0

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.bl...



On Aug 2, 2007, at 5:38 PM, David Mark Weiss wrote:

> 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.bl...
>


Ryan Davis

8/3/2007 1:53:00 AM

0


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 Gallop

8/3/2007 1:57:00 AM

0

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 wrote:
> 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.bl...
>
>


David Mark Weiss

8/3/2007 4:07:00 AM

0

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

On Aug 2, 2007, at 6:52 PM, Ryan Davis wrote:

>
> 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.
>


David Mark Weiss

8/3/2007 4:28:00 AM

0

Mark,

I am running mySQL, innodb. 5.0.24a
I did the install found at http://hivelogic.com/narrative...
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


On Aug 2, 2007, at 6:57 PM, Mark Gallop wrote:

> 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 wrote:
>> 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.bl...
>>
>>
>
>


Mark Gallop

8/3/2007 5:27:00 AM

0

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/Ma...

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


David Mark Weiss wrote:
> Mark,
>
> I am running mySQL, innodb. 5.0.24a
> I did the install found at
> http://hivelogic.com/narrative/articles/ruby-rails-mongrel...
> 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
>
>
> On Aug 2, 2007, at 6:57 PM, Mark Gallop wrote:
>
>> 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 wrote:
>>> 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.bl...
>>>
>>>
>>
>>
>
>
>


Ryan Davis

8/4/2007 6:21:00 PM

0


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.