gamertag 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mdown +7 -3
- data/gamertag.gemspec +1 -1
- data/lib/gamertag/played_games.rb +4 -3
- data/lib/gamertag/simple_profile.rb +1 -2
- data/lib/gamertag/version.rb +1 -1
- metadata +1 -2
- data/lib/gamertag/recent_games.rb +0 -0
data/README.mdown
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
An interface for accessing your xbox live profile and game data.
|
4
4
|
|
5
5
|
## Install
|
6
|
-
|
6
|
+
gem install gamertag.
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
This gem fetches data from two independent sources, which has several implications such as one of the sources not being available, or an increased overhead when you only want to access some of the data. To this end the interface will allow you to access all data, just the profile data or just the played games data.
|
@@ -62,13 +62,17 @@ This gem fetches data from two independent sources, which has several implicatio
|
|
62
62
|
game.earned_achievements
|
63
63
|
game.available_achievements
|
64
64
|
game.average_gamerscore
|
65
|
-
game.relative_gamerscore
|
65
|
+
game.relative_gamerscore => :above_average || :below_average
|
66
66
|
end
|
67
67
|
|
68
68
|
|
69
69
|
## Note on Patches/Pull Requests
|
70
70
|
|
71
|
-
*
|
71
|
+
* Fork the project.
|
72
|
+
* Make your feature addition or bug fix.
|
73
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
74
|
+
* Send me a pull request.
|
75
|
+
|
72
76
|
|
73
77
|
## Copyright
|
74
78
|
|
data/gamertag.gemspec
CHANGED
@@ -6,7 +6,7 @@ module Gamertag
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def method_missing(method_name, args = nil)
|
9
|
-
[:first, :last, :each, :count].each {|method| return @played_games.send(method) if method_name == method }
|
9
|
+
[:first, :last, :each, :count, :to_hash].each {|method| return @played_games.send(method) if method_name == method }
|
10
10
|
@played_games[method_name.to_s]
|
11
11
|
end
|
12
12
|
|
@@ -15,10 +15,11 @@ module Gamertag
|
|
15
15
|
uri = URI.parse("http://www.xboxgamertag.com/search/#{gamertag}/")
|
16
16
|
response = Net::HTTP.get_response(uri)
|
17
17
|
document = Nokogiri::HTML(response.body)
|
18
|
-
parse_rows(document)
|
18
|
+
parse_rows(document)
|
19
19
|
end
|
20
20
|
|
21
21
|
def parse_rows(document)
|
22
|
+
# Nasty HTML scraping hack, maybe pull into another class?
|
22
23
|
document.css("[id='recentGamesTable']").css('tr').map do |table_row|
|
23
24
|
cells = table_row.css('td')
|
24
25
|
|
@@ -26,7 +27,7 @@ module Gamertag
|
|
26
27
|
gamerscore = cells[2].css("div[class='percentage-container']").first.text.strip!.split('/')
|
27
28
|
achievements = (cells[2].css("div[class='percentage-container']").last.text).strip!.split('/')
|
28
29
|
average_gamerscore = cells[3].css('span').text.strip!
|
29
|
-
relative_gamerscore = (cells[3].css('span').attribute('title').text.include?('above average') ? :
|
30
|
+
relative_gamerscore = (cells[3].css('span').attribute('title').text.include?('above average') ? :above_average : :below_average)
|
30
31
|
|
31
32
|
Hashie::Mash.new({'image' => cells[0].css('img').attribute('src').text,
|
32
33
|
'title' => naming.first.text,
|
@@ -10,8 +10,7 @@ module Gamertag
|
|
10
10
|
|
11
11
|
def recent_games
|
12
12
|
@profile['recent_games'].map do |k, v|
|
13
|
-
|
14
|
-
Hashie::Mash.new(g)
|
13
|
+
Hashie::Mash.new(v.merge({'last_played' => Time.at(v['last_played'].to_i)}))
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
data/lib/gamertag/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gamertag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Baris Balic
|
@@ -31,7 +31,6 @@ files:
|
|
31
31
|
- lib/gamertag.rb
|
32
32
|
- lib/gamertag/played_games.rb
|
33
33
|
- lib/gamertag/profile.rb
|
34
|
-
- lib/gamertag/recent_games.rb
|
35
34
|
- lib/gamertag/simple_profile.rb
|
36
35
|
- lib/gamertag/version.rb
|
37
36
|
- spec/played_games_spec.rb
|
File without changes
|