[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Ruby Tidy

Mark Dodwell

12/19/2006 10:53:00 AM

Hi All,

I'm trying to get the Ruby Tidy gem installed but I am having problems.
I downloaded and installed HTML Tidy from source first, then installed
Ruby Tidy from the gem:

gem install tidy

And it reports that it went ok:

Bulk updating Gem source index for: http://gems.rub...
irbSuccessfully installed tidy-1.1.2
Installing ri documentation for tidy-1.1.2...
Installing RDoc documentation for tidy-1.1.2...

But when I issue 'require 'tidy'' (in my rails 'script/console') it
reports false, as if it isn't installed.

Any ideas? I'm on OS X 10.4.8 on my workstation and FC5 on my server.

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

10 Answers

Peter Szinek

12/19/2006 11:00:00 AM

0

Hola,
> But when I issue 'require 'tidy'' (in my rails 'script/console') it
> reports false, as if it isn't installed.

Are you sure you require 'rubygems' before requiring 'tidy'?

Cheers,
Peter

__
http://www.rubyra...


Chris Carter

12/19/2006 12:54:00 PM

0

It was required already then. If you are requireing something for the
first time in that interpreter, it returns true, if you are doing it
for the second+ time, it returns false, if it wasn't installed, it
would result in a load error

On 12/19/06, Mark Dodwell <seo@mkdynamic.co.uk> wrote:
> Hi All,
>
> I'm trying to get the Ruby Tidy gem installed but I am having problems.
> I downloaded and installed HTML Tidy from source first, then installed
> Ruby Tidy from the gem:
>
> gem install tidy
>
> And it reports that it went ok:
>
> Bulk updating Gem source index for: http://gems.rub...
> irbSuccessfully installed tidy-1.1.2
> Installing ri documentation for tidy-1.1.2...
> Installing RDoc documentation for tidy-1.1.2...
>
> But when I issue 'require 'tidy'' (in my rails 'script/console') it
> reports false, as if it isn't installed.
>
> Any ideas? I'm on OS X 10.4.8 on my workstation and FC5 on my server.
>
> --
> Posted via http://www.ruby-....
>
>


--
Chris Carter
concentrationstudios.com
brynmawrcs.com

Greg Donald

12/19/2006 4:21:00 PM

0

On 12/19/06, Mark Dodwell <seo@mkdynamic.co.uk> wrote:
> But when I issue 'require 'tidy'' (in my rails 'script/console') it
> reports false, as if it isn't installed.

Don't you have to have libtidy installed in addition to the gem?


--
Greg Donald
http://des...

Andrew Stewart

12/20/2006 9:30:00 AM

0


On 19 Dec 2006, at 16:21, Greg Donald wrote:

> On 12/19/06, Mark Dodwell <seo@mkdynamic.co.uk> wrote:
>> But when I issue 'require 'tidy'' (in my rails 'script/console') it
>> reports false, as if it isn't installed.
>
> Don't you have to have libtidy installed in addition to the gem?

Some systems have it already installed. For example, on my OS X it's
here:

/usr/lib/libtidy.dylib

Regards,
Andy Stewart

Ross Bamford

12/20/2006 1:29:00 PM

0

On Tue, 19 Dec 2006 16:21:27 -0000, Greg Donald <gdonald@gmail.com> wrote:

> On 12/19/06, Mark Dodwell <seo@mkdynamic.co.uk> wrote:
>> But when I issue 'require 'tidy'' (in my rails 'script/console') it
>> reports false, as if it isn't installed.
>
> Don't you have to have libtidy installed in addition to the gem?
>

Yes, but that would have caused a failure at the 'Building native
extensions' phase of the gem install?

The false result the OP is seeing means that either tidy was already
required, or an (old?) gems bug has reared it's head. Generally, I find it
best to ignore the return value from Kernel#require, since it will throw a
LoadError if the library cannot be loaded. In this case, I suspect the
library is loading just fine, despite the 'false' return from require.

--
Ross Bamford - rosco@roscopeco.remove.co.uk

Suraj Kurapati

12/20/2006 5:26:00 PM

0

Mark Dodwell wrote:
>
> gem install tidy
>
> And it reports that it went ok:
>
> But when I issue 'require 'tidy'' (in my rails 'script/console') it
> reports false, as if it isn't installed.

Try loading rubygems first:

require 'rubygems'
require 'tidy' # or: require_gem 'tidy'

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

Peter Szinek

12/20/2006 6:42:00 PM

0

> Try loading rubygems first:
>
> require 'rubygems'
> require 'tidy' # or: require_gem 'tidy'

As someone pointed out earlier, that would throw a LoadError - and
anyway, Rails has dependency on rubygems so this should not be the
problem...

Peter

__
http://www.rubyra...

David Vallner

12/21/2006 12:03:00 AM

0

Suraj Kurapati wrote:
> require 'tidy' # or: require_gem 'tidy'
>

require_gem 'tidy' is not supposed to do anything. If I got the threads
in which that occured right, require_gem only specifies the preferred
version of a gem, you still have to require files from inside them.

David Vallner

Arie Kusuma Atmaja

12/29/2006 6:56:00 AM

0

Mark Dodwell wrote:
> Hi All,
>
> I'm trying to get the Ruby Tidy gem installed but I am having problems.
> I downloaded and installed HTML Tidy from source first, then installed
> Ruby Tidy from the gem:
>
> gem install tidy
>
> And it reports that it went ok:
>
> Bulk updating Gem source index for: http://gems.rub...
> irbSuccessfully installed tidy-1.1.2
> Installing ri documentation for tidy-1.1.2...
> Installing RDoc documentation for tidy-1.1.2...
>
> But when I issue 'require 'tidy'' (in my rails 'script/console') it
> reports false, as if it isn't installed.
>
> Any ideas? I'm on OS X 10.4.8 on my workstation and FC5 on my server.
>

Hi Mark,
I'm on Mac OS X 10.4.8 as well (Powerbook). and i've got no problems
with Tidy here

sayang:~/mo/tau/direktori/gw/aja/lu/huh/hwek arie$ irb
irb(main):001:0> require 'tidy'
=> true
irb(main):004:0> Tidy.path = '/usr/lib/libtidy.dylib'
=> "/usr/lib/libtidy.dylib"
irb(main):005:0> html = '<html><title>title</title>Body akeh pokoke
isine merene mrono <!-- komentar --> das des dos <strong>i</strong>\ntes
tes tes<br />\n\n<br /><i>adfdfdfdfd</i></html>'
=> "<html><title>title</title>Body akeh pokoke isine merene mrono <!--
komentar --> das des dos <strong>i</strong>\\ntes tes tes<br />\\n\\n<br
/><i>adfdfdfdfd</i></html>"
irb(main):006:0> xml = Tidy.open(:show_warnings => true) do |tidy|
irb(main):007:1* tidy.options.output_xml = true
irb(main):008:1> puts tidy.options.show_warnings
irb(main):009:1> xml = tidy.clean(html)
irb(main):010:1> puts tidy.errors
irb(main):011:1> puts tidy.diagnostics
irb(main):012:1> xml
irb(main):013:1> end
true
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 9 - Warning: plain text isn't allowed in <head> elements
Info: Document content looks like XHTML 1.0 Transitional
2 warnings, 0 errors were found!

=> "<html>\n<head>\n<meta name="generator"\ncontent="HTML Tidy for Mac
OS X (vers 1st December 2004), see www.w3.org"
/>\n<title>title</title>\n</head>\n<body>Body akeh pokoke isine merene
mrono \n<!-- komentar --> das des dos \n<strong>i</strong>\\ntes tes
tes\n<br />\\n\\n\n<br />\n<i>adfdfdfdfd</i></body>\n</html>\n"
irb(main):014:0> puts xml
<html>
<head>
<meta name="generator"
content="HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org" />
<title>title</title>
</head>
<body>Body akeh pokoke isine merene mrono
<!-- komentar --> das des dos
<strong>i</strong>\ntes tes tes
<br />\n\n
<br />
<i>adfdfdfdfd</i></body>
</html>
=> nil
irb(main):015:0>


--
Arie Kusuma Atmaja A.K.A Arie A.K.A ariekeren / YM! = riyari3
http://ariekusumaatmaja.wor... http://groups.yahoo.com/grou...
http://groups-beta.google.com/g... # nihongo o benkyoshimashou
http://groups-beta.google.com/g... # parlons francais
Dicari wanita bule prancis/jepang cantik penuh gairah,pinter masak &
mijit.Buat Arie



Wim Vander Schelden

12/29/2006 9:26:00 AM

0

Arie Kusuma Atmaja wrote:
> Mark Dodwell wrote:
>> Hi All,
>>
>> I'm trying to get the Ruby Tidy gem installed but I am having problems.
>> I downloaded and installed HTML Tidy from source first, then installed
>> Ruby Tidy from the gem:
>>
>> gem install tidy
>>
>> And it reports that it went ok:
>>
>> Bulk updating Gem source index for: http://gems.rub...
>> irbSuccessfully installed tidy-1.1.2
>> Installing ri documentation for tidy-1.1.2...
>> Installing RDoc documentation for tidy-1.1.2...
>>
>> But when I issue 'require 'tidy'' (in my rails 'script/console') it
>> reports false, as if it isn't installed.
>>
>> Any ideas? I'm on OS X 10.4.8 on my workstation and FC5 on my server.
>>
>
> Hi Mark,
> I'm on Mac OS X 10.4.8 as well (Powerbook). and i've got no problems
> with Tidy here
>
> sayang:~/mo/tau/direktori/gw/aja/lu/huh/hwek arie$ irb
> irb(main):001:0> require 'tidy'
> => true
> irb(main):004:0> Tidy.path = '/usr/lib/libtidy.dylib'
> => "/usr/lib/libtidy.dylib"
> irb(main):005:0> html = '<html><title>title</title>Body akeh pokoke
> isine merene mrono <!-- komentar --> das des dos <strong>i</strong>\ntes
> tes tes<br />\n\n<br /><i>adfdfdfdfd</i></html>'
> => "<html><title>title</title>Body akeh pokoke isine merene mrono <!--
> komentar --> das des dos <strong>i</strong>\\ntes tes tes<br />\\n\\n<br
> /><i>adfdfdfdfd</i></html>"
> irb(main):006:0> xml = Tidy.open(:show_warnings => true) do |tidy|
> irb(main):007:1* tidy.options.output_xml = true
> irb(main):008:1> puts tidy.options.show_warnings
> irb(main):009:1> xml = tidy.clean(html)
> irb(main):010:1> puts tidy.errors
> irb(main):011:1> puts tidy.diagnostics
> irb(main):012:1> xml
> irb(main):013:1> end
> true
> line 1 column 1 - Warning: missing <!DOCTYPE> declaration
> line 1 column 9 - Warning: plain text isn't allowed in <head> elements
> Info: Document content looks like XHTML 1.0 Transitional
> 2 warnings, 0 errors were found!
>
> => "<html>\n<head>\n<meta name="generator"\ncontent="HTML Tidy for Mac
> OS X (vers 1st December 2004), see www.w3.org"
> />\n<title>title</title>\n</head>\n<body>Body akeh pokoke isine merene
> mrono \n<!-- komentar --> das des dos \n<strong>i</strong>\\ntes tes
> tes\n<br />\\n\\n\n<br />\n<i>adfdfdfdfd</i></body>\n</html>\n"
> irb(main):014:0> puts xml
> <html>
> <head>
> <meta name="generator"
> content="HTML Tidy for Mac OS X (vers 1st December 2004), see
> www.w3.org" />
> <title>title</title>
> </head>
> <body>Body akeh pokoke isine merene mrono
> <!-- komentar --> das des dos
> <strong>i</strong>\ntes tes tes
> <br />\n\n
> <br />
> <i>adfdfdfdfd</i></body>
> </html>
> => nil
> irb(main):015:0>
>
>
I've had similar problems before, but require doesn't return false on an
error. It returns false if the file has been included before and there
is not loaded again. When an error occurs, require will throw an Error.
Try and use some of the methods from Tidy and see if they work.

Kind regards,

Wim

--
Wim Vander Schelden
Bachelor Computer Science, University Ghent

http://nanob...
My weblog, powered by Ruby and BSD licensed.