[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

cgi vs. fcgi question

Tom Allison

7/29/2006 11:26:00 AM

Under CGI I can create a cgi object like:

cgi = CGI.new("html4")
and have methods available to me like .head, .body, and so on.

Under FCGI the cgi is created for me.
I don't see any way to make any CGI methods available to me so that I
can write an FCGI script like:

FCGI.each_cgi do |cgi|
cgi.out{
cgi.html {
cgi.head{ "\n" + cgi.title("This is a Test"} } +
cgi.body{ "\n" + "<p>This is indeed a test..</p>"}
}
}
end

it complains that .html is unkown.
I can't seem to find any class methods to set this up.

Am I really relegated to writing everything under FCGI as just cgi.out{ } ?

9 Answers

Matt Todd

7/29/2006 5:43:00 PM

0

Or you could use another library, such as Builder or Markaby.

Tom Allison

7/29/2006 8:41:00 PM

0

Matt Todd wrote:
> Or you could use another library, such as Builder or Markaby.
>
never heard of them. How do I install these?

Tim Hunter

7/29/2006 8:46:00 PM

0

Tom Allison wrote:
> Matt Todd wrote:
>> Or you could use another library, such as Builder or Markaby.
>>
> never heard of them. How do I install these?
>
You are in for a treat. http::rubyforge.org is the home of both
libraries, along with 100's of other Ruby projects. Check it out!

Matt Todd

7/29/2006 8:49:00 PM

0

Builder comes with Rails, so I don't exactly know, but I think it's just:

[sudo] gem install builder

But I could be wrong. To install Markaby, you'd:

[sudo] gem install markaby

Documentation for Markaby can be found here:
http://code.whytheluckystiff.net/ma...

Cheers,

M.T.

Tom Allison

7/30/2006 12:02:00 AM

0

Timothy Hunter wrote:
> Tom Allison wrote:
>> Matt Todd wrote:
>>> Or you could use another library, such as Builder or Markaby.
>>>
>> never heard of them. How do I install these?
>>
> You are in for a treat. http::rubyforge.org is the home of both
> libraries, along with 100's of other Ruby projects. Check it out!
>

Looks like CPAN.org to me.

Um... Not to sound utterly retarded, but how does it work?

If I am supposed to install the modules using gems, I don't have gems
installed either. So do I need to start there or what?

I'm literally at step 0.
I'm also curious if this has a better uninstall process than CPAN (which
has no uninstall process)

James Britt

7/30/2006 1:56:00 AM

0

Tom Allison wrote:

>
> I'm literally at step 0.

Go to RubyForge and locate the rubygems library. There's a search field
on the main page.

Download rubygems, latest version. Extract and install as per the
README or INSTALL file that I'm pretty sure is included.

You may want to be root so that the library and scripts are placed
correctly.


You can now run, for example:

gem install markaby

> I'm also curious if this has a better uninstall process than CPAN (which
> has no uninstall process)
>

gem uninstall markaby

If the gem is needed by other gems you should get warnings and an option
to stop the uninstalling.

There are assorted options you can pass when installing, upgrading, and
such, so try running

gem help

to learn more. And ask questions here, too, if you try but cannot
figure something out.


--
James Britt

"I can see them saying something like 'OMG Three Wizards Awesome'"
- billinboston, on reddit.com

Tom Allison

7/30/2006 12:21:00 PM

0

James Britt wrote:
> Tom Allison wrote:
>
>>
>> I'm literally at step 0.

> gem help
>
> to learn more. And ask questions here, too, if you try but cannot
> figure something out.
>
>

I started playing with this and ran into a lack of PATH (I guess).
require doesn't find the library I just installed.
ri doesn't either, but someone mentioned gemri instead.

I guess this puts me at step 0.0.1?

James Britt

7/30/2006 7:52:00 PM

0

Tom Allison wrote:
> James Britt wrote:
>
>> Tom Allison wrote:
>>
>>>
>>> I'm literally at step 0.
>
>
>> gem help
>>
>> to learn more. And ask questions here, too, if you try but cannot
>> figure something out.
>>
>>
>
> I started playing with this and ran into a lack of PATH (I guess).
> require doesn't find the library I just installed.
> ri doesn't either, but someone mentioned gemri instead.

Does your code include

require 'rubygems'

before you try to load files installed as gems?

You can also define that on the command line:

ruby -rubygems my_app.rb

or add it to your RUBYOPT environment variable

e.g.

RUBYOPT=rubygems

But one why or another you need to tell Ruby that it should load the
rubygems library first, and that then takes care of looking for gem files.

>
> I guess this puts me at step 0.0.1?
>
>

Oh, I say at least 0.1.



--
James Britt

"I was born not knowing and have had only a little
time to change that here and there."
- Richard P. Feynman

Tim Hunter

7/30/2006 8:10:00 PM

0

Tom Allison wrote:
> James Britt wrote:
>> Tom Allison wrote:
>>
>>>
>>> I'm literally at step 0.
>
>> gem help
>>
>> to learn more. And ask questions here, too, if you try but cannot
>> figure something out.
>>
>>
>
> I started playing with this and ran into a lack of PATH (I guess).
> require doesn't find the library I just installed.
> ri doesn't either, but someone mentioned gemri instead.
>
> I guess this puts me at step 0.0.1?
>
You don't have to stumble around in the dark while waiting for some kind
soul here to guide you. RubyGems has good user doc, available from the
RubyGems project page at the link marked "Project Home Page". Here's the
link: http://docs.rub.... (This link is also the #1 result if you
Google for "rubygems".)

Here's something that a lot of newcomers miss: RubyGems is not only a
way to install Ruby libraries, it's also the mechanism for using these
libraries after they're installed. Look at "Chapter 3.4 Post-install --
Setting Up the RubyGems Environment" for the details.