league_of_legends 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ecc7dd2c6bbe476cb20c0a555a47fca80fbabbce
4
+ data.tar.gz: 4f81bd5b7e31e558ea930bd7ea9e1f2e4d89f184
5
+ SHA512:
6
+ metadata.gz: 0954d361c173bb8f729d3d931362116e5c48840c20d45e4a7a64c358c2466728207a926a84aa0b9a7b8153a7e5518dc54543f7fd2166789343b8b9fa33ebb8a4
7
+ data.tar.gz: 40951e499982bd5f7f9547265fb2b4337502c7e0fd254558927d42bb7c78a4545193ab017a9f8c9a140f7b599aef2d35702b0cd367b388bc7a1c7f560e8da9c5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in league_of_legends.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Francisco Orvalho
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # LeagueOfLegends
2
+
3
+ This gem implements the League Of Legends API (currently in open beta). It will continue to be updated as the API evolves.
4
+
5
+ This product is not endorsed, certified or otherwise approved in any way by Riot Games, Inc. or any of its affiliates.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'league_of_legends'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install league_of_legends
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( http://github.com/<my-github-username>/league_of_legends/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'league_of_legends/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "league_of_legends"
8
+ spec.version = LeagueOfLegends::VERSION
9
+ spec.authors = ["Francisco Orvalho"]
10
+ spec.email = ["francisco.orvalho@gmail.com"]
11
+ spec.summary = %q{Implementation of the LoL API}
12
+ spec.description = %q{This gem implements the League Of Legends API (currently in open beta). It will continue to be updated as the API evolves.
13
+
14
+ This product is not endorsed, certified or otherwise approved in any way by Riot Games, Inc. or any of its affiliates.}
15
+ spec.homepage = "http://github.com/forvalho/league_of_legends"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,5 @@
1
+ require "league_of_legends/version"
2
+
3
+ module LeagueOfLegends
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,90 @@
1
+ module ::LeagueOfLegends
2
+ module DTO
3
+ class AggregatedStats
4
+
5
+ attr_reader :average_assists, :average_champions_killed,
6
+ :average_combat_player_score, :average_node_capture,
7
+ :average_node_capture_assist, :average_node_neutralize,
8
+ :average_node_neutralize_assist, :average_num_deaths,
9
+ :average_objective_player_score, :average_team_objective,
10
+ :average_total_player_score, :bot_games_layed, :killing_spree,
11
+ :max_assists, :max_champions_killed, :max_combat_player_score,
12
+ :max_largest_critical_strike, :max_largest_killing_spree,
13
+ :max_node_capture, :max_node_capture_assist, :max_node_neutralize,
14
+ :max_node_neutralize_assist, :max_num_deaths,
15
+ :max_objective_player_score, :max_team_objective, :max_time_played,
16
+ :max_time_spent_living, :max_total_player_score,
17
+ :most_champion_kills_per_session, :most_spells_cast,
18
+ :normal_games_played, :ranked_premade_games_played,
19
+ :ranked_solo_games_played, :total_assists, :total_champion_kills,
20
+ :total_damage_dealt, :total_damage_taken, :total_deaths_per_session,
21
+ :total_double_kills, :total_first_blood, :total_gold_earned,
22
+ :total_heal, :total_magic_damage_dealt, :total_minion_kills,
23
+ :total_neutral_minions_killed, :total_node_capture,
24
+ :total_node_neutralize, :total_penta_kills, :total_physical_damage_dealt,
25
+ :total_quadra_kills, :total_sessions_lost, :total_sessions_played,
26
+ :total_sessions_won, :total_triple_kills, :total_turrets_killed,
27
+ :total_unreal_kills
28
+
29
+ def initialize attributes
30
+ @average_assists = attributes[:averageAssists].to_i
31
+ @average_champions_killed = attributes[:averageChampionsKilled].to_i
32
+ @average_combat_player_score = attributes[:averageCombatPlayerScore].to_i
33
+ @average_node_capture = attributes[:averageNodeCapture].to_i
34
+ @average_node_capture_assist = attributes[:averageNodeCaptureAssist].to_i
35
+ @average_node_neutralize = attributes[:averageNodeNeutralize].to_i
36
+ @average_node_neutralize_assist = attributes[:averageNodeNeutralizeAssist].to_i
37
+ @average_num_deaths = attributes[:averageNumDeaths].to_i
38
+ @average_objective_player_score = attributes[:averageObjectivePlayerScore].to_i
39
+ @average_team_objective = attributes[:averageTeamObjective].to_i
40
+ @average_total_player_score = attributes[:averageTotalPlayerScore].to_i
41
+ @bot_games_layed = attributes[:botGamesPlayed].to_i
42
+ @killing_spree = attributes[:killingSpree].to_i
43
+ @max_assists = attributes[:maxAssists].to_i
44
+ @max_champions_killed = attributes[:maxChampionsKilled].to_i
45
+ @max_combat_player_score = attributes[:maxCombatPlayerScore].to_i
46
+ @max_largest_critical_strike = attributes[:maxLargestCriticalStrike].to_i
47
+ @max_largest_killing_spree = attributes[:maxLargestKillingSpree].to_i
48
+ @max_node_capture = attributes[:maxNodeCapture].to_i
49
+ @max_node_capture_assist = attributes[:maxNodeCaptureAssist].to_i
50
+ @max_node_neutralize = attributes[:maxNodeNeutralize].to_i
51
+ @max_node_neutralize_assist = attributes[:maxNodeNeutralizeAssist].to_i
52
+ @max_num_deaths = attributes[:maxNumDeaths].to_i
53
+ @max_objective_player_score = attributes[:maxObjectivePlayerScore].to_i
54
+ @max_team_objective = attributes[:maxTeamObjective].to_i
55
+ @max_time_played = attributes[:maxTimePlayed].to_i
56
+ @max_time_spent_living = attributes[:maxTimeSpentLiving].to_i
57
+ @max_total_player_score = attributes[:maxTotalPlayerScore].to_i
58
+ @most_champion_kills_per_session = attributes[:mostChampionKillsPerSession].to_i
59
+ @most_spells_cast = attributes[:mostSpellsCast].to_i
60
+ @normal_games_played = attributes[:normalGamesPlayed].to_i
61
+ @ranked_premade_games_played = attributes[:rankedPremadeGamesPlayed].to_i
62
+ @ranked_solo_games_played = attributes[:rankedSoloGamesPlayed].to_i
63
+ @total_assists = attributes[:totalAssists].to_i
64
+ @total_champion_kills = attributes[:totalChampionKills].to_i
65
+ @total_damage_dealt = attributes[:totalDamageDealt].to_i
66
+ @total_damage_taken = attributes[:totalDamageTaken].to_i
67
+ @total_deaths_per_session = attributes[:totalDeathsPerSession].to_i
68
+ @total_double_kills = attributes[:totalDoubleKills].to_i
69
+ @total_first_blood = attributes[:totalFirstBlood].to_i
70
+ @total_gold_earned = attributes[:totalGoldEarned].to_i
71
+ @total_heal = attributes[:totalHeal].to_i
72
+ @total_magic_damage_dealt = attributes[:totalMagicDamageDealt].to_i
73
+ @total_minion_kills = attributes[:totalMinionKills].to_i
74
+ @total_neutral_minions_killed = attributes[:totalNeutralMinionsKilled].to_i
75
+ @total_node_capture = attributes[:totalNodeCapture].to_i
76
+ @total_node_neutralize = attributes[:totalNodeNeutralize].to_i
77
+ @total_penta_kills = attributes[:totalPentaKills].to_i
78
+ @total_physical_damage_dealt = attributes[:totalPhysicalDamageDealt].to_i
79
+ @total_quadra_kills = attributes[:totalQuadraKills].to_i
80
+ @total_sessions_lost = attributes[:totalSessionsLost].to_i
81
+ @total_sessions_played = attributes[:totalSessionsPlayed].to_i
82
+ @total_sessions_won = attributes[:totalSessionsWon].to_i
83
+ @total_triple_kills = attributes[:totalTripleKills].to_i
84
+ @total_turrets_killed = attributes[:totalTurretsKilled].to_i
85
+ @total_unreal_kills = attributes[:totalUnrealKills].to_i
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,15 @@
1
+ require 'json'
2
+
3
+ module ::LeagueOfLegends
4
+ module DTO
5
+ class Base
6
+
7
+ protected
8
+
9
+ def build_attributes json
10
+ JSON.parse(json, symbolize_names: true)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module ::LeagueOfLegends
2
+ module DTO
3
+ class PlayerStatsSummary
4
+
5
+ attr_reader :player_stat_summary_type, :wins,
6
+ :losses, :modify_date, :aggregated_stats
7
+
8
+ def initialize attributes
9
+ @player_stat_summary_type = attributes[:playerStatSummaryType]
10
+ @wins = attributes[:wins].to_i
11
+ @losses = attributes[:losses].to_i
12
+ @modify_date = Time.at(attributes[:modifyDate]/1000)
13
+ @aggregated_stats = ::LeagueOfLegends::DTO::AggregatedStats.new(attributes[:aggregatedStats])
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module ::LeagueOfLegends
2
+ module DTO
3
+ class PlayerStatsSummaryList < ::LeagueOfLegends::DTO::Base
4
+
5
+ attr_reader :summoner_id, :player_stat_summaries
6
+
7
+ def initialize json
8
+ @attributes = build_attributes json
9
+ @summoner_id = attributes[:summonerId].to_i
10
+ @player_stat_summaries = attributes[:playerStatSummaries].map do |pss|
11
+ ::LeagueOfLegends::DTO::PlayerStatsSummary.new(pss)
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :attributes
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module LeagueOfLegends
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,22 @@
1
+ require 'league_of_legends/dto/aggregated_stats'
2
+
3
+ describe ::LeagueOfLegends::DTO::AggregatedStats do
4
+
5
+ let(:attributes) { {
6
+ totalChampionKills: 72,
7
+ totalMinionKills: 1530,
8
+ totalTurretsKilled: 29,
9
+ totalNeutralMinionsKilled: 339,
10
+ totalAssists: 75
11
+ } }
12
+ let(:dto) { described_class.new(attributes) }
13
+
14
+ it "has attributes" do
15
+ expect(dto.total_champion_kills).to eq 72
16
+ expect(dto.total_minion_kills).to eq 1530
17
+ expect(dto.total_turrets_killed).to eq 29
18
+ expect(dto.total_neutral_minions_killed).to eq 339
19
+ expect(dto.total_assists).to eq 75
20
+ end
21
+
22
+ end
@@ -0,0 +1,5 @@
1
+ require 'league_of_legends/dto/base'
2
+
3
+ describe ::LeagueOfLegends::DTO::Base do
4
+
5
+ end
@@ -0,0 +1,65 @@
1
+ require 'league_of_legends/dto/player_stats_summary_list'
2
+ require 'league_of_legends/dto/player_stats_summary_list'
3
+
4
+ describe ::LeagueOfLegends::DTO::PlayerStatsSummaryList do
5
+
6
+ json = '{
7
+ "summonerId":50519866,
8
+ "playerStatSummaries":
9
+ [
10
+ {
11
+ "playerStatSummaryType":"CoopVsAI",
12
+ "wins":13,
13
+ "modifyDate":1385389596000,
14
+ "aggregatedStats":
15
+ {
16
+ "totalChampionKills":72,
17
+ "totalMinionKills":1530,
18
+ "totalTurretsKilled":29,
19
+ "totalNeutralMinionsKilled":339,
20
+ "totalAssists":75
21
+ }
22
+ },
23
+ {
24
+ "playerStatSummaryType":"OdinUnranked",
25
+ "wins":0,
26
+ "modifyDate":1388758443000,
27
+ "aggregatedStats":
28
+ {
29
+ }
30
+ },
31
+ {
32
+ "playerStatSummaryType":"Unranked",
33
+ "wins":6,
34
+ "modifyDate":1389882950000,
35
+ "aggregatedStats":
36
+ {
37
+ "totalChampionKills":121,
38
+ "totalMinionKills":758,
39
+ "totalTurretsKilled":11,
40
+ "totalNeutralMinionsKilled":182,
41
+ "totalAssists":62
42
+ }
43
+ },
44
+ {
45
+ "playerStatSummaryType":"Unranked3x3",
46
+ "wins":0,
47
+ "modifyDate":1388758443000,
48
+ "aggregatedStats":
49
+ {
50
+ }
51
+ }
52
+ ]
53
+ }'
54
+ let(:dto){ described_class.new(json) }
55
+
56
+ it "has attributes" do
57
+ expect(dto.summoner_id).to eq 50519866
58
+ expect(dto.player_stat_summaries.is_a? Array).to eq true
59
+
60
+ dto.player_stat_summaries.each do |pss|
61
+ expect(pss.is_a? ::LeagueOfLegends::DTO::PlayerStatsSummary).to eq true
62
+ end
63
+ end
64
+
65
+ end
@@ -0,0 +1,28 @@
1
+ require 'league_of_legends/dto/player_stats_summary'
2
+
3
+ describe LeagueOfLegends::DTO::PlayerStatsSummary do
4
+
5
+ let(:attributes) { {
6
+ playerStatSummaryType: 'CoopVsAI',
7
+ wins: 13,
8
+ modifyDate: 1385389596000,
9
+ aggregatedStats:
10
+ {
11
+ totalChampionKills: 72,
12
+ totalMinionKills: 1530,
13
+ totalTurretsKilled: 29,
14
+ totalNeutralMinionsKilled: 339,
15
+ totalAssists: 75
16
+ }
17
+ } }
18
+ let(:dto) { described_class.new(attributes) }
19
+
20
+ it "has attributes" do
21
+ expect(dto.player_stat_summary_type).to eq 'CoopVsAI'
22
+ expect(dto.wins).to eq 13
23
+ expect(dto.losses).to eq 0
24
+ expect(dto.modify_date).to eq Time.new(2013,11,25,14,26,36)
25
+ expect(dto.aggregated_stats.is_a?(LeagueOfLegends::DTO::AggregatedStats)).to eq true
26
+ end
27
+
28
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: league_of_legends
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Francisco Orvalho
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |-
42
+ This gem implements the League Of Legends API (currently in open beta). It will continue to be updated as the API evolves.
43
+
44
+ This product is not endorsed, certified or otherwise approved in any way by Riot Games, Inc. or any of its affiliates.
45
+ email:
46
+ - francisco.orvalho@gmail.com
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - .gitignore
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - league_of_legends.gemspec
57
+ - lib/league_of_legends.rb
58
+ - lib/league_of_legends/dto/aggregated_stats.rb
59
+ - lib/league_of_legends/dto/base.rb
60
+ - lib/league_of_legends/dto/player_stats_summary.rb
61
+ - lib/league_of_legends/dto/player_stats_summary_list.rb
62
+ - lib/league_of_legends/version.rb
63
+ - spec/dto/aggregated_stats_spec.rb
64
+ - spec/dto/base_spec.rb
65
+ - spec/dto/player_stats_summary_list_spec.rb
66
+ - spec/dto/player_stats_summary_spec.rb
67
+ homepage: http://github.com/forvalho/league_of_legends
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.0.14
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Implementation of the LoL API
91
+ test_files:
92
+ - spec/dto/aggregated_stats_spec.rb
93
+ - spec/dto/base_spec.rb
94
+ - spec/dto/player_stats_summary_list_spec.rb
95
+ - spec/dto/player_stats_summary_spec.rb