xbox_leaders 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cbf79ad21dc816872bef6ebba42a988299ac29a4
4
+ data.tar.gz: 5f82a3abdd0c11a695decefd3e25783d47c1c1f9
5
+ SHA512:
6
+ metadata.gz: a59e8fd6e78c55623b59b532896d9ccb3851cc0bed96e327ffc033adcd9e9e1c9c8ee57071fc20953c78d7dbeeb0e9accbebf3aeda510c88efc9a44b63b20209
7
+ data.tar.gz: 30b5b36e818310040654e43c5e25a03e2f679581d50cccfb579164c7d7d8dbe1d10291262405318fd3f71cf5a6d2bb908b8611f5c94fad07ad7d1d703075c7ce
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.swp
2
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 2.0.0" > .rvmrc
9
+ environment_id="ruby-2.0.0@xbox_leaders"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.18.21 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+ ruby '2.0.0'
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ xbox_leaders (1.0.0)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.0.9)
11
+ diff-lcs (1.2.1)
12
+ httparty (0.10.2)
13
+ multi_json (~> 1.0)
14
+ multi_xml (>= 0.5.2)
15
+ method_source (0.8.1)
16
+ multi_json (1.7.2)
17
+ multi_xml (0.5.3)
18
+ pry (0.9.12)
19
+ coderay (~> 1.0.5)
20
+ method_source (~> 0.8)
21
+ slop (~> 3.4)
22
+ rspec (2.13.0)
23
+ rspec-core (~> 2.13.0)
24
+ rspec-expectations (~> 2.13.0)
25
+ rspec-mocks (~> 2.13.0)
26
+ rspec-core (2.13.1)
27
+ rspec-expectations (2.13.0)
28
+ diff-lcs (>= 1.1.3, < 2.0)
29
+ rspec-mocks (2.13.0)
30
+ slop (3.4.4)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ pry
37
+ rspec
38
+ xbox_leaders!
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+ require 'xbox_leaders'
3
+
4
+ task :default => :console
5
+
6
+ task :console do
7
+ require 'pry'
8
+ binding.pry
9
+ end
@@ -0,0 +1,43 @@
1
+ require 'httparty'
2
+
3
+ class XboxLeaders::Api
4
+
5
+ include HTTParty
6
+ base_uri 'https://www.xboxleaders.com/api'
7
+ format :json
8
+
9
+ attr_accessor :timeout
10
+
11
+ def initialize(timeout: 6)
12
+ @timeout = timeout
13
+ end
14
+
15
+ def fetch_achievements(gamertag, game_id)
16
+ get('/achievements', gamertag: gamertag, titleid: game_id)
17
+ end
18
+
19
+ def fetch_friends(gamertag)
20
+ get('/friends', gamertag: gamertag)
21
+ end
22
+
23
+ def fetch_games(gamertag)
24
+ get('/games', gamertag: gamertag)
25
+ end
26
+
27
+ def fetch_profile(gamertag)
28
+ get('/profile', gamertag: gamertag)
29
+ end
30
+
31
+ private
32
+
33
+ def get(path, query={})
34
+ response = self.class.get(path, timeout: timeout, query: query).to_hash
35
+
36
+ if error = response['error']
37
+ raise ArgumentError, error['message']
38
+ end
39
+
40
+ response['Data']
41
+ end
42
+
43
+ end
@@ -0,0 +1,6 @@
1
+ module XboxLeaders
2
+ VERSION = '1.0.0'
3
+ end
4
+
5
+ require 'xbox_leaders/api'
6
+
@@ -0,0 +1,2 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'xbox_leaders'
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe XboxLeaders::Api do
4
+ describe '#initialize' do
5
+ it 'allows a specified timeout in seconds' do
6
+ api = XboxLeaders::Api.new(timeout: 10)
7
+ api.timeout.should == 10
8
+ end
9
+
10
+ it 'defaults to a 6-second timeout' do
11
+ api = XboxLeaders::Api.new
12
+ api.timeout.should == 6
13
+ end
14
+ end
15
+
16
+ context 'making requests' do
17
+ it 'validates the gamertag' do
18
+ api = XboxLeaders::Api.new
19
+ lambda { api.fetch_profile('nevern02') }.should_not raise_exception
20
+ lambda { api.fetch_profile('foobarbaz123') }.should raise_exception
21
+ end
22
+
23
+ it 'fetches a profile' do
24
+ response = XboxLeaders::Api.new.fetch_profile('nevern02')
25
+ response['IsValid'].should == 1
26
+ end
27
+
28
+ it 'fetches a list of games' do
29
+ response = XboxLeaders::Api.new.fetch_games('nevern02')
30
+ response['GameCount'].should be > 0
31
+ end
32
+
33
+ it 'fetches a list of achievements' do
34
+ response = XboxLeaders::Api.new.fetch_achievements('nevern02', '1096157379')
35
+ response['Achievements'].should_not be_nil
36
+ end
37
+
38
+ it 'fetches a list of friends' do
39
+ response = XboxLeaders::Api.new.fetch_friends('nevern02')
40
+ response['Friends'].should_not be_nil
41
+ end
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xbox_leaders
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Rice
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: 'A wrapper for the Xbox Live API provided by Xbox Leaders: https://www.xboxleaders.com/'
56
+ email:
57
+ - brice84@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .rspec
64
+ - .rvmrc
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - Rakefile
68
+ - lib/xbox_leaders.rb
69
+ - lib/xbox_leaders/api.rb
70
+ - spec/spec_helper.rb
71
+ - spec/xbox_leaders/api_spec.rb
72
+ homepage: https://github.com/nevern02/xbox_leaders
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.3
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: An Xbox Live API wrapper
96
+ test_files:
97
+ - spec/spec_helper.rb
98
+ - spec/xbox_leaders/api_spec.rb