31 May 2009, 18:55
Generic-user-small

Ken Burgett (20 posts)

I ran the test program pp_login.rb and got the following error:

$ ruby pp_login.rb keburgett@gmail.com c0st8n08 pp_login.rb:17: undefined method `text’ for # (NoMethodError)

Line 17 of pp_login.rb is: page = agent.click page.links.text(‘Login’)

I am using mechanize 0.9.2

31 May 2009, 20:20
Maik_schmidt_avatar2_pragsmall

Maik Schmidt (113 posts)

Hi Ken!

The API of WWW::Mechanize has changed since the book has been published. To make the sample program work with version 0.9.2 it has to look as follows:

1 require ‘rubygems’ 2 require ‘logger’ 3 require ‘mechanize’ 4 5 agent = WWW::Mechanize.new { |a| a.log = Logger.new(‘scrape.log’) } 6 agent.user_agent_alias = ‘Mac Safari’ 7 page = agent.get(‘http://www.pragprog.com’) 8 page = agent.click page.links.select { |l| l.text =~ /Login/ }.first # Change! 9 10 login_form = page.forms.first 11 login_form.email = ARGV[0] 12 login_form.password = ARGV[1] 13 agent.log.debug “Logging in with email address #{ARGV[0]}.” 14 15 login_form.checkbox_with(:name => ‘remember_me’).check # Change! 16 page = agent.submit(login_form, login_form.buttons.first) 17 18 page.links.each { |link| puts link.text if link.text =~ /Ruby|Rails/ } 19 agent.click page.links.select { |l| l.text =~ /Log Out/ }.first # Change!

I had to change lines 8, 15, and 19. The rest of the program stays the same.

If you still run into any problems, do not hesitate to ask.

Cheers,

Maik

05 Jun 2009, 15:58
Generic-user-small

Ken Burgett (20 posts)

Hi Maik,

Thanks for the correction. It must be a challenge to keep up with all the changes in the gems and plugins you reference in the book. It is appreciated.

I am building an app that uses stomp, mechanize, ngrams, realrand, daemons, and of course, Rails. I am adding one piece at a time and building it out slowly.

I plan to create a plugin so that ActiveMQ messages can be delivered directly into a rails app via a RESTful file upload submitted to the app from a daemon-based subscriber. I am calling this project “RESTful Message Beans”, since it operates in a manner similar to JMS and EJBs.

09 Jun 2009, 05:43
Maik_schmidt_avatar2_pragsmall

Maik Schmidt (113 posts)

Hi Ken,

That’s sounds like a really interesting projects. If you are planning to release it as an Open Source project, it’d be great, if you’d post a link to it here.

Cheers,

Maik

23 Jun 2009, 18:09
Generic-user-small

Ken Burgett (20 posts)

Hi Maik,

I have a working version of my RESTful-Message-Beans app. So far, I have leveraged code and gems from Recipes 5, 31, 32, 33, 37, and 44. I am in the process of switching from WWW::Mechanize over to rufus-verbs to handle the delivery aspect of the daemon, and that will come in time. Please see http://github.com/explainer/RESTful-Message-Beans/tree/master for the source code. The accompanying wiki has installation instructions.

24 Jul 2009, 15:58
Generic-user-small

Ken Burgett (20 posts)

Hi Maik,

I have refactored my RESTful-Message-Beans github project into two projects.

I created a gem called ‘rmb-rails’:http://github.com/explainer/rmb-rails/tree/master (explainer-rmb-rails on github) and have revised the rails app named RESTful-Message-Beans to use the gem.

The refactoring was very instructive, a lot of code melted away.

30 Jul 2009, 06:20
Maik_schmidt_avatar2_pragsmall

Maik Schmidt (113 posts)

Hi Ken!

Sorry for my late answer, but I have been very busy in the last weeks, so I did not have time to have a closer look at rmb-rails.

It looks very interesting and I’d like to know if you are already using it in a real-world project?

Cheers

Maik

  You must be logged in to comment