dotinha 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43cd1aa64e4266ea19430fb9e20049c56a50a572
4
+ data.tar.gz: 6ee60187dbc42f1bb2fc9359513e63eed14ede9d
5
+ SHA512:
6
+ metadata.gz: 280b63a5dcc1aa85685033effd0e20149978df41e40cb9b47f99708258d3cecb30b8597d8fb0b72fcd0f0906bd015cf4196afdfdd8e3c168a7b624b1742179a5
7
+ data.tar.gz: 9e2fa82dba8d4fea76f48f90821a1f366ee471483382b1aead9869200b413b7b1bc9b15cf22f52b3da778d9861737d08a9512d635eaef0f27c2904629bc2cee3
data/lib/dotinha.rb ADDED
@@ -0,0 +1,44 @@
1
+ # coding: utf-8
2
+ path = File.expand_path(File.dirname(__FILE__))
3
+ $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
4
+
5
+ # here come the requires bla bla bla
6
+ require 'open-uri'
7
+ require 'json'
8
+
9
+ #require 'dotinha/league_listing'
10
+ #require 'dotinha/live_league_games'
11
+ require 'dotinha/match_details'
12
+ require 'dotinha/match_history'
13
+ #require 'dotinha/team_info'
14
+
15
+ module Dotinha
16
+
17
+ VERSION = '0.0.1'
18
+
19
+ # Steam Generic API Url
20
+ URI = 'http://api.steampowered.com/'
21
+
22
+ # Steam Dota2 Game ID
23
+ GAME_ID = '570'
24
+
25
+ class Client
26
+
27
+ def initialize(api_key)
28
+ @api_key = api_key
29
+ end
30
+
31
+ def get_match_history(params={})
32
+ params[:key] ||= @api_key
33
+ MatchHistory.get_data(params)
34
+ end
35
+
36
+ def get_match_details(match_id, params={})
37
+ params[:key] ||= @api_key
38
+ params[:match_id] ||= match_id
39
+ MatchDetails.get_data(params)
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,25 @@
1
+ module Dotinha
2
+ class MatchDetails
3
+
4
+ #
5
+ # Get match details from Dota2 API
6
+ # Possible params at: http://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistory
7
+ #
8
+
9
+ def self.get_data(params={})
10
+ uri = get_uri(params)
11
+ match_history = open(uri){|f| f.read}
12
+ JSON.parse(match_history)["result"]
13
+ end
14
+
15
+ private
16
+
17
+ def self.get_uri(params={})
18
+ url = "#{URI}IDOTA2Match_#{GAME_ID}/GetMatchDetails/v1?"
19
+ query_string = params.map{ |key, value| "#{key}=#{value}" }.join '&'
20
+
21
+ url + query_string
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Dotinha
2
+ class MatchHistory
3
+
4
+ #
5
+ # Get match history from Dota2 API
6
+ # Possible params at: http://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistory
7
+ #
8
+
9
+ def self.get_data(params={})
10
+ uri = get_uri(params)
11
+ match_history = open(uri){|f| f.read}
12
+ JSON.parse(match_history)["result"]
13
+ end
14
+
15
+ private
16
+
17
+ def self.get_uri(params={})
18
+ url = "#{URI}IDOTA2Match_#{GAME_ID}/GetMatchHistory/v1?"
19
+ query_string = params.map{ |key, value| "#{key}=#{value}" }.join '&'
20
+
21
+ url + query_string
22
+ end
23
+
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dotinha
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - João Gabriel Fraga
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
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
+ description: A Simple Dota 2 Public API Parser
28
+ email: jgfraga@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/dotinha/match_details.rb
34
+ - lib/dotinha/match_history.rb
35
+ - lib/dotinha.rb
36
+ homepage: https://github.com/joaofraga/dotinha
37
+ licenses: []
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.0.0.rc.2
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: A Simple Dota 2 Public API Parser
59
+ test_files: []