captainteemo 0.0.1
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.
- data/captainteemo.gemspec +26 -0
- data/lib/captainteemo/api.rb +17 -0
- data/lib/captainteemo/player.rb +69 -0
- data/lib/captainteemo/resource.rb +41 -0
- data/lib/captainteemo/search.rb +40 -0
- data/lib/captainteemo.rb +24 -0
- metadata +67 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "captainteemo"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "captainteemo"
|
7
|
+
s.version = LoL::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ahmet Abdi"]
|
10
|
+
s.email = ["ahmetabdi@gmail.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/captainteemo"
|
12
|
+
s.summary = %q{A Ruby wrapper for league of legends information, API from http://api.captainteemo.com/_docs/index.php}
|
13
|
+
s.description = %q{Wrapper for http://api.captainteemo.com/_docs/index.php}
|
14
|
+
s.rubyforge_project = "captainteemo"
|
15
|
+
s.files = [
|
16
|
+
"captainteemo.gemspec",
|
17
|
+
"lib/captainteemo.rb",
|
18
|
+
"lib/captainteemo/api.rb",
|
19
|
+
"lib/captainteemo/player.rb",
|
20
|
+
"lib/captainteemo/resource.rb",
|
21
|
+
"lib/captainteemo/search.rb"
|
22
|
+
]
|
23
|
+
s.test_files = [ ]
|
24
|
+
s.require_paths = ["lib"]
|
25
|
+
s.add_dependency('httparty')
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module LoL
|
2
|
+
class Api
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'http://api.captainteemo.com/'
|
5
|
+
format :json
|
6
|
+
headers 'Accept' => 'application/json'
|
7
|
+
|
8
|
+
def self.config
|
9
|
+
@@config
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.key(api_key)
|
13
|
+
@@config = { :api_key => api_key }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module LoL
|
2
|
+
class Player < Resource
|
3
|
+
has_resource 'player', :plural => 'players'
|
4
|
+
|
5
|
+
@@fields = [
|
6
|
+
:accountId,
|
7
|
+
:summonerId,
|
8
|
+
:name,
|
9
|
+
:icon,
|
10
|
+
:internalName,
|
11
|
+
:level
|
12
|
+
]
|
13
|
+
|
14
|
+
@@fields.each do |field|
|
15
|
+
attr_accessor field
|
16
|
+
end
|
17
|
+
|
18
|
+
#Returns observer metadata and information if
|
19
|
+
#String Summoner on String Platform is playing a valid game.
|
20
|
+
def self.ingame(platform, name, conditions={})
|
21
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/ingame")
|
22
|
+
search.fetch_resource
|
23
|
+
end
|
24
|
+
|
25
|
+
#Returns last 10 matches (order is random) for String Summoner on String Platform.
|
26
|
+
def self.recent_games(platform, name, conditions={})
|
27
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/recent_games")
|
28
|
+
search.fetch_resource
|
29
|
+
end
|
30
|
+
|
31
|
+
#Returns lifetime influence point gains for String Summoner on String Platform.
|
32
|
+
def self.influence_points(platform, name, conditions={})
|
33
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/influence_points")
|
34
|
+
search.fetch_resource['data']
|
35
|
+
end
|
36
|
+
|
37
|
+
#Returns runepages for String Summoner on String Platform.
|
38
|
+
def self.runes(platform, name, conditions={})
|
39
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/runes")
|
40
|
+
search.fetch_resource
|
41
|
+
end
|
42
|
+
|
43
|
+
#Returns mastery pages for String Summoner on String Platform.
|
44
|
+
def self.mastery(platform, name, conditions={})
|
45
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/mastery")
|
46
|
+
search.fetch_resource
|
47
|
+
end
|
48
|
+
|
49
|
+
#Returns Season 3 Leagues info (internally Pojo).
|
50
|
+
def self.leagues(platform, name, conditions={})
|
51
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/leagues")
|
52
|
+
search.fetch_resource
|
53
|
+
end
|
54
|
+
|
55
|
+
#Returns all teams (and team match history) player is a member of.
|
56
|
+
def self.teams(platform, name, conditions={})
|
57
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/teams")
|
58
|
+
search.fetch_resource
|
59
|
+
end
|
60
|
+
|
61
|
+
#Returns player commendation (internally Kudos).
|
62
|
+
def self.honor(platform, name, conditions={})
|
63
|
+
search = LoL::Search.new("/#{self.endpoints[:singular]}/#{platform.to_s}/#{name.to_s}/honor")
|
64
|
+
search.fetch_resource
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module LoL
|
2
|
+
class Resource
|
3
|
+
@@endpoints = {}
|
4
|
+
@@endpoint_id = {}
|
5
|
+
|
6
|
+
def self.has_resource(singular=nil, opts={})
|
7
|
+
@@endpoints[self.name.downcase] = {
|
8
|
+
:singular => singular.nil? ? "#{self.name.downcase}" : singular,
|
9
|
+
:plural => opts[:plural].nil? ? "#{self.name.downcase}s" : opts[:plural]
|
10
|
+
}
|
11
|
+
@@endpoint_id[self.name.downcase] = opts[:id].nil? ? "" : "#{opts[:id]}-"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.endpoints
|
15
|
+
@@endpoints[self.name.downcase]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.endpoint_id
|
19
|
+
@@endpoint_id[self.name.downcase]
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.search(platform, query)
|
23
|
+
search = LoL::Search.new
|
24
|
+
search.resource("#{self.endpoints[:singular]}")
|
25
|
+
search.query(platform, query)
|
26
|
+
self.new(search.fetch)
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
alias_method :find, :search
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(attributes={})
|
34
|
+
attributes.each do |key, value|
|
35
|
+
if self.respond_to?(key.to_sym)
|
36
|
+
self.instance_variable_set("@#{key}", value)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module LoL
|
2
|
+
class Search
|
3
|
+
def initialize(resource=nil)
|
4
|
+
@params = {}
|
5
|
+
@resource = resource.nil? ? '/player/euw/' : resource
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
def query(platform, query)
|
10
|
+
@platform = "#{platform}/"
|
11
|
+
@query = "#{query}"
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def resource(resource)
|
16
|
+
if resource == 'player' then
|
17
|
+
@resource = '/player/'
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
#Sends back main data
|
23
|
+
def fetch()
|
24
|
+
fetch_response['data']
|
25
|
+
end
|
26
|
+
|
27
|
+
#Send back whole response
|
28
|
+
def fetch_response
|
29
|
+
response = Api.get(@resource + @platform + @query)
|
30
|
+
response.to_hash
|
31
|
+
end
|
32
|
+
|
33
|
+
#Send back whole response
|
34
|
+
def fetch_resource
|
35
|
+
response = Api.get(@resource)
|
36
|
+
response.to_hash
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/captainteemo.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
["api","search","resource"].each do |inc|
|
5
|
+
require File.join(File.dirname(__FILE__), "captainteemo", inc)
|
6
|
+
end
|
7
|
+
|
8
|
+
["player"].each do |inc|
|
9
|
+
require File.join(File.dirname(__FILE__), "captainteemo", inc)
|
10
|
+
end
|
11
|
+
|
12
|
+
module LoL
|
13
|
+
VERSION = "0.0.1"
|
14
|
+
end
|
15
|
+
|
16
|
+
#@search = LoL::Search.new
|
17
|
+
#@search.resource('player')
|
18
|
+
#@search.query('skrillux')
|
19
|
+
#puts @search.fetch
|
20
|
+
|
21
|
+
#@player = LoL::Player.find("euw", "skrillux")
|
22
|
+
#puts @player.name
|
23
|
+
|
24
|
+
#puts LoL::Player.runes("euw", "skrillux")
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: captainteemo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ahmet Abdi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Wrapper for http://api.captainteemo.com/_docs/index.php
|
31
|
+
email:
|
32
|
+
- ahmetabdi@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- captainteemo.gemspec
|
38
|
+
- lib/captainteemo.rb
|
39
|
+
- lib/captainteemo/api.rb
|
40
|
+
- lib/captainteemo/player.rb
|
41
|
+
- lib/captainteemo/resource.rb
|
42
|
+
- lib/captainteemo/search.rb
|
43
|
+
homepage: http://rubygems.org/gems/captainteemo
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: captainteemo
|
63
|
+
rubygems_version: 1.8.24
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: A Ruby wrapper for league of legends information, API from http://api.captainteemo.com/_docs/index.php
|
67
|
+
test_files: []
|