vigor 0.1.0
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/lib/vigor.rb +62 -0
- metadata +79 -0
data/lib/vigor.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Vigor
|
4
|
+
class Client
|
5
|
+
include HTTParty
|
6
|
+
base_uri "http://prod.api.pvp.net/api/lol/na/v1.1"
|
7
|
+
# debug_output $stderr
|
8
|
+
|
9
|
+
def initialize(api_key)
|
10
|
+
self.class.default_params :api_key => api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def summoner(lookup_value)
|
14
|
+
if lookup_value.is_a? String
|
15
|
+
return Summoner.new(self.class.get("/summoner/by-name/" + lookup_value))
|
16
|
+
else
|
17
|
+
return Summoner.new(self.class.get("/summoner/" + lookup_value.to_s))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Summoner
|
23
|
+
attr_accessor :id, :name, :profile_icon_id, :level, :revision_date
|
24
|
+
|
25
|
+
def initialize(data)
|
26
|
+
@id = data["id"]
|
27
|
+
@name = data["name"]
|
28
|
+
@profile_icon_id = data["profileIconId"]
|
29
|
+
@level = data["summonerLevel"]
|
30
|
+
@revision_date = DateTime.strptime(data["revisionDate"].to_s,'%s')
|
31
|
+
end
|
32
|
+
|
33
|
+
def mastery_pages
|
34
|
+
mastery_hash = Client.get("/summoner/" + @id.to_s + "/masteries")
|
35
|
+
return mastery_hash["pages"].map {|page| MasteryPage.new(page)}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class MasteryPage
|
40
|
+
attr_accessor :talents, :name
|
41
|
+
|
42
|
+
def initialize(data)
|
43
|
+
@talents = data["talents"].map {|talent| Talent.new(talent)}
|
44
|
+
@name = data["name"]
|
45
|
+
@current = data["current"]
|
46
|
+
end
|
47
|
+
|
48
|
+
def current?
|
49
|
+
@current
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Talent
|
54
|
+
attr_accessor :id, :rank, :name
|
55
|
+
|
56
|
+
def initialize(data)
|
57
|
+
@id = data["id"]
|
58
|
+
@rank = data["rank"]
|
59
|
+
@name = data["name"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vigor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Peter Borah
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-11 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
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: This aims to be a idiomatic Ruby wrapper for the League of Legends API.
|
47
|
+
Very much a work in progress at the moment.
|
48
|
+
email: peterborah@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/vigor.rb
|
54
|
+
homepage: https://github.com/PeterBorah/vigor
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.24
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Unofficial League of Legends API wrapper
|
79
|
+
test_files: []
|