overwatch_stats 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95f520db75d439300c3177eb54c18db4460eeaba
4
- data.tar.gz: 20cf615d2c2f1a574161a289b5f6d1b157937b9c
3
+ metadata.gz: c57a64d7d9a9147cc276521579b046220cc206db
4
+ data.tar.gz: afaaae2e08ea0df92fe25a5b69310b21740ea3ea
5
5
  SHA512:
6
- metadata.gz: bb27191b14778bf102d2ca5a7932bf65cc32e38e03307244e0c4c6c8e7deedeb1042fa02b4517075deecff968d101bb7885d7872189ba869d8cbe5d8d5f80d28
7
- data.tar.gz: 78aa37fb2935e66e246c835e414e42c51d2d24fb0d58d4d9ec3af551917256200c3166a1742f712747d231aa022e78b70bc76269d432829cd5af0aa5725b1d31
6
+ metadata.gz: 82daaa9ac816d968c252293d6a64b507b4571d2b991ccfa802beab25c9cc97e36053764281a120c4c7414380984b514319f36643ae1f7616dcd520c01da8ab8f
7
+ data.tar.gz: c38e19cfe61f80c0a8f89449b1d25315742e1728369a89f64ed8ce86e772ba4c8617dd96b432f5952ca66f0fce5653a5d1c74220eaf93af95d7710bb0cfa514b
data/lib/cli.rb CHANGED
@@ -14,7 +14,7 @@ class OverwatchStats::CLI
14
14
  end
15
15
 
16
16
  def menu
17
- puts "Type the following to change sorting rules: '(win)rate' '(pop)ularity' '(damage)min' '(kd)ratio' or '(alph)abetically'."
17
+ puts "Type the following to change sorting rules: '(win)rate' '(pop)ularity' 'medal(game)' '(kd)ratio' or '(alph)abetically'."
18
18
  puts "Type the name of one of the above heroes to see more about that hero."
19
19
  puts "Type 'exit' to exit."
20
20
 
@@ -25,8 +25,8 @@ class OverwatchStats::CLI
25
25
  elsif input == "popularity" || input == "pop"
26
26
  display_stats_popularity
27
27
  menu
28
- elsif input == "damagemin" || input == "damage"
29
- display_stats_damagemin
28
+ elsif input == "medalpergame" || input == "medal"
29
+ display_stats_medalpergame
30
30
  menu
31
31
  elsif input == "kdratio" || input == "kd"
32
32
  display_stats_herokd
@@ -112,15 +112,15 @@ class OverwatchStats::CLI
112
112
  puts ""
113
113
  puts " Stats Sorted Alphabetically"
114
114
  puts "==================================================================================="
115
- puts "|| HERO || TYPE || WINRATE || POPULARITY || DAMAGE/MIN || K/D Ratio ||"
115
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
116
116
  byalph.each.with_index(1) do |herostats, index|
117
117
  show_heroname = check_width(herostats[:heroname], index)
118
118
  show_herotype = check_width(herostats[:herotype], 1 , 8)
119
119
  show_winrate = check_width(herostats[:winrate], 1 , 7)
120
120
  show_popularity = check_width(herostats[:popularity], 1 , 8)
121
- show_damagemin = check_width(herostats[:damagemin], 1 , 8)
121
+ show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
122
122
  show_herokd = check_width(herostats[:herokd], 1 , 8)
123
- puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_damagemin} || #{show_herokd} ||"
123
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_medalpergame} || #{show_herokd} ||"
124
124
  end
125
125
  puts "==================================================================================="
126
126
  end
@@ -130,15 +130,15 @@ class OverwatchStats::CLI
130
130
  bywinrate = stats.sort_by {|hash| hash[:winrate]}.reverse
131
131
  puts " Stats Sorted by Winrate"
132
132
  puts "==================================================================================="
133
- puts "|| HERO || TYPE || WINRATE || POPULARITY || DAMAGE/MIN || K/D Ratio ||"
133
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
134
134
  bywinrate.each.with_index(1) do |herostats, index|
135
135
  show_heroname = check_width(herostats[:heroname], index)
136
136
  show_herotype = check_width(herostats[:herotype], 1 , 8)
137
137
  show_winrate = check_width(herostats[:winrate], 1 , 7)
138
138
  show_popularity = check_width(herostats[:popularity], 1 , 8)
139
- show_damagemin = check_width(herostats[:damagemin], 1 , 8)
139
+ show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
140
140
  show_herokd = check_width(herostats[:herokd], 1 , 8)
141
- puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_damagemin} || #{show_herokd} ||"
141
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_medalpergame} || #{show_herokd} ||"
142
142
  end
143
143
  puts "==================================================================================="
144
144
  end
@@ -148,58 +148,51 @@ class OverwatchStats::CLI
148
148
  bypopularity = stats.sort_by {|hash| hash[:popularity]}.reverse
149
149
  puts " Stats Sorted by Popularity"
150
150
  puts "==================================================================================="
151
- puts "|| HERO || TYPE || WINRATE || POPULARITY || DAMAGE/MIN || K/D Ratio ||"
151
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
152
152
  bypopularity.each.with_index(1) do |herostats, index|
153
153
  show_heroname = check_width(herostats[:heroname], index)
154
154
  show_herotype = check_width(herostats[:herotype], 1 , 8)
155
155
  show_winrate = check_width(herostats[:winrate], 1 , 7)
156
156
  show_popularity = check_width(herostats[:popularity], 1 , 8)
157
- show_damagemin = check_width(herostats[:damagemin], 1 , 8)
157
+ show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
158
158
  show_herokd = check_width(herostats[:herokd], 1 , 8)
159
- puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_damagemin} || #{show_herokd} ||"
159
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_medalpergame} || #{show_herokd} ||"
160
160
  end
161
161
  puts "==================================================================================="
162
162
  end
163
163
 
164
- def display_stats_damagemin
164
+ def display_stats_medalpergame
165
165
  stats = OverwatchStats::StatScraper.current
166
- new_array = []
167
- stats.collect do |x|
168
- if x[:damagemin].include?(",")
169
- x[:damagemin].gsub!(",","")
170
- end
171
- new_array << x
172
- end
173
- bydamagemin = new_array.sort_by {|hash| hash[:damagemin].to_i}.reverse
174
- puts " Stats Sorted by Damage/Minute"
166
+ bymedalpergame = stats.sort_by {|hash| hash[:medalpergame].to_f}.reverse
167
+ puts " Stats Sorted by Medal/Game"
175
168
  puts "==================================================================================="
176
- puts "|| HERO || TYPE || WINRATE || POPULARITY || DAMAGE/MIN || K/D Ratio ||"
177
- bydamagemin.each.with_index(1) do |herostats, index|
169
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
170
+ bymedalpergame.each.with_index(1) do |herostats, index|
178
171
  show_heroname = check_width(herostats[:heroname], index)
179
172
  show_herotype = check_width(herostats[:herotype], 1 , 8)
180
173
  show_winrate = check_width(herostats[:winrate], 1 , 7)
181
174
  show_popularity = check_width(herostats[:popularity], 1 , 8)
182
- show_damagemin = check_width(herostats[:damagemin], 1 , 8)
175
+ show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
183
176
  show_herokd = check_width(herostats[:herokd], 1 , 8)
184
- puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_damagemin} || #{show_herokd} ||"
177
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_medalpergame} || #{show_herokd} ||"
185
178
  end
186
179
  puts "==================================================================================="
187
180
  end
188
181
 
189
182
  def display_stats_herokd
190
183
  stats = OverwatchStats::StatScraper.current
191
- byherokd = stats.sort_by {|hash| hash[:herokd]}.reverse
184
+ byherokd = stats.sort_by {|hash| hash[:herokd].to_f}.reverse
192
185
  puts " Stats Sorted by Herokd"
193
186
  puts "==================================================================================="
194
- puts "|| HERO || TYPE || WINRATE || POPULARITY || DAMAGE/MIN || K/D Ratio ||"
187
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || MEDALS/GM || K/D Ratio ||"
195
188
  byherokd.each.with_index(1) do |herostats, index|
196
189
  show_heroname = check_width(herostats[:heroname], index)
197
190
  show_herotype = check_width(herostats[:herotype], 1 , 8)
198
191
  show_winrate = check_width(herostats[:winrate], 1 , 7)
199
192
  show_popularity = check_width(herostats[:popularity], 1 , 8)
200
- show_damagemin = check_width(herostats[:damagemin], 1 , 8)
193
+ show_medalpergame = check_width(herostats[:medalpergame], 1 , 8)
201
194
  show_herokd = check_width(herostats[:herokd], 1 , 8)
202
- puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_damagemin} || #{show_herokd} ||"
195
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_medalpergame} || #{show_herokd} ||"
203
196
  end
204
197
  puts "==================================================================================="
205
198
  end
data/lib/statscraper.rb CHANGED
@@ -6,21 +6,19 @@ class OverwatchStats::StatScraper
6
6
 
7
7
  def self.scrape_all_stats
8
8
  doc = Nokogiri::HTML(open("http://masteroverwatch.com/heroes"))
9
- container = doc.css("main.heroes-data div.table-list")
10
- counter = 0
9
+ container = doc.css("div.table-body")
11
10
  stats = []
12
- container.css("div.table-row-container").each do |x|
13
- counter += 1
14
- if counter > 1
15
- hero_name = x.css("div.row div.table-icon strong span").text
16
- hero_type = x.css("div.row div.table-icon strong small").text
17
- threenumbers = x.css("span.table-stats-winrate").text
18
- hero_winrate = threenumbers.split("%")[0] + "%"
19
- hero_popularity = threenumbers.split("%")[1] + "%"
20
- kdanddpm = threenumbers.split("%")[2].split(":")
21
- hero_kd = kdanddpm[0] + ":1"
22
- hero_damagemin = kdanddpm[1][1..-1]
23
- stats << {:heroname => hero_name, :herotype => hero_type, :winrate => hero_winrate, :popularity => hero_popularity, :damagemin => hero_damagemin, :herokd => hero_kd}
11
+ counter = 0
12
+ container.css("div.table-row-content").each do |x|
13
+ counter = counter + 1
14
+ if counter >= 1 && counter <= 21
15
+ hero_name = x.css("div.table-name span.table-name-block strong").text
16
+ hero_type = x.css("div.table-name span.table-name-block small").text
17
+ hero_winrate = x.css("div.table-winrate div.bar-outer").text
18
+ hero_popularity = x.css("div.table-popularity div.bar-outer").text
19
+ hero_kd = x.css("div.table-kd-ratio div.bar-outer").text
20
+ hero_medalpergame = x.css("div.table-medals-game div.bar-outer").text
21
+ stats << {:heroname => hero_name, :herotype => hero_type, :winrate => hero_winrate, :popularity => hero_popularity, :medalpergame => hero_medalpergame, :herokd => hero_kd}
24
22
  end
25
23
  end
26
24
  stats
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module OverwatchStats
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec", "~> 3.0"
24
24
  spec.add_runtime_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
25
+ spec.add_runtime_dependency "pry"
25
26
 
26
27
 
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overwatch_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - joelbitar1986
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-02 00:00:00.000000000 Z
11
+ date: 2016-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.6.8
75
+ - !ruby/object:Gem::Dependency
76
+ name: pry
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
75
89
  description: This app displays current stats of Overwatch(tm) heroes based on factors
76
90
  like winrate, popularity, K/D ratio and score/minute.
77
91
  email:
@@ -96,7 +110,6 @@ files:
96
110
  - lib/overwatch_stats.rb
97
111
  - lib/statscraper.rb
98
112
  - lib/version.rb
99
- - overwatch_stats-0.1.2.gem
100
113
  - overwatch_stats.gemspec
101
114
  homepage: https://github.com/joelbitar1986/OverwatchStats
102
115
  licenses:
Binary file