sightstone 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/lib/sightstone/masterybook.rb +12 -0
- data/lib/sightstone/modules/summoner_module.rb +29 -7
- data/lib/sightstone/runebook.rb +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1ae542a57feb0c02b9c0edda4af3f15c12efc3e
|
4
|
+
data.tar.gz: 8190b20a31a41ed7049b5c61117abe922efa4822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ff572e25f88aad085f6ba142e851511b44af196830ed2d8271c0d51d9af49ced9c3119d2501ab4670f5a8c1541d52e611e2874fb1ebb68f484776ccadb2d39
|
7
|
+
data.tar.gz: 1e3c54e978dbbea24cd2fef83aaf34d561f0682a9817aa112940c04f8a2e6fcd407443d60d6ac53372d38632bca6ef405eaf471984e6faa3cb6651990c630840
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Class to represent the masterybook of a summoner
|
2
|
+
# @attr [Numeric] summonerId id of the summoner
|
3
|
+
# @attr [Array<MasteryPage>] pages of the masterybook
|
1
4
|
class MasteryBook
|
2
5
|
attr_accessor :pages, :summonerId
|
3
6
|
|
@@ -10,6 +13,11 @@ class MasteryBook
|
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
16
|
+
# Class to represent a page of a masterybook
|
17
|
+
# @attr [Numeric] id ID of the page
|
18
|
+
# @attr [String] name page name
|
19
|
+
# @attr [Boolean] current indicates if the page is selected
|
20
|
+
# @attr [Array<Talent>] array of selected talents
|
13
21
|
class MasteryPage
|
14
22
|
attr_accessor :id, :talents, :name, :current
|
15
23
|
|
@@ -25,6 +33,10 @@ class MasteryPage
|
|
25
33
|
|
26
34
|
end
|
27
35
|
|
36
|
+
# Class to represent a talent of a mastery page
|
37
|
+
# @attr [Numeric] id id of the mastery
|
38
|
+
# @attr [String] name of the mastery
|
39
|
+
# @attr [Numeric] rank rank of the mastery
|
28
40
|
class Talent
|
29
41
|
attr_accessor :id,:rank, :name
|
30
42
|
|
@@ -4,17 +4,23 @@ require 'sightstone/masterybook'
|
|
4
4
|
require 'sightstone/runebook'
|
5
5
|
require 'open-uri'
|
6
6
|
|
7
|
+
# Module to provide calls to the summoner api
|
7
8
|
class SummonerModule < SightstoneBaseModule
|
9
|
+
|
8
10
|
def initialize(sightstone)
|
9
11
|
@sightstone = sightstone
|
10
12
|
end
|
11
13
|
|
14
|
+
# returns a summoner object
|
15
|
+
# @param name_or_id [Integer, String] name or id of the summoner
|
16
|
+
# @param optional [Hash] optional arguments: :region => replaces default region
|
17
|
+
# @ return [Summoner] summoner
|
12
18
|
def summoner(name_or_id, optional={})
|
13
19
|
region = optional[:region] || @sightstone.region
|
14
20
|
uri = if name_or_id.is_a? Integer
|
15
|
-
"https://prod.api.pvp.net/api/lol/#{region}/v1.
|
21
|
+
"https://prod.api.pvp.net/api/lol/#{region}/v1.2/summoner/#{name_or_id}"
|
16
22
|
else
|
17
|
-
"https://prod.api.pvp.net/api/lol/#{region}/v1.
|
23
|
+
"https://prod.api.pvp.net/api/lol/#{region}/v1.2/summoner/by-name/#{URI::encode(name_or_id)}"
|
18
24
|
end
|
19
25
|
|
20
26
|
response = _get_api_response(uri)
|
@@ -24,18 +30,30 @@ class SummonerModule < SightstoneBaseModule
|
|
24
30
|
}
|
25
31
|
end
|
26
32
|
|
27
|
-
|
33
|
+
# returns the names for the ids
|
34
|
+
# @param ids [Array<Numeric>] ids
|
35
|
+
# @param optional [Hash<Symbol, String>] optional arguments: :region => replaces default region
|
36
|
+
# @return [Hash<Numeric, String>] a hash matching each id to the summoners name
|
28
37
|
def names(ids, optional={})
|
29
38
|
region = optional[:region] || @sightstone.region
|
30
39
|
ids = ids.join(',')
|
31
|
-
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.
|
40
|
+
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.2/summoner/#{ids}/name"
|
32
41
|
response = _get_api_response(uri)
|
33
42
|
_parse_response(response) { |resp|
|
34
43
|
data = JSON.parse(resp)
|
35
|
-
|
44
|
+
names_array = data['summoners']
|
45
|
+
names_hash = Hash.new
|
46
|
+
names_array.each do |summoner|
|
47
|
+
names_hash[summoner['id']] = summoner['name']
|
48
|
+
end
|
49
|
+
return names_hash
|
36
50
|
}
|
37
51
|
end
|
38
52
|
|
53
|
+
# returns the runebook of a summoner
|
54
|
+
# @param summoner [Summoner, id] summoner object or id of a summoner
|
55
|
+
# @param optional [Hash<Symbol, String>] optional arguments: :region => replaces default region
|
56
|
+
# @return [Runebook] runebook of the summoner
|
39
57
|
def runes(summoner, optional={})
|
40
58
|
region = optional[:region] || @sightstone.region
|
41
59
|
id = if summoner.is_a? Summoner
|
@@ -43,7 +61,7 @@ class SummonerModule < SightstoneBaseModule
|
|
43
61
|
else
|
44
62
|
summoner
|
45
63
|
end
|
46
|
-
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.
|
64
|
+
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.2/summoner/#{id}/runes"
|
47
65
|
response = _get_api_response(uri)
|
48
66
|
_parse_response(response) { |resp|
|
49
67
|
data = JSON.parse(resp)
|
@@ -51,6 +69,10 @@ class SummonerModule < SightstoneBaseModule
|
|
51
69
|
}
|
52
70
|
end
|
53
71
|
|
72
|
+
# returns the masterybook of a summoner
|
73
|
+
# @param summoner [Summoner, id] summoner object or id of a summoner
|
74
|
+
# @param optional [Hash<Symbol, String>] optional arguments: :region => replaces default region
|
75
|
+
# @return [Masterybook] masterybook of the summoner
|
54
76
|
def masteries(summoner, optional={})
|
55
77
|
region = optional[:region] || @sightstone.region
|
56
78
|
id = if summoner.is_a? Summoner
|
@@ -58,7 +80,7 @@ class SummonerModule < SightstoneBaseModule
|
|
58
80
|
else
|
59
81
|
summoner
|
60
82
|
end
|
61
|
-
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.
|
83
|
+
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.2/summoner/#{id}/masteries"
|
62
84
|
response = _get_api_response(uri)
|
63
85
|
_parse_response(response) { |resp|
|
64
86
|
data = JSON.parse(resp)
|
data/lib/sightstone/runebook.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# Class to represent the runebook of a summoner
|
2
|
+
# @attr [Numeric] summonerId id of the summoner
|
3
|
+
# @attr [Array<RunePage>] pages of the runebook
|
1
4
|
class RuneBook
|
2
5
|
attr_accessor :pages, :summonerId
|
3
6
|
|
@@ -10,6 +13,11 @@ class RuneBook
|
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
16
|
+
# Class to represent a page of a runebook
|
17
|
+
# @attr [Numeric] id ID of the page
|
18
|
+
# @attr [String] name page name
|
19
|
+
# @attr [Boolean] current indicates if the page is selected
|
20
|
+
# @attr [Hash<Numeric, Rune>] slots matches slot ids to the rune
|
13
21
|
class RunePage
|
14
22
|
attr_accessor :id, :slots, :name, :current
|
15
23
|
|
@@ -25,6 +33,11 @@ class RunePage
|
|
25
33
|
|
26
34
|
end
|
27
35
|
|
36
|
+
# Class to represent a rune
|
37
|
+
# @attr [Numeric] id ID of the rune
|
38
|
+
# @attr [String] description description
|
39
|
+
# @attr [String] name name of the rune
|
40
|
+
# @attr [Numeric] tier rune tier (1,2,3)
|
28
41
|
class Rune
|
29
42
|
attr_accessor :id, :description, :name, :tier
|
30
43
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sightstone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bauer
|
@@ -63,7 +63,7 @@ files:
|
|
63
63
|
- lib/sightstone/summoner.rb
|
64
64
|
- lib/sightstone/team.rb
|
65
65
|
- lib/sightstone.rb
|
66
|
-
homepage:
|
66
|
+
homepage: https://github.com/danijoo/Sightstone
|
67
67
|
licenses:
|
68
68
|
- MIT
|
69
69
|
metadata: {}
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.0.6
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Ruby wrapper for riots league of legends api
|