lolbase 0.4.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c5b69ef5bed39cda2abb25d0e963288727858f8a
4
- data.tar.gz: e15c0be707b1fec1bfeddeaf6d1ee9a4950e0bc2
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2FiZjU1Yzg4OTRmZWQ2NzYzODVjODViMTBlMDlkMzRmODM0MThiYQ==
5
+ data.tar.gz: !binary |-
6
+ OWI5NjUyYzRlYzEyNmI3MmY3YTVjNzM5ZTliZjljMzEwYmNmODE1MQ==
5
7
  SHA512:
6
- metadata.gz: 0297f5dd95ed99c5450e07a45b81e3124264c27574c68f609c3f5a6156db5a96d869821bfac96c4520a94d6eb11935cef558721970cb162b2fa2b9a66feb0981
7
- data.tar.gz: 01e5f3b76bb4514e8967a98c6af4899242480a13f968fa671c8e70bd9aaddc0eaae9fa02adce817b5720bdb15012764386807f27254fccea44a8f6fde220148d
8
+ metadata.gz: !binary |-
9
+ YWNlNzA3MTgwNzNkNDJmNmE4NDUyNDJkMjM4OGIzNzU2YzBmOTMxMTRjODM5
10
+ N2RmYTk2MjY1ZGI2MzhiYWEwZTU5ZjIwN2QwMTYwYTRlMDU0ZDk3NTFhOTQy
11
+ ZWRmM2FmZWE4Y2QzYzJkNjgzZDdhZjNlMzgxNjEyMWM5YzI5NmI=
12
+ data.tar.gz: !binary |-
13
+ ZmFhNjJjOGZiYmE1Zjc4Mzg5OTkzMThkNDYyZjlkNDk5NGUxM2VmMTE5MzNh
14
+ YTFjNTVmYjFlZDJkM2ViZjhiYzM0MDVkYjQ1ZTBmN2FmNDRkYmI1ODRhNjY1
15
+ ODVlMTUyYzIwYTUyMzFjNzZkOTU4ZjRmYWRhZGQxMGI4Yjg1NDQ=
@@ -1,7 +1,15 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
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
@@ -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
 
@@ -12,6 +12,8 @@ module LoLBase
12
12
  end
13
13
 
14
14
  def find(criteria = {})
15
+ raise InvalidArgumentError if criteria.class != Hash
16
+
15
17
  if criteria[:id]
16
18
  return @champions.select { |champ| champ.id == criteria[:id] }.first
17
19
  elsif criteria[:name]
@@ -14,19 +14,26 @@ module LoLBase
14
14
  end
15
15
 
16
16
  def summary(season = LoLBase.config.current_season)
17
- response = @connection.get(
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}/ranked",
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
- RankedStats.new response
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
@@ -1,4 +1,7 @@
1
1
  module LoLBase
2
2
  class LoLBaseError < StandardError
3
3
  end
4
+
5
+ class InvalidArgumentError < LoLBaseError
6
+ end
4
7
  end
@@ -1,3 +1,3 @@
1
1
  module LoLBase
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -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
@@ -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"
@@ -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
@@ -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.0
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.0.3
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: