⚠️ Obsolete ⚠️
QuakeLive now runs fully on Steam platform, this gem is now useless (until updated)
This gem fetches (basic) publicly available data from QuakeLive site. Unfortunately currently there is no real API provided by ID so we're forced to parse html to get what we can. It will go down in flames if QL changes its internal html structure, so be prepared for that too.
The dirty job is made under
Parser module (nothing pretty there, but response from QL is not pretty as well).
It is currently used in production environment, but consider it as work in progress for you own safety.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install quakelive_api
There is a main class called
QuakeliveApi::Profile that will accept player_name (nickname from QL) as argument.
This class delegates its methods to other classes that speaks with quakelive.com. Each method call will execute a single query (using standard
Net::HTTP Ruby library), parse the response using
Nokogiri and returns the result (cached as instance variables).
profile = QuakeliveApi::Profile.new(player_name) profile.summary # instance variable of QuakeliveApi::Profile::Summary profile.statistics # instance variable of QuakeliveApi::Profile::Statistics profile.awards_milestones # instance variable of QuakeliveApi::Profile::Awards::CareerMilestones profile.awards_experience # instance variable of QuakeliveApi::Profile::Awards::Experience profile.awards_skillz # instance variable of QuakeliveApi::Profile::Awards::MadSkillz profile.awards_social # instance variable of QuakeliveApi::Profile::Awards::SocialLife profile.awards_success # instance variable of QuakeliveApi::Profile::Awards::SweetSuccess # there is also helper method called .each_award that will execute given block for all awards # Note: those classes can be used separately (the initializer argument is the same) # calling those methods may raise: # - QuakeliveApi::Error::PlayerNotFound on invalid player_name # - QuakeliveApi::Error::RequestError when ql site returns 'An Error Has Occurred' page
Methods (should be self-explanatory)
QuakeliveApi::Profile::Summary: country, nick, clan, model, memeber_since, last_game, time_played, wins, accuracy, losses, quits, frags, deaths, hits, shots, favourite, recent_awards, recent_games, recent_competitors
QuakeliveApi::Profile::Statistics- weapons, records (each is array of Struct objects)
QuakeliveApi::Profile::Awards(each kind) - earned, unearned (same as above)
- I noticed that sometimes QL site returns incomplete response for awards, that will trigger exception inside parser, unfortunately I can't quite narrow it down atm :(
- it would be great to provide support for all stats like matches, competitors, friends etc.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request