lolapi 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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/configuration.rb +15 -0
  3. data/lib/lolapi.rb +45 -0
  4. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e7d8bebee5848c3a7da0853ce2af3e1a0ccdab1a
4
+ data.tar.gz: f2ea8a50c5ac4a590d965069c0bfae87bcdbdcde
5
+ SHA512:
6
+ metadata.gz: e9f19fe533b208d5082327be7f359c18279b4eef5da207f2bd5aec8bb5b8ea86ad77023084a325a1c69367c403084276f8e9a44116cfef380fdbd1ccb3bddf0c
7
+ data.tar.gz: 8ee7c6866ad3993035bbaf16f66b216c57ad99c7df5affe7cef185ee6e81fc54fa71f85f81ccb782d476a4421852180125f2c90d01e9a87bcb2eccc2f4924234
@@ -0,0 +1,15 @@
1
+ module Configuration
2
+ DEFAULT_API_KEY = 'API KEY HERE'
3
+
4
+ VALID_OPTIONS_KEYS = [:api_key].freeze
5
+
6
+ attr_accessor *VALID_OPTIONS_KEYS
7
+
8
+ def reset
9
+ self.api_key = DEFAULT_API_KEY
10
+ end
11
+
12
+ def configure
13
+ yield self
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ require 'net/http'
2
+ require 'cgi'
3
+ require 'json'
4
+ require 'configuration'
5
+ class LoLAPI
6
+ extend Configuration
7
+
8
+ def self.champion(region)
9
+ query '/api/lol/' + region + '/v1.1/champion'
10
+ end
11
+
12
+ def self.game(summoner_id, region)
13
+ query '/api/lol/' + region + '/v1.1/game/by-summoner/' + summoner_id.to_s + '/recent'
14
+ end
15
+
16
+ def self.league(summoner_id, region)
17
+ query '/api/' + region + '/v2.1/league/by-summoner/' + summoner_id.to_s
18
+ end
19
+
20
+ def self.summary(summoner_id, region)
21
+ query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/summary', 'season=SEASON3'
22
+ end
23
+
24
+ def self.ranked(summoner_id, region)
25
+ query '/api/lol/' + region + '/v1.1/stats/by-summoner/' + summoner_id.to_s + '/ranked'
26
+ end
27
+
28
+ def self.summoner(name, region)
29
+ query '/api/lol/' + region + '/v1.1/summoner/by-name/' + name
30
+ end
31
+
32
+ def self.team(summoner_id, region)
33
+ query '/api/' + region + '/v2.1/team/by-summoner/' + summoner_id.to_s
34
+ end
35
+
36
+ def self.query(uri, params = nil)
37
+ if params.nil?
38
+ response = Net::HTTP.get(URI('http://prod.api.pvp.net' + uri + '?api_key=' + self.api_key))
39
+ else
40
+ response = Net::HTTP.get(URI('http://prod.api.pvp.net' + uri + '?' + params + '&api_key=' + self.api_key))
41
+ end
42
+
43
+ JSON.parse(response)
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lolapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ian Mitchell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A wrapper for the League of Legends API desc
14
+ email: ian.mitchel1@live.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/lolapi.rb
20
+ - lib/configuration.rb
21
+ homepage: http://github.com/ianmitchell/lolapi
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A wrapper for the League of Legends API
44
+ test_files: []