Hpricot and Sandbox for Win32 #
Mauricio checked in some Rakefiles for cross-compiling to win32, so I’ve got some win32 gems for Hpricot and the (FF)Sandbox. The majority of you can now:
gem install hpricot --source code.whytheluckystiff.net gem install sandbox --source code.whytheluckystiff.net
THE SANDBOX ONE IS COMPILED FOR 1.8.4 SO IT HAS TOTALLY GOT HOLES. And yet, fun can still be had I’m sure.
As for cross-compiling, I’m using mingw on FreeBSD. Here’s how:
cd /usr/ports/devel/mingw32-gcc sudo make install cd ~/sand wget http://ftp.ruby-lang.org/pub/ruby/binaries/mingw/1.8/ruby-1.8.4-i386-mingw32.tar.gz mv usr/local RUBY-1_8_4-MINGW32 rm -rf usr cd ~/dev svn co https://code.whytheluckystiff.net/svn/sandbox/trunk sandbox cd sandbox export MINGW32_RUBY=/home/why/sand/RUBY-1_8_4-MINGW32 export MINGW32_PREFIX=mingw32 rake rubygems_win32
I mean that’s alot better than putting together a VM and trying to track down a decent free Microsoft compiler. A couple weeks ago, I spent six hours on it and made no progress.
RSL
Yay! Hpricot totally rocks the Windows. Thanks for the speedy work on that!
hoyhoy
Asztal
Is there something wrong with Microsoft’s own C++ compiler (on Windows, that is, of course)? The toolkit is free as in beer.
mfp
More details about the cross-compilation magic in the Rakefile, and here .
mfp
Asztal: First of all, it runs on win32 only :-) Second, and most importantly: it’s not binary-compatible with the VC6 ruby build (I read now that MinGW isn’t fully either, but it works for all but a few extensions).
hoyhoy
Does Hpricot not support [] in an Xpath? I know I can index the elements from the resultant ruby array following a search, but I have to believe it could be faster using an internal lookup to an internal C data structure via an Xpath string.
hoyhoy
why
hoyhoy: Thankyou for that. Is fixed in SVN , the feed parses fine.
The thing is: I’m not keeping any internal C data structures here. It’s usually the parsing that really slows you down, not the data structures. It would be faster to do it all in C, but then it would be something that I couldn’t possibly finish.
hoyhoy
That makes supporting [] in XPath kind of moot. I’ve often considered making my own whizbang XML parser gem using flex/bison or spirit. Unfortunately, after having that kind of thought, I usually sit down and eat a sandwich and it goes away.
why
Haha, oh yeah dreaming about scanners and parsers is really fun, it’s too bad the reality is so vomitously bleak.
Matt Todd
Well, maybe we should make that not so. :) (HAH)
Dr Nic
I am the proud owner of a 2006 Win32 Sandbox, Unsafe Edition, with leather seats.
hoyhoy
hoyhoy
hoyhoy
hoyhoy
Line 102 in traverse.rb, but you knew that.
capn_midnight
... it’s not binary-compatible with the VC6 ruby build…
Dear God, why do people still use VC6 ?
FlashHater
Capn: Because it’s become a de facto standard, and tends to have good windows compatibility.
Adam
hoyhoy: You have a sneaky smiley man in your regexp! :-]
Michael
this is great! but i have a little problem: is v0.3 missing something? Container::Trav.filter calls to_node.subst_subnode on line 402, but that doesn’t seem to exist?
capn_midnight
FlashHater: However, VC7 has the same perfect level of windows compatibility AND is one of the most standards compliant compilers on the market. Essentially, with the availability of VC7 , there is no reason to use VC6 .
hpricot_newbie
So am I using hpricot wrong or is this a bug?
doc = Hpricot(open(“http://usgenweb.org/”)) puts (doc/:a).length # => 15 but it should be 66
also the follow errors out
doc.to_s
bearik
Hpricot doesn’t support this:
... does it?
I’m trying to fetch the 3rd td in each tr.
Boris K.
bearik, this should work
doc.search("//table/tr/td")[3]
Boris K.
why
There’s still some unimplemented XPath. Refer to the supported CSS selectors for other ideas.