I am using http.get in a model to parse html code returned from a Oracle server. My first try was to use assertions (assert and assert_select) to test and parse the html code. But I have problems including the methods in the model. Have tried both "include" and copy/paste to get assertion methods into my model. Works as a model, but I get load errors when I am using the model from a controller. Does anyone known the correct way to get assertion methods merged into a model? I am considering replace assertions with a html parser. Is there a recommented html parser for ruby? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ok, it looks like I have to use both load and include to prevent load error when the model with assertions are used from a controller. load ''/usr/lib/ruby/1.8/test/unit/assertions.rb'' class OlapDatabaseTrans < ActiveRecord::Base include Test::Unit::Assertions ... end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Dec 23, 2009 at 1:23 AM, Jan Roslind <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am using http.get in a model to parse html code returned from a Oracle > server. > > My first try was to use assertions (assert and assert_select) to test > and parse the html code.That''s, er, interesting :-)> I am considering replace assertions with a html parser. II would think so -- take a look at http://github.com/tenderlove/nokogiri HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jan Roslind wrote:> I am using http.get in a model to parse html code returned from a Oracle > server. > > My first try was to use assertions (assert and assert_select) to test > and parse the html code. But I have problems including the methods in > the model.Why do you need assertions to parse HTML? Assertions are for tests, not generic parsing.> Have tried both "include" and copy/paste to get assertion > methods into my model. Works as a model, but I get load errors when I am > using the model from a controller.What do the errors say?> > Does anyone known the correct way to get assertion methods merged into a > model? > > I am considering replace assertions with a html parser.Good idea.> Is there a > recommented html parser for ruby?I think most people are using Nokogiri these days. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Definitely Nokogiri, maybe with Mechanize... http://joemcglynn.wordpress.com/2009/12/10/five-minute-introduction-to-nokog iri/ -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Hassan Schroeder Sent: Wednesday, December 23, 2009 8:16 AM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: Re: [Rails] html parser / assertions in a model On Wed, Dec 23, 2009 at 1:23 AM, Jan Roslind <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am using http.get in a model to parse html code returned from a Oracle > server. > > My first try was to use assertions (assert and assert_select) to test > and parse the html code.That''s, er, interesting :-)> I am considering replace assertions with a html parser. II would think so -- take a look at http://github.com/tenderlove/nokogiri HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.