RubyUW: Ruby Interface to MyUW
RubyUW is NOT supported in any way by the University of Washington
RubyUW provides a programmable interface to MyUW, University of Washington's student web portal.
Why?
Proof of Concept.
It's a fun project and it was really a proof of concept more than anything. I don't plan on officially supporting this library or promising updates in case any features break. Its a good example for any Ruby developer on the uses of mechanize and the ability to scrape content or simulate a human at a browser.
It is also a useful library to create MyUW automation tools with. I do not support this.
How does it work?
RubyUW functions by emulating a human in an actual browser. It hunts down buttons to click, fields to fill in, etc. It is programmed using the Ruby Mechanize library to achieve this level of human simulation.
Of course this also means that even minor tweaks to the MyUW layout could potentially "break" the RubyUW library.
Installing
# Install the gem
sudo gem sources -a http://gems.github.com
sudo gem install mitchellh-rubyuw
Using RubyUW
It's easy to get started with RubyUW. Officially RDoc documentation is planned but is not up yet. Sorry!
The following is a quick and simple example:
require 'myuw'
myuw = MyUW.new
myuw.login("netid", "password") or raise("Login Failed!")
# Get SLN information
sln_info = myuw.sln(14153)
# Get user course schedule
schedule = myuw.schedule.schedule
Testing
RubyUW includes a comprehensive test suite included both live and mocked testing. Mocked testing uses "mocked" HTML pages and a lot of object stubbing to simulate a real environment and to force certain events to occur (such as strange HTML in a request) in order to completely test the library. Mock testing can be run straight "out of the box" via a rake task:
rake test:run_mock
RubyUW also includes "live" testing which uses a real UW NetID and password to conduct live tests. To run this, see test/password.rb.sample and modify it to include your credentials, then save it as password.rb. Following this, run another rake task:
rake test:run_live
Note: Live testing is very very slow. On my machine with the current suite it takes about a minute to run all the tests (though this is highly dependent on your internet connection).
Note: Also, live testing DOES NOT test registration since that actually affects your MyUW account in a significant way. To test registration, run the registration test directly:
cd test/live && ruby registration_test.rb