overwatch_stats 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d766891a4ae9ec10d757dbec81bc7d4caead4735
4
+ data.tar.gz: b6eeec774a3ca90b7d6a17ab6f76003201a73eef
5
+ SHA512:
6
+ metadata.gz: 0dcf913a29cfe36e35f8159d66f6e13418a9b1347019823750d44b2fcdb124aead6ab686a3bb93881e6ee59cd6b52ecb4cf6e416630a5cb5de7ff854429bad3f
7
+ data.tar.gz: 47704ea4cee30a7350e60d881fb4e07d3ec8680f0e5a08e9575bc37e7ace8333423474495381b4cda5125d5683919d3efdfa9ae2595d008145ccc54d64ff0c36
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at joelbitar1986@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in overwatchstats.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 joelbitart1986
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # overwatch_stats
2
+
3
+ This app displays current stats of Overwatch(tm) heroes based on factors like winrate, popularity, K/D ratio and score/minute.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'overwatch_stats'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install overwatch_stats
20
+
21
+ ## Usage
22
+
23
+ Option :1
24
+ gem install overwatch_stats
25
+ require 'overwatch_stats'
26
+
27
+ Option :2
28
+ Clone repository (https://github.com/joelbitar1986/OverwatchStats)
29
+ run bin/overwatch_stats
30
+
31
+
32
+ ## Development
33
+
34
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
35
+
36
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/joelbitar1986/OverwatchStats. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
41
+
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "environment"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require './lib/environment.rb'
3
+
4
+ OverwatchStats::CLI.new.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/cli.rb ADDED
@@ -0,0 +1,361 @@
1
+ class OverwatchStats::CLI
2
+
3
+ attr_accessor :stats
4
+
5
+ def start
6
+ greeting
7
+ display_stats_alphabetically
8
+ menu
9
+ end
10
+
11
+ def greeting
12
+ puts ""
13
+ puts " Cheers Love! Welcome to OverwatchStats!"
14
+ end
15
+
16
+ def menu
17
+ puts "Type the following to change sorting rules: '(win)rate' '(pop)ularity' '(score)min' '(kd)ratio' or '(alph)abetically'."
18
+ puts "Type the name of one of the above heroes to see more about that hero."
19
+ puts "Type 'exit' to exit."
20
+
21
+ input = gets.strip.downcase
22
+ if input == "winrate" || input == "win"
23
+ display_stats_winrate
24
+ menu
25
+ elsif input == "popularity" || input == "pop"
26
+ display_stats_popularity
27
+ menu
28
+ elsif input == "scoremin" || input == "score"
29
+ display_stats_scoremin
30
+ menu
31
+ elsif input == "kdratio" || input == "kd"
32
+ display_stats_herokd
33
+ menu
34
+ elsif input == "alphabetically" || input == "alph"
35
+ display_stats_alphabetically
36
+ menu
37
+ elsif input == "bastion"
38
+ display_bastion
39
+ menu
40
+ elsif input == "d.va"
41
+ display_dva
42
+ menu
43
+ elsif input == "genji"
44
+ display_genji
45
+ menu
46
+ elsif input == "hanzo"
47
+ display_hanzo
48
+ menu
49
+ elsif input == "junkrat"
50
+ display_junkrat
51
+ menu
52
+ elsif input == "lucio"
53
+ display_lucio
54
+ menu
55
+ elsif input == "mccree"
56
+ display_mccree
57
+ menu
58
+ elsif input == "mei"
59
+ display_mei
60
+ menu
61
+ elsif input == "mercy"
62
+ display_mercy
63
+ menu
64
+ elsif input == "pharah"
65
+ display_pharah
66
+ menu
67
+ elsif input == "reaper"
68
+ display_reaper
69
+ menu
70
+ elsif input == "reinhardt"
71
+ display_reinhardt
72
+ menu
73
+ elsif input == "roadhog"
74
+ display_roadhog
75
+ menu
76
+ elsif input == "soldier76" || input == "soldier:76" || input == "soldier: 76"
77
+ display_soldier76
78
+ menu
79
+ elsif input == "symmetra"
80
+ display_symmetra
81
+ menu
82
+ elsif input == "torbjorn"
83
+ display_torbjorn
84
+ menu
85
+ elsif input == "tracer"
86
+ display_tracer
87
+ menu
88
+ elsif input == "widowmaker"
89
+ display_widowmaker
90
+ menu
91
+ elsif input == "winston"
92
+ display_winston
93
+ menu
94
+ elsif input == "zarya"
95
+ display_zarya
96
+ menu
97
+ elsif input == "zenyatta"
98
+ display_zenyatta
99
+ menu
100
+ elsif input == "exit"
101
+ exit
102
+ else
103
+ puts "Please make a valid selection..."
104
+ menu
105
+ end
106
+
107
+ end
108
+
109
+ def display_stats_alphabetically
110
+ stats = OverwatchStats::StatScraper.current
111
+ puts ""
112
+ puts " Stats Sorted Alphabetically"
113
+ puts "==================================================================================="
114
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || SCORE/MIN || K/D Ratio ||"
115
+ stats.each.with_index(1) do |herostats, index|
116
+ show_heroname = check_width(herostats[:heroname], index)
117
+ show_herotype = check_width(herostats[:herotype], 1 , 8)
118
+ show_winrate = check_width(herostats[:winrate], 1 , 7)
119
+ show_popularity = check_width(herostats[:popularity], 1 , 8)
120
+ show_scoremin = check_width(herostats[:scoremin], 1 , 8)
121
+ show_herokd = check_width(herostats[:herokd], 1 , 8)
122
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_scoremin} || #{show_herokd} ||"
123
+ end
124
+ puts "==================================================================================="
125
+ end
126
+
127
+ def display_stats_winrate
128
+ stats = OverwatchStats::StatScraper.current
129
+ bywinrate = stats.sort_by {|hash| hash[:winrate]}.reverse
130
+ puts " Stats Sorted by Winrate"
131
+ puts "==================================================================================="
132
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || SCORE/MIN || K/D Ratio ||"
133
+ bywinrate.each.with_index(1) do |herostats, index|
134
+ show_heroname = check_width(herostats[:heroname], index)
135
+ show_herotype = check_width(herostats[:herotype], 1 , 8)
136
+ show_winrate = check_width(herostats[:winrate], 1 , 7)
137
+ show_popularity = check_width(herostats[:popularity], 1 , 8)
138
+ show_scoremin = check_width(herostats[:scoremin], 1 , 8)
139
+ show_herokd = check_width(herostats[:herokd], 1 , 8)
140
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_scoremin} || #{show_herokd} ||"
141
+ end
142
+ puts "==================================================================================="
143
+ end
144
+
145
+ def display_stats_popularity
146
+ stats = OverwatchStats::StatScraper.current
147
+ bypopularity = stats.sort_by {|hash| hash[:popularity]}.reverse
148
+ puts " Stats Sorted by Popularity"
149
+ puts "==================================================================================="
150
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || SCORE/MIN || K/D Ratio ||"
151
+ bypopularity.each.with_index(1) do |herostats, index|
152
+ show_heroname = check_width(herostats[:heroname], index)
153
+ show_herotype = check_width(herostats[:herotype], 1 , 8)
154
+ show_winrate = check_width(herostats[:winrate], 1 , 7)
155
+ show_popularity = check_width(herostats[:popularity], 1 , 8)
156
+ show_scoremin = check_width(herostats[:scoremin], 1 , 8)
157
+ show_herokd = check_width(herostats[:herokd], 1 , 8)
158
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_scoremin} || #{show_herokd} ||"
159
+ end
160
+ puts "==================================================================================="
161
+ end
162
+
163
+ def display_stats_scoremin
164
+ stats = OverwatchStats::StatScraper.current
165
+ byscoremin = stats.sort_by {|hash| hash[:scoremin]}.reverse
166
+ puts " Stats Sorted by Score/Minute"
167
+ puts "==================================================================================="
168
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || SCORE/MIN || K/D Ratio ||"
169
+ byscoremin.each.with_index(1) do |herostats, index|
170
+ show_heroname = check_width(herostats[:heroname], index)
171
+ show_herotype = check_width(herostats[:herotype], 1 , 8)
172
+ show_winrate = check_width(herostats[:winrate], 1 , 7)
173
+ show_popularity = check_width(herostats[:popularity], 1 , 8)
174
+ show_scoremin = check_width(herostats[:scoremin], 1 , 8)
175
+ show_herokd = check_width(herostats[:herokd], 1 , 8)
176
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_scoremin} || #{show_herokd} ||"
177
+ end
178
+ puts "==================================================================================="
179
+ end
180
+
181
+ def display_stats_herokd
182
+ stats = OverwatchStats::StatScraper.current
183
+ byherokd = stats.sort_by {|hash| hash[:herokd]}.reverse
184
+ puts " Stats Sorted by Herokd"
185
+ puts "==================================================================================="
186
+ puts "|| HERO || TYPE || WINRATE || POPULARITY || SCORE/MIN || K/D Ratio ||"
187
+ byherokd.each.with_index(1) do |herostats, index|
188
+ show_heroname = check_width(herostats[:heroname], index)
189
+ show_herotype = check_width(herostats[:herotype], 1 , 8)
190
+ show_winrate = check_width(herostats[:winrate], 1 , 7)
191
+ show_popularity = check_width(herostats[:popularity], 1 , 8)
192
+ show_scoremin = check_width(herostats[:scoremin], 1 , 8)
193
+ show_herokd = check_width(herostats[:herokd], 1 , 8)
194
+ puts "|| #{index}. #{show_heroname} || #{show_herotype} || #{show_winrate} || #{show_popularity} || #{show_scoremin} || #{show_herokd} ||"
195
+ end
196
+ puts "==================================================================================="
197
+ end
198
+
199
+ def check_width(string, index = 1, column_width = 13)
200
+ if index < 10 && string.size <= column_width
201
+ add_space = column_width - string.size - 1
202
+ add_space.times do
203
+ string = string + " "
204
+ end
205
+ string
206
+ elsif index > 9 && string.size <= column_width
207
+ add_space = column_width - string.size - 2
208
+ add_space.times do
209
+ string = string + " "
210
+ end
211
+ end
212
+ string
213
+ end
214
+
215
+ # def display_bastion
216
+ # array = OverwatchStats::Hero.hero_collect
217
+ # array.each do |x|
218
+ # if x.name.downcase == "bastion"
219
+ # puts "Name: #{x.name}"
220
+ # puts "Role: #{x.role}"
221
+ # puts ""
222
+ # puts "Lore: #{x.lore}"
223
+ # puts ""
224
+ # puts "Max HP: #{x.hp}" unless x.hp == nil
225
+ # puts "Ammo: #{x.ammo}" unless x.ammo == nil
226
+ # puts ""
227
+ # puts "**Abilities**"
228
+ # puts "------------------------"
229
+ # x.abilities.each do |ability|
230
+ # puts "Ability: #{ability[:ability_name]}"
231
+ # puts "Description: " + "#{ability[:ability_description]}"
232
+ # puts ""
233
+ # end
234
+ # else
235
+ # menu
236
+ # end
237
+ # end
238
+ # end
239
+
240
+
241
+
242
+ def display_bastion
243
+ x = OverwatchStats::Hero.bastion
244
+ show_stats(x)
245
+ end
246
+
247
+ def display_dva
248
+ x = OverwatchStats::Hero.dva
249
+ show_stats(x)
250
+ end
251
+
252
+ def display_genji
253
+ x = OverwatchStats::Hero.genji
254
+ show_stats(x)
255
+ end
256
+
257
+ def display_hanzo
258
+ x = OverwatchStats::Hero.hanzo
259
+ show_stats(x)
260
+ end
261
+
262
+ def display_junkrat
263
+ x = OverwatchStats::Hero.junkrat
264
+ show_stats(x)
265
+ end
266
+
267
+ def display_lucio
268
+ x = OverwatchStats::Hero.lucio
269
+ show_stats(x)
270
+ end
271
+
272
+ def display_mccree
273
+ x = OverwatchStats::Hero.mccree
274
+ show_stats(x)
275
+ end
276
+
277
+ def display_mei
278
+ x = OverwatchStats::Hero.mei
279
+ show_stats(x)
280
+ end
281
+
282
+ def display_pharah
283
+ x = OverwatchStats::Hero.pharah
284
+ show_stats(x)
285
+ end
286
+
287
+ def display_reaper
288
+ x = OverwatchStats::Hero.reaper
289
+ show_stats(x)
290
+ end
291
+
292
+ def display_reinhardt
293
+ x = OverwatchStats::Hero.reinhardt
294
+ show_stats(x)
295
+ end
296
+
297
+ def display_roadhog
298
+ x = OverwatchStats::Hero.roadhog
299
+ show_stats(x)
300
+ end
301
+
302
+ def display_soldier76
303
+ x = OverwatchStats::Hero.soldier76
304
+ show_stats(x)
305
+ end
306
+
307
+ def display_symmetra
308
+ x = OverwatchStats::Hero.symmetra
309
+ show_stats(x)
310
+ end
311
+
312
+ def display_torbjorn
313
+ x = OverwatchStats::Hero.torbjorn
314
+ show_stats(x)
315
+ end
316
+
317
+ def display_tracer
318
+ x = OverwatchStats::Hero.tracer
319
+ show_stats(x)
320
+ end
321
+
322
+ def display_widowmaker
323
+ x = OverwatchStats::Hero.widowmaker
324
+ show_stats(x)
325
+ end
326
+
327
+ def display_winston
328
+ x = OverwatchStats::Hero.winston
329
+ show_stats(x)
330
+ end
331
+
332
+ def display_zarya
333
+ x = OverwatchStats::Hero.zarya
334
+ show_stats(x)
335
+ end
336
+
337
+ def display_zenyatta
338
+ x = OverwatchStats::Hero.zenyatta
339
+ show_stats(x)
340
+ end
341
+
342
+ def show_stats(x)
343
+ puts "Name: #{x.name}"
344
+ puts ""
345
+ puts "Role: #{x.role}"
346
+ puts "Max HP: #{x.hp}" unless x.hp == nil
347
+ puts "Ammo: #{x.ammo}" unless x.ammo == nil
348
+ puts ""
349
+ puts "Lore: #{x.lore}"
350
+ puts ""
351
+ puts ""
352
+ puts "**Abilities**"
353
+ puts "------------------------"
354
+ x.abilities.each do |ability|
355
+ puts "Ability: #{ability[:ability_name]}"
356
+ puts "Description: " + "#{ability[:ability_description]}"
357
+ puts ""
358
+ end
359
+ end
360
+
361
+ end
data/lib/hero.rb ADDED
@@ -0,0 +1,160 @@
1
+ #OverwatchStats::Hero.scrapehero
2
+ class OverwatchStats::Hero
3
+
4
+ attr_accessor :name, :lore, :hp, :ammo, :abilities, :role
5
+
6
+ @@all = []
7
+
8
+ # @@urls = ["http://masteroverwatch.com/heroes/15-bastion",
9
+ # "http://masteroverwatch.com/heroes/22-d-va",
10
+ # "http://masteroverwatch.com/heroes/21-genji",
11
+ # "http://masteroverwatch.com/heroes/16-hanzo",
12
+ # "http://masteroverwatch.com/heroes/2-junkrat",
13
+ # "http://masteroverwatch.com/heroes/3-lucio",
14
+ # "http://masteroverwatch.com/heroes/6-mccree",
15
+ # "http://masteroverwatch.com/heroes/20-mei",
16
+ # "http://masteroverwatch.com/heroes/17-mercy",
17
+ # "http://masteroverwatch.com/heroes/11-pharah",
18
+ # "http://masteroverwatch.com/heroes/8-reaper",
19
+ # "http://masteroverwatch.com/heroes/12-reinhardt",
20
+ # "http://masteroverwatch.com/heroes/1-roadhog",
21
+ # "http://masteroverwatch.com/heroes/4-soldier-76",
22
+ # "http://masteroverwatch.com/heroes/13-symmetra",
23
+ # "http://masteroverwatch.com/heroes/14-torbjorn",
24
+ # "http://masteroverwatch.com/heroes/7-tracer",
25
+ # "http://masteroverwatch.com/heroes/9-widowmaker",
26
+ # "http://masteroverwatch.com/heroes/10-winston",
27
+ # "http://masteroverwatch.com/heroes/5-zarya",
28
+ # "http://masteroverwatch.com/heroes/18-zenyatta"]
29
+
30
+ def self.scrapehero(page_url)
31
+ doc = Nokogiri::HTML(open(page_url))
32
+ x = OverwatchStats::Hero.new
33
+ x.name = doc.css("div.heroes-header-title h1").text
34
+ x.lore = doc.css("div.heroes-lore p").text.gsub(".",". ")
35
+ x.hp = doc.css("div.heroes-header-title span.stat-hp").text.strip + " HP" unless doc.css("div.heroes-header-title span.stat-hp").text.strip == ""
36
+ x.ammo = doc.css("div.heroes-header-title span.stat-ammo").text.strip + " Ammo" unless doc.css("div.heroes-header-title span.stat-ammo").text.strip == ""
37
+ x.abilities = []
38
+ doc.css("div.heroes-abilities-ability").each do |ability|
39
+ ability_name = ability.css("div.ability-name").text
40
+ ability_description = ability.css("div.ability-description").text
41
+ x.abilities << {:ability_name => ability_name, :ability_description => ability_description}
42
+ end
43
+ x.role = doc.css("div.heroes-header-title span.stat-role").text
44
+ x
45
+ end
46
+
47
+ def self.bastion
48
+ bastion = self.scrapehero("http://masteroverwatch.com/heroes/15-bastion")
49
+ bastion
50
+ end
51
+
52
+ def self.dva
53
+ dva = self.scrapehero("http://masteroverwatch.com/heroes/22-d-va")
54
+ dva
55
+ end
56
+
57
+ def self.genji
58
+ genji = self.scrapehero("http://masteroverwatch.com/heroes/21-genji")
59
+ genji
60
+ end
61
+
62
+ def self.hanzo
63
+ hanzo = self.scrapehero("http://masteroverwatch.com/heroes/16-hanzo")
64
+ hanzo
65
+ end
66
+
67
+ def self.junkrat
68
+ junkray = self.scrapehero("http://masteroverwatch.com/heroes/2-junkrat")
69
+ junkray
70
+ end
71
+
72
+ def self.lucio
73
+ lucio = self.scrapehero("http://masteroverwatch.com/heroes/3-lucio")
74
+ lucio
75
+ end
76
+
77
+ def self.mccree
78
+ mccree = self.scrapehero("http://masteroverwatch.com/heroes/6-mccree")
79
+ mccree
80
+ end
81
+
82
+ def self.mei
83
+ mei = self.scrapehero("http://masteroverwatch.com/heroes/20-mei")
84
+ mei
85
+ end
86
+
87
+ def self.mercy
88
+ mercy = self.scrapehero("http://masteroverwatch.com/heroes/17-mercy")
89
+ mercy
90
+ end
91
+
92
+ def self.pharah
93
+ pharah = self.scrapehero("http://masteroverwatch.com/heroes/11-pharah")
94
+ pharah
95
+ end
96
+
97
+ def self.reaper
98
+ reaper = self.scrapehero("http://masteroverwatch.com/heroes/8-reaper")
99
+ reaper
100
+ end
101
+
102
+ def self.reinhardt
103
+ reinhardt = self.scrapehero("http://masteroverwatch.com/heroes/12-reinhardt")
104
+ reinhardt
105
+ end
106
+
107
+ def self.roadhog
108
+ roadhog = self.scrapehero("http://masteroverwatch.com/heroes/1-roadhog")
109
+ roadhog
110
+ end
111
+
112
+ def self.soldier76
113
+ soldier76 = self.scrapehero("http://masteroverwatch.com/heroes/4-soldier-76")
114
+ soldier76
115
+ end
116
+
117
+ def self.symmetra
118
+ symmetra = self.scrapehero("http://masteroverwatch.com/heroes/13-symmetra")
119
+ symmetra
120
+ end
121
+
122
+ def self.torbjorn
123
+ torbjorn = self.scrapehero("http://masteroverwatch.com/heroes/14-torbjorn")
124
+ torbjorn
125
+ end
126
+
127
+ def self.tracer
128
+ tracer = self.scrapehero("http://masteroverwatch.com/heroes/7-tracer")
129
+ tracer
130
+ end
131
+
132
+ def self.widowmaker
133
+ widowmaker = self.scrapehero("http://masteroverwatch.com/heroes/9-widowmaker")
134
+ widowmaker
135
+ end
136
+
137
+ def self.winston
138
+ winston = self.scrapehero("http://masteroverwatch.com/heroes/10-winston")
139
+ winston
140
+ end
141
+
142
+ def self.zarya
143
+ zarya = self.scrapehero("http://masteroverwatch.com/heroes/5-zarya")
144
+ zarya
145
+ end
146
+
147
+ def self.zenyatta
148
+ zenyatta = self.scrapehero("http://masteroverwatch.com/heroes/18-zenyatta")
149
+ zenyatta
150
+ end
151
+
152
+ # def self.hero_collect
153
+ # @@urls.each do |url|
154
+ # x = self.scrapehero(url)
155
+ # @@all << x
156
+ # end
157
+ # @@all
158
+ # end
159
+
160
+ end
@@ -0,0 +1,7 @@
1
+ require './lib/version'
2
+ require './lib/cli'
3
+ require './lib/statscraper'
4
+ require './lib/hero'
5
+
6
+ require 'nokogiri'
7
+ require 'open-uri'
@@ -0,0 +1,28 @@
1
+ class OverwatchStats::StatScraper
2
+
3
+ def self.current
4
+ self.scrape_all_stats
5
+ end
6
+
7
+ def self.scrape_all_stats
8
+ doc = Nokogiri::HTML(open("http://masteroverwatch.com/heroes"))
9
+ container = doc.css("main.heroes-data div.table-list")
10
+ counter = 0
11
+ 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
+ hero_scoremin = threenumbers.split("%")[2]
21
+ hero_kd = x.css("div.table-stats-kd span").text + ":1"
22
+ stats << {:heroname => hero_name, :herotype => hero_type, :winrate => hero_winrate, :popularity => hero_popularity, :scoremin => hero_scoremin, :herokd => hero_kd}
23
+ end
24
+ end
25
+ stats
26
+ end
27
+
28
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module OverwatchStats
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "overwatch_stats"
8
+ spec.version = OverwatchStats::VERSION
9
+ spec.authors = ["joelbitar1986"]
10
+ spec.email = ["joelbitar1986@gmail.com"]
11
+
12
+ spec.summary = "This app displays current stats of Overwatch(tm) heroes based on factors like winrate, popularity, K/D ratio and score/minute."
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/joelbitar1986/OverwatchStats"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ spec.add_runtime_dependency "nokogiri", "~> 1.6", ">= 1.6.8"
25
+
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: overwatch_stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - joelbitar1986
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-01 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.6.8
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.6'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.6.8
75
+ description: This app displays current stats of Overwatch(tm) heroes based on factors
76
+ like winrate, popularity, K/D ratio and score/minute.
77
+ email:
78
+ - joelbitar1986@gmail.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - ".gitignore"
84
+ - ".rspec"
85
+ - ".travis.yml"
86
+ - CODE_OF_CONDUCT.md
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/console
92
+ - bin/overwatch_stats
93
+ - bin/setup
94
+ - lib/cli.rb
95
+ - lib/hero.rb
96
+ - lib/overwatch_stats.rb
97
+ - lib/statscraper.rb
98
+ - lib/version.rb
99
+ - overwatch_stats.gemspec
100
+ homepage: https://github.com/joelbitar1986/OverwatchStats
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.4.8
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: This app displays current stats of Overwatch(tm) heroes based on factors
124
+ like winrate, popularity, K/D ratio and score/minute.
125
+ test_files: []