agoragames / bnet_scraper

A Nokogiri-based scraper of Battle.net profiles. Currently this only includes Starcraft2.
MIT License
22 stars 7 forks source link

Improved Profile API #10

Closed cadwallion closed 11 years ago

cadwallion commented 11 years ago

Instead of the previous Hash-based scraper outputs, this adds the concept of models and a root object, with scrapers filling in the gaps.

To scrape a profile, you still start with an instance of ProfileScraper. Calling ProfileScraper#scrape returns a BnetScraper::Starcraft2::Profile object now instead of a Hash. In addition to methods instead of hash keys, an additional piece of functionality is the achievements, match_history, and leagues methods. Each of these methods returns an array, however on the first call to these methods it will setup the appropriate scraper object, scrape, and fill in the gaps.

Drilling down even further, for every League object there contains information that can be accessed without scraping beyond the Profile. If you attempt to access additional information, the League object will instantiate a BnetScraper::Starcraft2::LeagueScraper object, grab league information, and map that onto itself.

This fixes #9 although full_scrape still exists, it just eager-loads these scrapers.