lolbase 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.travis.yml +15 -7
- data/lib/lolbase/connection.rb +2 -0
- data/lib/lolbase/data/champion.rb +2 -0
- data/lib/lolbase/data/stats.rb +16 -7
- data/lib/lolbase/error.rb +3 -0
- data/lib/lolbase/version.rb +1 -1
- data/spec/champion_data_spec.rb +4 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/stats_data_spec.rb +8 -0
- data/spec/summoner_data_spec.rb +4 -0
- metadata +12 -13
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2FiZjU1Yzg4OTRmZWQ2NzYzODVjODViMTBlMDlkMzRmODM0MThiYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWI5NjUyYzRlYzEyNmI3MmY3YTVjNzM5ZTliZjljMzEwYmNmODE1MQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWNlNzA3MTgwNzNkNDJmNmE4NDUyNDJkMjM4OGIzNzU2YzBmOTMxMTRjODM5
|
10
|
+
N2RmYTk2MjY1ZGI2MzhiYWEwZTU5ZjIwN2QwMTYwYTRlMDU0ZDk3NTFhOTQy
|
11
|
+
ZWRmM2FmZWE4Y2QzYzJkNjgzZDdhZjNlMzgxNjEyMWM5YzI5NmI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmFhNjJjOGZiYmE1Zjc4Mzg5OTkzMThkNDYyZjlkNDk5NGUxM2VmMTE5MzNh
|
14
|
+
YTFjNTVmYjFlZDJkM2ViZjhiYzM0MDVkYjQ1ZTBmN2FmNDRkYmI1ODRhNjY1
|
15
|
+
ODVlMTUyYzIwYTUyMzFjNzZkOTU4ZjRmYWRhZGQxMGI4Yjg1NDQ=
|
data/.travis.yml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
script: bundle exec rspec spec
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
|
7
|
+
script: bundle exec rspec spec
|
8
|
+
|
9
|
+
deploy:
|
10
|
+
provider: rubygems
|
11
|
+
api_key:
|
12
|
+
secure: dkuO+YOJo2ylm/ipkCdz/OVENYo/B1e6ai44sKBleKYEbkxwRifh/jEaXcA8KKwhmcVVcQEoodUZD0lKdzcEdi5YMyzoGqdLeSwsSslNaMvbsYKH0C3h1WQlh2fHL3rRyrUhEQ+V9BxXbjWvPUa9OQUrHW/jP4TZ4yVO1yNskl8=
|
13
|
+
gem: lolbase
|
14
|
+
on:
|
15
|
+
repo: Illianthe/lolbase
|
data/lib/lolbase/connection.rb
CHANGED
@@ -37,10 +37,12 @@ module LoLBase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def summoner_by_name(name, region = LoLBase.config.default_region)
|
40
|
+
raise InvalidArgumentError if !name.is_a?(String)
|
40
41
|
Summoner.new({ name: name, region: region }, self)
|
41
42
|
end
|
42
43
|
|
43
44
|
def summoner_by_id(id, region = LoLBase.config.default_region)
|
45
|
+
raise InvalidArgumentError if !id.is_a?(Integer)
|
44
46
|
Summoner.new({ id: id, region: region }, self)
|
45
47
|
end
|
46
48
|
|
data/lib/lolbase/data/stats.rb
CHANGED
@@ -14,19 +14,26 @@ module LoLBase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def summary(season = LoLBase.config.current_season)
|
17
|
-
|
18
|
-
"/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/summary",
|
19
|
-
{ query: { season: "SEASON#{season}" } }
|
20
|
-
)
|
21
|
-
SummaryStats.new response
|
17
|
+
fetch_stats(:summary, season)
|
22
18
|
end
|
23
19
|
|
24
20
|
def ranked(season = LoLBase.config.current_season)
|
21
|
+
fetch_stats(:ranked, season)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def fetch_stats(type, season)
|
25
27
|
response = @connection.get(
|
26
|
-
"/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}
|
28
|
+
"/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/#{type}",
|
27
29
|
{ query: { season: "SEASON#{season}" } }
|
28
30
|
)
|
29
|
-
|
31
|
+
|
32
|
+
if type == :summary
|
33
|
+
return SummaryStats.new response
|
34
|
+
elsif type == :ranked
|
35
|
+
return RankedStats.new response
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
32
39
|
|
@@ -52,6 +59,7 @@ module LoLBase
|
|
52
59
|
end
|
53
60
|
|
54
61
|
def find(criteria = {})
|
62
|
+
raise InvalidArgumentError if criteria.class != Hash
|
55
63
|
if criteria[:name]
|
56
64
|
return @parsed_data.select { |item| item.name == criteria[:name] }.first
|
57
65
|
end
|
@@ -102,6 +110,7 @@ module LoLBase
|
|
102
110
|
end
|
103
111
|
|
104
112
|
def find(criteria = {})
|
113
|
+
raise InvalidArgumentError if criteria.class != Hash
|
105
114
|
if criteria[:champion_id]
|
106
115
|
return @parsed_data.select { |item| item.id == criteria[:champion_id] }.first
|
107
116
|
end
|
data/lib/lolbase/error.rb
CHANGED
data/lib/lolbase/version.rb
CHANGED
data/spec/champion_data_spec.rb
CHANGED
@@ -33,4 +33,8 @@ describe LoLBase::Champion do
|
|
33
33
|
f2p = @connection.champions.find(free_to_play: true)
|
34
34
|
expect(f2p.count).to eq(10)
|
35
35
|
end
|
36
|
+
|
37
|
+
it "should throw an error when trying to find a champion with invalid parameters" do
|
38
|
+
expect { @connection.champions.find("free") }.to raise_error(LoLBase::InvalidArgumentError)
|
39
|
+
end
|
36
40
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,18 +4,26 @@ require "lolbase"
|
|
4
4
|
RSpec.configure do |config|
|
5
5
|
config.before(:each) do
|
6
6
|
stub_info = [
|
7
|
+
# Summoner lookup
|
7
8
|
{
|
8
9
|
file: File.read(File.expand_path("../json/summoner/1.2/summoner.json", __FILE__)),
|
9
10
|
url: "https://prod.api.pvp.net/api/lol/na/v1.2/summoner/by-name/illianthe?api_key=random-key"
|
10
11
|
},
|
12
|
+
{
|
13
|
+
file: File.read(File.expand_path("../json/summoner/1.2/summoner.json", __FILE__)),
|
14
|
+
url: "https://prod.api.pvp.net/api/lol/na/v1.2/summoner/19578577?api_key=random-key"
|
15
|
+
},
|
16
|
+
# Summary stats
|
11
17
|
{
|
12
18
|
file: File.read(File.expand_path("../json/stats/1.2/summary_s3.json", __FILE__)),
|
13
19
|
url: "https://prod.api.pvp.net/api/lol/na/v1.2/stats/by-summoner/19578577/summary?api_key=random-key&season=SEASON3"
|
14
20
|
},
|
21
|
+
# Ranked stats
|
15
22
|
{
|
16
23
|
file: File.read(File.expand_path("../json/stats/1.2/ranked_s3.json", __FILE__)),
|
17
24
|
url: "https://prod.api.pvp.net/api/lol/na/v1.2/stats/by-summoner/19578577/ranked?api_key=random-key&season=SEASON3"
|
18
25
|
},
|
26
|
+
# Champion lookup
|
19
27
|
{
|
20
28
|
file: File.read(File.expand_path("../json/champion/1.1/champions.json", __FILE__)),
|
21
29
|
url: "https://prod.api.pvp.net/api/lol/na/v1.1/champion?api_key=random-key"
|
data/spec/stats_data_spec.rb
CHANGED
@@ -38,4 +38,12 @@ describe LoLBase::Stats do
|
|
38
38
|
overall = @illianthe.stats.ranked.overall
|
39
39
|
expect(overall["totalDamageTaken"]).to eq(583858)
|
40
40
|
end
|
41
|
+
|
42
|
+
it "should throw an error when trying to filter stats with an invalid parameter" do
|
43
|
+
ranked = @illianthe.stats.ranked
|
44
|
+
expect { ranked.find("Criteria") }.to raise_error(LoLBase::InvalidArgumentError)
|
45
|
+
|
46
|
+
summary = @illianthe.stats.summary
|
47
|
+
expect { summary.find("Blah") }.to raise_error(LoLBase::InvalidArgumentError)
|
48
|
+
end
|
41
49
|
end
|
data/spec/summoner_data_spec.rb
CHANGED
@@ -19,6 +19,10 @@ describe LoLBase::Summoner do
|
|
19
19
|
expect(@illianthe.profile_icon.id).to eq(539)
|
20
20
|
end
|
21
21
|
|
22
|
+
it "should allow for summoner lookups by ID" do
|
23
|
+
summoner = @connection.summoner(19578577)
|
24
|
+
end
|
25
|
+
|
22
26
|
context "Stats" do
|
23
27
|
it "should return a generic Stats object when called without arguments" do
|
24
28
|
expect(@illianthe.stats.class).to eq(LoLBase::Stats)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Regan Chan
|
@@ -28,56 +28,56 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - '>='
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - '>='
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: webmock
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - '>='
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - '>='
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: A basic Ruby wrapper for the League of Legends API.
|
@@ -122,17 +122,17 @@ require_paths:
|
|
122
122
|
- lib
|
123
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- - '>='
|
125
|
+
- - ! '>='
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: '0'
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - '>='
|
130
|
+
- - ! '>='
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.1.11
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: A basic Ruby wrapper for the League of Legends API.
|
@@ -146,4 +146,3 @@ test_files:
|
|
146
146
|
- spec/spec_helper.rb
|
147
147
|
- spec/stats_data_spec.rb
|
148
148
|
- spec/summoner_data_spec.rb
|
149
|
-
has_rdoc:
|