Archive

Posts Tagged ‘nokogiri’

Transforming CSS selector to an XPath query

September 9th, 2011 Serabe No comments

So. Easy.

[ruby]require ‘nokogiri’; Nokogiri::CSS.xpath_for(css_selector)[/ruby]

article clipper Transforming CSS selector to an XPath query
 
share save 171 16 Transforming CSS selector to an XPath query
Categories: Programming, Ruby Tags: , ,

Helping Nokogiri. Take II

December 31st, 2009 Serabe 8 comments
4218563829 bf9f5519dd m Helping Nokogiri. Take II
Nokogiri and Pizza, what else can you ask for?

Ok. My fault. Now, let’s go get some work done.

First, if you haven’t done it, read the previous post about helping nokogiri and forgot about the script and memory leak. It seems that there are more important issues, so let’s fix them first. First run jruby test/test_jruby.rb from Nokogiri root. You’ll see a lot of errors (27 by now) and failures (14). Choose one, and get it green. After that, send me a pull request.

Ok. That sounds simple, but what if  the number of errors or failures raises? The rule I use is simple: keep the sum of both numbers going down and having a failure is better than having an error.

On the other hand, if you take a look at test/test_jruby.rb, you’ll see that not every test is in there. There is a reason for that. Even keeping the number of test low, you get a lot of errors/failures. If that annoys me with just 50 failures, imagine if I had a couple of hundreds errors. When all is right, I’ll add some more to keep the fun on.

Photo by Paul Johnston.

article clipper Helping Nokogiri. Take II
 
share save 171 16 Helping Nokogiri. Take II
Categories: Java, JRuby, Programming, Ruby Tags: ,

Do you wanna help us with pure-Java Nokogiri?

December 1st, 2009 Serabe No comments

First things first, if you wanna help, you’ll need to clone the git repo. Just:

git clone git://github.com/tenderlove/nokogiri.git
cd nokogiri
git checkout --track -b java origin/java

Install the dependencies. Just:

rake install:deps

Because it uses some native libraries, you’ll need to do that with MRI. Finally, you’ll need to generate some files, just run jruby -S rake java:spec. For having a hprof file, you’ll need to run this script with the following command:

jr -J-Xmx32m -J-XX:+HeapDumpOnOutOfMemoryError nokogiri_doc_frag.rb

-J-Xmx32m limits the heap space to 32 Mb, and the other options makes the JVM to write a hprof file when a OutOfMemoryError is thrown. After that, you can inspect that file with the profiler you can find in NetBeans.

In next post, I’ll comment where I think the problem is.

article clipper Do you wanna help us with pure Java Nokogiri?
 
share save 171 16 Do you wanna help us with pure Java Nokogiri?
Categories: General, Java, JRuby, Programming, Ruby Tags: , ,

Final Status Update (or How to get Nokogiri in JRuby without FFI)

August 26th, 2009 Serabe No comments

Hi, all,

sorry for the silence all these months, but I’ve been working hard on Nokogiri. First things first, it is not complete yet. Anyway, I’m gonna tell you how to build a gem and start working with it.

3848826571 e2da6c85ed m Final Status Update (or How to get Nokogiri in JRuby without FFI)
cc Final Status Update (or How to get Nokogiri in JRuby without FFI) photo credit: Matthew Byrne

Clone the repo and checkout the java branch.

git clone git://github.com/tenderlove/nokogiri.git
git checkout --track -b java origin/java

Next step: build the gem. As easy as jruby -S rake java:gem. Maybe, you need to install rexical and racc. jruby -S rake install:deps would do.

Finally, you have a gem in the pkg folder. Install it, and you’re done.

Updated: Take a look here if you wanna help.

article clipper Final Status Update (or How to get Nokogiri in JRuby without FFI)
 
share save 171 16 Final Status Update (or How to get Nokogiri in JRuby without FFI)
Categories: Java, JRuby, Programming, Ruby Tags: , , ,

Status Update: RMagick4J, Nokogiri, ruby2java and a possible MagickWand4J

June 6th, 2009 Serabe No comments

It’s been long time since last status update, but there are some things to tell, so here I am.

Thankfully, this year I’m a GSoC student again (and my mentor is Tom too). The main part of my project would be porting Nokogiri to JRuby, so I haven’t code for RMagick for a while now.

Let’s start with the status update then.

Nokogiri

I’ve been working on Nokogiri for a while. I forked Charles’ repo in Github, and I’ve implemented some cool features. For example, today I got my XML::Reader implementation to pass all tests in test_reader.rb. I hope I’ll be able to make a release this month (cross your fingers).

On the other hand, I got my first patch accepted in Nokogiri’s main repo.

RMagick4J

Not to much work done here, sorry. I haven’t code anything for a while now. Migrating from mercurial to git is already planned, but before that I would like to do a few commits more. Anyway, I’m quite happy with this project. Some people are using it and reporting bugs (in the end, those little things are all that matters). What else can I ask for?

Please, if you find a bug, report it here.

MagickWand

Tim Hunter (creator of RMagick) released MagickWand recently. I’ve been considering porting it to JRuby too. I have to take a deeper look at the C code, but, by now, I think it could be a good way to lead RMagick4J development. If finally I port it, I will split RMagick4J in two projects (Magick4J and RMagick4J). This way, MagickWand4J and RMagick4J would share the same java codebase, as MagickWand and RMagick share ImageMagick.

ruby2java

Take a look here. Awesome, isn’t it? And as soon as I have some time to work on it, siesta will be out too…

P.D. By the way, no more personal stuff in this blog. That stuff is now here, and only in Spanish (sorry about that).

article clipper Status Update: RMagick4J, Nokogiri, ruby2java and a possible MagickWand4J
 
share save 171 16 Status Update: RMagick4J, Nokogiri, ruby2java and a possible MagickWand4J