gamertag 1.1.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +11 -1
  3. data/LICENSE.md +11 -0
  4. data/README.md +84 -0
  5. data/gamertag.gemspec +25 -25
  6. data/lib/faraday/response/cleanup_xbox_leaders_naming.rb +30 -0
  7. data/lib/faraday/response/raise_xbox_leaders_error.rb +22 -0
  8. data/lib/gamertag.rb +21 -10
  9. data/lib/gamertag/client.rb +25 -0
  10. data/lib/gamertag/client/achievements.rb +15 -0
  11. data/lib/gamertag/client/friends.rb +14 -0
  12. data/lib/gamertag/client/games.rb +41 -0
  13. data/lib/gamertag/client/profile.rb +14 -0
  14. data/lib/gamertag/configuration.rb +48 -0
  15. data/lib/gamertag/connection.rb +22 -0
  16. data/lib/gamertag/error.rb +22 -0
  17. data/lib/gamertag/version.rb +2 -2
  18. data/spec/client/achievements_spec.rb +21 -0
  19. data/spec/client/friends_spec.rb +23 -0
  20. data/spec/client/games_spec.rb +49 -0
  21. data/spec/client/profile_spec.rb +22 -0
  22. data/spec/client_spec.rb +7 -0
  23. data/spec/faraday/xboxleader_cleanup_spec.rb +59 -0
  24. data/spec/faraday/xboxleader_error_spec.rb +63 -0
  25. data/spec/fixtures/achievements.json +654 -0
  26. data/spec/fixtures/errors/friends_not_found.json +9 -0
  27. data/spec/fixtures/errors/game_not_found.json +9 -0
  28. data/spec/fixtures/errors/gamertag_not_found.json +9 -0
  29. data/spec/fixtures/errors/invalid_game_id.json +9 -0
  30. data/spec/fixtures/errors/invalid_gamertag.json +9 -0
  31. data/spec/fixtures/friends.json +772 -0
  32. data/spec/fixtures/gamertag_not_found.json +9 -0
  33. data/spec/fixtures/games.json +2244 -0
  34. data/spec/fixtures/profile.json +125 -0
  35. data/spec/gamertag_spec.rb +13 -0
  36. data/spec/helper.rb +38 -0
  37. metadata +92 -124
  38. data/.gitignore +0 -9
  39. data/.rspec +0 -3
  40. data/.rvmrc +0 -1
  41. data/Gemfile +0 -4
  42. data/LICENSE +0 -20
  43. data/README.mdown +0 -106
  44. data/Rakefile +0 -12
  45. data/lib/gamertag/friends.rb +0 -25
  46. data/lib/gamertag/played_games.rb +0 -73
  47. data/lib/gamertag/profile.rb +0 -13
  48. data/lib/gamertag/simple_profile.rb +0 -68
  49. data/spec/fixtures/vcr_cassettes/Friends_Belial1984.yml +0 -520
  50. data/spec/fixtures/vcr_cassettes/PlayedGames_Belial1984.yml +0 -1309
  51. data/spec/fixtures/vcr_cassettes/PlayedGames_some_user.yml +0 -100
  52. data/spec/fixtures/vcr_cassettes/SimpleProfile_Belial1984.yml +0 -45
  53. data/spec/friends_spec.rb +0 -19
  54. data/spec/played_games_spec.rb +0 -25
  55. data/spec/profile_spec.rb +0 -15
  56. data/spec/simple_profile_spec.rb +0 -69
  57. data/spec/spec_helper.rb +0 -15
  58. data/spec/version_spec.rb +0 -7
@@ -1,100 +0,0 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: http://www.xboxgamertag.com:80/search/some+user/
6
- body: !!null
7
- headers: !!null
8
- response: !ruby/struct:VCR::Response
9
- status: !ruby/struct:VCR::ResponseStatus
10
- code: 500
11
- message: Internal Server Error
12
- headers:
13
- set-cookie:
14
- - PHPSESSID=q43afhmf2th49p3hluntbkp8h0; path=/
15
- expires:
16
- - Thu, 19 Nov 1981 08:52:00 GMT
17
- cache-control:
18
- - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
19
- pragma:
20
- - no-cache
21
- vary:
22
- - Accept-Encoding
23
- content-type:
24
- - text/html; charset=UTF-8
25
- transfer-encoding:
26
- - chunked
27
- date:
28
- - Thu, 20 Dec 2012 20:16:22 GMT
29
- x-varnish:
30
- - '1120123603'
31
- age:
32
- - '0'
33
- connection:
34
- - keep-alive
35
- x-cache:
36
- - MISS
37
- server:
38
- - Xbox Gamertag
39
- body: ! "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html
40
- xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:og=\"http://ogp.me/ns#\"\n xmlns:fb=\"https://www.facebook.com/2008/fbml\"
41
- lang=\"en\">\n<head>\n<title>Xbox Gamertag data is broken </title>\n<meta http-equiv=\"Content-Type\"
42
- content=\"text/html; charset=utf-8\" />\n<meta name=\"description\" content=\"Search
43
- Xbox Live Gamertags, Create Xbox Gamercards using the Xbox Gamerator. Get Gamertag
44
- Suggestions for a new Gamertag. Find Game information, reviews and more\" />\n<meta
45
- name=\"keywords\" content=\"xbox, xbox gamertag, gamertag, gamertag search,
46
- xbox gamertag search, xbox live, gamercards, gamertag generator, gamercard generator\"
47
- />\n<meta name=\"robots\" content=\"index, follow\" />\n<meta name=\"google-site-verification\"
48
- content=\"DawowDmV2J68zDd4Ej0RdjF9C4mPykmq7smE1F2bgTw\" />\n<!-- Stylesheets
49
- -->\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/resources/css/main.css?1340884017\"
50
- />\n\n\n<!-- Javascript -->\n<script type=\"text/javascript\" src=\"/resources/scripts/jquery-1.7.2.min.js?1340884017\"></script>\n\n<!--[if
51
- lt IE 7]>\n<script type=\"text/javascript\" src=\"/resources/scripts/supersleight.plugin.js?1340884017\"></script>\n<script>\n$(document).ready(function()\n{\n\t$('img,
52
- div, input').supersleight();\n});\n</script>\n<![endif]-->\n\n<div id=\"fb-root\"></div>\n<script
53
- type=\"text/javascript\">(function(d, s, id) {\n var js, fjs = d.getElementsByTagName(s)[0];\n
54
- \ if (d.getElementById(id)) return;\n js = d.createElement(s); js.id = id;\n
55
- \ js.src = \"//connect.facebook.net/en_GB/all.js#xfbml=1&appId=190837717693571\";\n
56
- \ fjs.parentNode.insertBefore(js, fjs);\n}(document, 'script', 'facebook-jssdk'));\n</script>\n\n\n\n</head>\n<body>\n\n\n\n<div
57
- id=\"container\"><noscript>For full functionality of this page it is necessary
58
- to enable JavaScript. Here are the <a href=\"http://www.enable-javascript.com\"
59
- target=\"_blank\"> instructions how to enable JavaScript in your web browser</a></noscript>\n\t\n\t<h1
60
- id=\"MainTitle\"><a href=\"http://www.xboxgamertag.com/\">Xbox Gamertag</a></h1>\n\t\t\t\t\t\t\t\t\n\n<div
61
- class=\"topAd\">\n\n<!-- BuySellAds.com Ad Code -->\n<script type=\"text/javascript\">\n(function(){\n
62
- \ var bsa = document.createElement('script');\n bsa.type = 'text/javascript';\n
63
- \ bsa.async = true;\n bsa.src = 'http://s3.buysellads.com/ac/bsa.js';\n
64
- \ (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);\n})();\n</script>\n<!--
65
- End BuySellAds.com Ad Code -->\n<div id=\"bsap_1263149\" class=\"bsarocks bsap_98d6915731db38cdebc72e15b7b23b2b\"></div>\n\n\n\n\n\n\n</div>\t\n\t\n\t<div
66
- id=\"topLinks\">\n\t\t<ul>\n\t\t\t\t\t\t<li><a href=\"/register/\"><strong>Register</strong></a>
67
- | </li>\n\t\t\t<li><a href=\"/login/\">Login</a></li>\n\t\t\t\t\t\t\n\t\t</ul>\n\t</div>\n\t<div
68
- id=\"XGTHeader\">\n\t\t<ul id=\"Menu\">\n\t\t\t<li class=\"image\"><a href=\"/\"><img
69
- src=\"/resources/images/homeHouse.png\" alt=\"xboxgamertag\" /></a></li>\n\t\t\t<li
70
- class=\"left\"><a href=\"/gamercard/\">Gamercards</a></li>\n\t\t\t<li class=\"left\"><a
71
- href=\"/gamertag-generator/\">Gamertag Generator</a></li>\n\t\t\t<li class=\"left\"><a
72
- href=\"/achievements/\">Achievements</a></li>\n\t\t\t<li class=\"left\"><a href=\"/leaderboards/\">Leaderboards</a></li>\n\n\t\t\t<!---<li
73
- class=\"rightOption\"><a href=\"/forum/\">Forums</a></li>-->\n\t\t\t\n\t\t\t<li
74
- class=\"rightOption\"><a href=\"http://www.facebook.com/pages/Xbox-Gamertag/134742809876061\"
75
- rel=\"nofollow\" target=\"_blank\">Share Your Gamertag</a></li>\n\n\n\t\t</ul>\n\t\t\t</div>\n\t<div
76
- id=\"XGTMain\">\n\t<h2>An error occured...</h2>\r\n\t<div class=\"centerContent\">\r\n\t<p>It
77
- seems as if the Xbox.com feeds are down.</p>\r\n\t<p>It's probably just a temporary
78
- issue, try again in a while</p>\r\n\t<p>In the mean time, come have a chat with
79
- us on the forums and have some tea...</p>\r\n\t\t<img src=\"/resources/images/icons/teatime.png\"
80
- alt=\"Why not have some tea? (or coffee, its better)\" title=\"Why not have
81
- some tea? (or coffee, its better)\" />\r\n\t\t\r\n\t\t<br /><br /> <h2>If you're
82
- bored, add us on Xbox Live before our friends list gets full! <br />Gamertag:
83
- XboxGamertagCom</h2>\r\n\t</div>\r\n</div>\n\t<div class=\"XGTFooter\">\n\t\t<div
84
- class=\"rightCol\">\n\t\t\t<p> </p>\n\t\t</div>\n\t\t\n\t</div>\n</div>\n<div
85
- class=\"XGTFooter\">\n\t<div class=\"leftCol\">\n\t\t<a href=\"/contact/\">Contact
86
- Us</a> - <a href=\"/legal/terms/\">Terms of Use</a> - <a href=\"/legal/privacy/\">Privacy
87
- Policy</a> - <a href=\"/sitemap/\">Sitemap</a>\n\t\t<br />\n\t\tFollow us on:
88
- <a href=\"http://www.facebook.com/pages/Xbox-Gamertag/134742809876061\" target=_blank\"
89
- rel=\"nofollow\">Facebook</a> - <a href=\"http://twitter.com/XboxGamerTagCom\"
90
- \ target=_blank\" rel=\"nofollow\">Twitter</a> - <a href=\"http://www.youtube.com/user/XboxGamertagCom\"
91
- target=_blank\" rel=\"nofollow\">Youtube</a>\n\n</div>\n\t<div class=\"rightCol\">\n\t\t<p>Xboxgamertag.com
92
- &#169 2010 - 2012</p>\n\t\t<p>XboxGamertag.com is a member of the Xbox Community
93
- Developer Program (XCDP)</p>\n\t\t<p>We are not affiliated with Microsoft or
94
- Xbox</p>\n\t</div>\t\n</div>\n<script type=\"text/javascript\"> var _gaq =
95
- _gaq || []; _gaq.push(['_setAccount', 'UA-16948229-1']); _gaq.push(['_trackPageview']);
96
- \ (function() { var ga = document.createElement('script'); ga.type = 'text/javascript';
97
- ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl'
98
- : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0];
99
- s.parentNode.insertBefore(ga, s); })();</script>\n</body>\n</html>\n"
100
- http_version: '1.1'
@@ -1,45 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: http://api.xboxleaders.com/v2/?gamertag=Belial1984&format=json
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers: {}
10
- response:
11
- status:
12
- code: 200
13
- message: OK
14
- headers:
15
- Date:
16
- - Wed, 24 Aug 2011 16:40:13 GMT
17
- Server:
18
- - Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1
19
- mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.13
20
- X-Powered-By:
21
- - PHP/5.2.13
22
- Expires:
23
- - Mon, 26 Jul 1997 05:00:00 GMT
24
- Last-Modified:
25
- - Wed, 24 Aug 2011 16:40:14GMT
26
- Cache-Control:
27
- - no-cache, must-revalidate
28
- Pragma:
29
- - no-cache
30
- Content-Length:
31
- - '3225'
32
- Content-Type:
33
- - application/json
34
- body:
35
- encoding: UTF-8
36
- string: ! '{"user":{"gamertag":"belial1984","is_valid":1,"profile_link":"http:\/\/live.xbox.com\/member\/belial1984","launch_team":{"xbl":0,"nxe":0,"kinect":0},"account_status":"Gold","gender":"Male","is_cheater":0,"online":0,"online_status":"Last
37
- seen 8\/22\/2011 playing Modern Warfare&#174; 2","avatars":{"gamer_tile":"http:\/\/avatar.xboxlive.com\/avatar\/belial1984\/avatarpic-l.png","small_gamerpic":"http:\/\/avatar.xboxlive.com\/avatar\/belial1984\/avatarpic-s.png","large_gamerpic":"http:\/\/avatar.xboxlive.com\/avatar\/belial1984\/avatarpic-l.png","body_gamerpic":"http:\/\/avatar.xboxlive.com\/avatar\/belial1984\/avatar-body.png"},"reputation":100,"gamerscore":11910,"location":"london","motto":"","name":"baris
38
- balic","bio":"","recent_games":{"1":{"title":"Modern Warfare&#174; 2","tid":1096157207,"marketplace_url":"http:\/\/marketplace.xbox.com\/Title\/1096157207","compare_url":"http:\/\/live.xbox.com\/en-US\/GameCenter\/Achievements?title=1096157207&amp;compareTo=belial1984","image":"http:\/\/tiles.xbox.com\/tiles\/l6\/Vi\/0Gdsb2JhbA9ECgQJGgYfVl5UL2ljb24vMC84MDAwIAAAAAAAAP9NpYg=.jpg","last_played":"1313967600","earned_gamerscore":930,"available_gamerscore":1000,"earned_achievements":43,"available_achievements":50,"percentage_complete":86},"2":{"title":"Halo:
39
- Reach","tid":1297287259,"marketplace_url":"http:\/\/marketplace.xbox.com\/Title\/1297287259","compare_url":"http:\/\/live.xbox.com\/en-US\/GameCenter\/Achievements?title=1297287259&amp;compareTo=belial1984","image":"http:\/\/tiles.xbox.com\/tiles\/ih\/ew\/0Wdsb2JhbA9ECgR8GgMfVlohL2ljb24vMC84MDAwIAAAAAAAAP6fF5U=.jpg","last_played":"1299542400","earned_gamerscore":375,"available_gamerscore":1400,"earned_achievements":26,"available_achievements":59,"percentage_complete":44},"3":{"title":"Portal
40
- 2","tid":1161890066,"marketplace_url":"http:\/\/marketplace.xbox.com\/Title\/1161890066","compare_url":"http:\/\/live.xbox.com\/en-US\/GameCenter\/Achievements?title=1161890066&amp;compareTo=belial1984","image":"http:\/\/tiles.xbox.com\/tiles\/x2\/5+\/1mdsb2JhbA9ECgQNGwEfV15RL2ljb24vMC84MDAwIAAAAAAAAPlRbtg=.jpg","last_played":"","earned_gamerscore":345,"available_gamerscore":1000,"earned_achievements":21,"available_achievements":50,"percentage_complete":42},"4":{"title":"SUPER
41
- STREETFIGHTER IV","tid":1128466428,"marketplace_url":"http:\/\/marketplace.xbox.com\/Title\/1128466428","compare_url":"http:\/\/live.xbox.com\/en-US\/GameCenter\/Achievements?title=1128466428&amp;compareTo=belial1984","image":"http:\/\/tiles.xbox.com\/tiles\/oX\/8i\/0Wdsb2JhbA9ECgQLGwMfWSkgL2ljb24vMC84MDAwIAAAAAAAAP4Nf74=.jpg","last_played":"1309906800","earned_gamerscore":470,"available_gamerscore":1160,"earned_achievements":28,"available_achievements":58,"percentage_complete":48},"5":{"title":"Child
42
- of Eden","tid":1431504972,"marketplace_url":"http:\/\/marketplace.xbox.com\/Title\/1431504972","compare_url":"http:\/\/live.xbox.com\/en-US\/GameCenter\/Achievements?title=1431504972&amp;compareTo=belial1984","image":"http:\/\/tiles.xbox.com\/tiles\/z2\/Jl\/1mdsb2JhbA9ECgUNGgMfVlsgL2ljb24vMC84MDAwIAAAAAAAAPlKYtA=.jpg","last_played":"","earned_gamerscore":0,"available_gamerscore":1000,"earned_achievements":0,"available_achievements":49,"percentage_complete":0}}}}'
43
- http_version: '1.1'
44
- recorded_at: Thu, 25 Aug 2011 00:52:26 GMT
45
- recorded_with: VCR 2.3.0
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gamertag::Friends do
4
- use_vcr_cassette('Friends_Belial1984')
5
-
6
- it "should return all friends" do
7
- profile = Gamertag::Friends.new('Belial1984')
8
-
9
- profile.friends.class.should be(Array)
10
- profile.friends.length.should eql(65)
11
- end
12
-
13
- it "should return online friends" do
14
- profile = Gamertag::Friends.new('Belial1984')
15
-
16
- profile.online_friends.class.should be(Array)
17
- profile.online_friends.length.should eql(7)
18
- end
19
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gamertag::PlayedGames do
4
-
5
- context "valid user" do
6
- use_vcr_cassette('PlayedGames_Belial1984')
7
- it "should return played games" do
8
- played_games = Gamertag::PlayedGames.new('Belial1984')
9
-
10
- played_games.first.title.should include("Modern Warfare")
11
- played_games.count.should == 88
12
- played_games.each {|game| game.title.nil?.should be_false}
13
- gamerscore_values = [:above_average, :below_average, :undefined]
14
- played_games.each do |game|
15
- gamerscore_values.should include(game.relative_gamerscore)
16
- end
17
- end
18
- end
19
- context "invalid user" do
20
- use_vcr_cassette('PlayedGames_some_user')
21
- it "should not raise an error" do
22
- expect{Gamertag::PlayedGames.new('some user')}.to_not raise_error(URI::InvalidURIError)
23
- end
24
- end
25
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gamertag::Profile do
4
- use_vcr_cassette('SimpleProfile_Belial1984')
5
- use_vcr_cassette('PlayedGames_Belial1984')
6
-
7
- it "should return composite details" do
8
- profile = Gamertag::Profile.new('Belial1984')
9
-
10
- profile.gamertag.should eql('belial1984')
11
- profile.online_status.include?('SUPER STREETFIGHTER IV').should eql(false)
12
- profile.recent_games.count.should eql(5)
13
- profile.played_games.count.should eql(88)
14
- end
15
- end
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gamertag::SimpleProfile do
4
- describe "#fetch" do
5
- context "valid user" do
6
- use_vcr_cassette('SimpleProfile_Belial1984')
7
-
8
- it "should return profile data" do
9
- profile = Gamertag::SimpleProfile.new('Belial1984')
10
-
11
- profile.name.should =~ /baris balic/i
12
- profile.gamertag.should =~ /Belial1984/i
13
- profile.avatars.count.should eql(4)
14
- profile.avatars.small_gamerpic.should == 'http://avatar.xboxlive.com/avatar/belial1984/avatarpic-s.png'
15
- end
16
-
17
- it "should return the recent games data" do
18
- profile = Gamertag::SimpleProfile.new('Belial1984')
19
-
20
- profile.recent_games.count.should eql(5)
21
- profile.recent_games.first.title.should eql('Modern Warfare&#174; 2')
22
- profile.recent_games.first.available_gamerscore.should eql(1000)
23
- profile.recent_games.first.last_played.class.should == Time
24
- end
25
- end
26
- context "user with spaces" do
27
- use_vcr_cassette('SimpleProfile_some_user')
28
- it "should not raise an error" do
29
- expect{Gamertag::SimpleProfile.new('some user')}.to_not raise_error(URI::InvalidURIError)
30
- end
31
- end
32
- end
33
-
34
- describe ".from_json" do
35
- let(:seed_data) {
36
- {
37
- "gamertag" => "laikal1",
38
- "is_valid" => 1,
39
- "profile_link"=>"http://live.xbox.com/member/laikal1",
40
- "launch_team"=>{"xbl"=>0, "nxe"=>0, "kinect"=>0},
41
- "account_status"=>"Gold",
42
- "gender"=>"Male",
43
- "is_cheater"=>0,
44
- "online"=>0,
45
- "online_status"=>"Last seen 9 hours ago playing Xbox.com",
46
- "avatars"=>{
47
- "gamer_tile"=>"http://avatar.xboxlive.com/avatar/laikal1/avatarpic-l.png",
48
- "small_gamerpic"=>"http://avatar.xboxlive.com/avatar/laikal1/avatarpic-s.png",
49
- "large_gamerpic"=>"http://avatar.xboxlive.com/avatar/laikal1/avatarpic-l.png",
50
- "body_gamerpic"=>"http://avatar.xboxlive.com/avatar/laikal1/avatar-body.png"
51
- },
52
- "reputation"=>85,
53
- "gamerscore"=>41646,
54
- "location"=>"Ann Arbor, MI",
55
- "motto"=>"Complexify!",
56
- "name"=>"Nyarlathotep (1 bucket)",
57
- "bio"=>"Design is how it works."
58
- }
59
- }
60
- it "should initialize a profile from json data without calling a remote service" do
61
- Net::HTTP.should_not_receive(:get_response)
62
- profile = Gamertag::SimpleProfile.from_json(seed_data.to_json)
63
- seed_data.keys.each do |k|
64
- profile.send(k).should == seed_data[k]
65
- end
66
- end
67
- end
68
-
69
- end
@@ -1,15 +0,0 @@
1
- require 'rubygems'
2
- require 'rspec'
3
- require 'vcr'
4
-
5
- require File.join(File.dirname(__FILE__), %w{ .. lib gamertag})
6
-
7
- VCR.configure do |c|
8
- c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
9
- c.hook_into :fakeweb
10
- c.default_cassette_options = { :record => :once }
11
- end
12
-
13
- RSpec.configure do |c|
14
- c.extend VCR::RSpec::Macros
15
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gamertag do
4
- it "should be the correct version" do
5
- Gamertag::VERSION.should == '1.1.0'
6
- end
7
- end