LeagueHelper 0.1.0

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: 789e9dff01e006bd1ae26ea6e84358c64b47418f
4
+ data.tar.gz: 9d2f7b215ae1b45c581b6ef84fcfb45d2e05a547
5
+ SHA512:
6
+ metadata.gz: 26a9cbb18d58b7c85fbd802d339c19f772a3dc4e2379b187f90492f153e7441a61ca2575577ee1a858190165a93481d59c3fdcc442cdf5b7bf4ed465543f4702
7
+ data.tar.gz: 8a6a3d9b0f66fc1bfae507ae21a66836efbe4631691427ccde2d1a6d4f575c4fb5c901d407fe259685a2760d3593f49ad98e4dee2bf8a44f315d760cbca25b4c
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/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at 'mr.omarmason@gmail.com'. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in LeagueHelper.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
7
+ gem 'nokogiri', '1.6.6.2'
8
+ gem 'rspec'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'LeagueHelper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "LeagueHelper"
8
+ spec.version = LeagueHelper::VERSION
9
+ spec.authors = ["'Omar Mason'"]
10
+ spec.email = ["'mr.omarmason@gmail.com'"]
11
+
12
+ spec.summary = "A helper tool for League rank players"
13
+ spec.homepage = 'https://github.com/PhreeMason/LeagueHelper-cli-app'
14
+ spec.license = "MIT"
15
+
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # LeagueHelper
2
+
3
+ This gem is meant to provide League of Legends players with information on climbing the ranking ladder. The gem provides information on your most popular rank champions and rank stats for each in addion to popular item builds for each champ.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'LeagueHelper'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install LeagueHelper
20
+
21
+ ## Usage
22
+ First run the league_helper in the bin directory. At this time you will be prompted to enter your summoner name. After doing so, if you are ranked you will be provided with the following list of options.
23
+ "1.Rank Solo Q 3.Most played Champs"
24
+ "2.Champion Build 4.New summoner lookup"
25
+ If you are unranked the program will close as it is intended to help rank players improve their game.
26
+ To make an option choice simply enter the number of your choice.
27
+ The first option will provide you information on your top two most sucessful champions with tips.
28
+ The second option will provide you with popular item builds on a champion of your choice from your top seven most used champions in rank.
29
+ The third options displays your seven most used champions.
30
+ The fourth and last option allows a user to look up a new summoner.
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/'mromarmason-38224'/LeagueHelper. 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.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "LeagueHelper"
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(__FILE__)
data/bin/league_helper ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require_relative '../lib/LeagueHelper'
5
+ LeagueHelper::CLI.new.call
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
@@ -0,0 +1,5 @@
1
+ require_relative "./LeagueHelper/version"
2
+ require_relative './LeagueHelper/cli'
3
+ require_relative './LeagueHelper/scraper'
4
+ require_relative './LeagueHelper/summoner'
5
+ require_relative './LeagueHelper/champions'
@@ -0,0 +1,19 @@
1
+
2
+ class Champion
3
+ attr_accessor :name, :my_winpercent, :cs, :build
4
+
5
+ def initialize(attributes_hash)
6
+ attributes_hash.each { |k, v| self.send(("#{k}="), v) }
7
+ @build = []
8
+ end
9
+
10
+ def self.create_from_collection(champions_array)
11
+ champions_array.each { |character| champion = champion.new(character) }
12
+ end
13
+
14
+ def player=(summoner)
15
+ summoner.champions << self
16
+ end
17
+
18
+
19
+ end
@@ -0,0 +1,93 @@
1
+
2
+
3
+ class LeagueHelper::CLI
4
+ attr_accessor :summoner, :input
5
+
6
+ def call
7
+ puts "Welcome to League Helper"
8
+ new_summoner
9
+ end
10
+
11
+ def options
12
+ while @input != 'exit'
13
+ puts ""
14
+ puts "Please enter the number for the area of game play you would like to improve"
15
+ puts "Or enter 'exit' to quit"
16
+ puts "1.Rank Solo Q 3.Most played Champs"
17
+ puts "2.Champion Build 4.New summoner lookup"
18
+ puts ""
19
+ @input = gets.chomp.downcase
20
+ action
21
+ end
22
+ end
23
+
24
+ def action
25
+ case @input
26
+ when '1'
27
+ soloQ
28
+ puts ""
29
+ when '2'
30
+ champ_mastery
31
+ puts ""
32
+ when '3'
33
+ puts "Here are your most played champs"
34
+ puts ""
35
+ @summoner.my_champs
36
+ when '4'
37
+ new_summoner
38
+ when 'exit'
39
+ puts "Thank You"
40
+ puts "Goodbye"
41
+ else
42
+ puts "I dont understand that choice"
43
+ end
44
+ end
45
+
46
+ def soloQ
47
+ puts "Here is a list of your best champions"
48
+ puts "with win percent and avareage cs for each"
49
+ c=@summoner.best_champs
50
+ puts "#{c[0].name} CS:#{c[0].cs} #{c[0].my_winpercent}"
51
+ puts "#{c[1].name} CS:#{c[1].cs} #{c[1].my_winpercent}"
52
+ puts "I suggest focusing on these two to climb in Rank"
53
+ puts "The easist way to improve win percent is to improve cs"
54
+ puts "Aim for about 90 cs for every 10 minutes of in game time."
55
+ end
56
+
57
+ def champ_mastery
58
+ puts "Which champions would you like a build for?"
59
+ summoner.champ_builds
60
+ summoner.champions.each {|champ| puts champ.name}
61
+ puts ""
62
+ @input= gets.chomp
63
+ champ = summoner.champ_find(@input)
64
+ if champ
65
+ puts "Here are the most popular items"
66
+ puts ""
67
+ champ.build.each_with_index {|item, idx| puts "#{idx+1}. #{item}"}
68
+ else
69
+ puts "That champion is not in your champ pool"
70
+ end
71
+ end
72
+
73
+ def new_summoner
74
+ puts "Please enter your summoner name"
75
+ @input = gets.chomp
76
+ get_summoner
77
+ puts ""
78
+ if @summoner.champions.count != 0
79
+ @summoner.stats
80
+ options
81
+ else
82
+ puts "Please try again when you are ranked"
83
+ puts "Goodbye"
84
+ end
85
+ end
86
+
87
+ def get_summoner
88
+ @summoner = Summoner.find_create_by_name(@input)
89
+ LolScraper.scrape_summoner_page(@summoner)
90
+ LolScraper.summ_champ_stats(@summoner)
91
+ end
92
+
93
+ end
@@ -0,0 +1,60 @@
1
+ require 'open-uri'
2
+ require 'pry'
3
+ require 'nokogiri'
4
+
5
+ class LolScraper
6
+ SUMMONER_LOOKUP = "https://na.op.gg/summoner/userName="
7
+ CHAMP_LOOKUP = "http://www.probuilds.net/champions/details/"
8
+ def self.scrape_champion_page(index_url)
9
+
10
+ end
11
+ def self.scrape_summoner_page(summoner)
12
+ url = SUMMONER_LOOKUP+summoner.url_name
13
+ doc = Nokogiri::HTML(open(url))
14
+ summoner.rank = doc.css('.tierRank').text
15
+ summoner.lp = doc.css('.LeaguePoints').text.strip
16
+ summoner.win_ratio = doc.css('.winratio').text
17
+ end
18
+
19
+ def self.champion_build(champions)
20
+ champions.each do |champ|
21
+ name = champ.name.split(' ').join('')
22
+ url = CHAMP_LOOKUP+name
23
+ doc = Nokogiri::HTML(open(url))
24
+ doc.css(".left.clear").css('.item-name.gold').each {|name| champ.build << name.text}
25
+ end
26
+ end
27
+
28
+ def self.summ_champ_stats(summoner)
29
+ url = SUMMONER_LOOKUP+summoner.url_name
30
+ doc = Nokogiri::HTML(open(url))
31
+ doc.css(".ChampionBox.Ranked").each do |champ|
32
+ attrs = {}
33
+ attrs[:name] = champ.css(".ChampionName").text.strip
34
+ attrs[:my_winpercent] = champ.css(".Played").text.strip[0..3]
35
+ attrs[:cs] = champ.css(".cs.average").text
36
+ attrs[:player] = summoner
37
+ Champion.new(attrs)
38
+ end
39
+
40
+ end
41
+
42
+
43
+
44
+
45
+
46
+ end
47
+ # lookup = "http://www.probuilds.net/champions/details/"
48
+ # name = 'Annie'
49
+ # url = lookup+name
50
+ # doc = Nokogiri::HTML(open(url))
51
+ # me = doc.css(".left.clear")
52
+ # me.css('.item-name.gold').each {|name| puts name.text}
53
+ # binding.pry
54
+
55
+ # def slow_print(word)
56
+ # word.each_char do |chr|
57
+ # sleep(0.1)
58
+ # print chr
59
+ # end
60
+ # end
@@ -0,0 +1,46 @@
1
+ class Summoner
2
+ attr_accessor :name, :url_name, :champions, :rank, :lp, :win_ratio
3
+ @@all = []
4
+ def initialize(summoner_name)
5
+ @name = summoner_name
6
+ @url_name = @name.split(" ").join("+")
7
+ @champions = []
8
+ @@all << self
9
+ end
10
+
11
+ def self.all
12
+ @@all
13
+ end
14
+
15
+ def my_winpercent
16
+ Scraper.new.champion_win(@champions)
17
+ end
18
+
19
+ def stats
20
+ puts "Summoner: #{@name}"
21
+ puts "Rank: #{@rank} with #{@lp}"
22
+ end
23
+
24
+ def my_champs
25
+ @champions.each {|champ| puts "#{champ.name}"}
26
+ end
27
+
28
+ def best_champs
29
+ @champions.sort {|a, b| b.my_winpercent <=> a.my_winpercent}
30
+ end
31
+
32
+ def champ_builds
33
+ LolScraper.champion_build(@champions)
34
+ @champions.each {|champ| champ.build.delete_at(6) }
35
+ @champions
36
+ end
37
+
38
+ def champ_find(name)
39
+ @champions.detect{|champ| champ.name.downcase == "#{name.downcase}"}
40
+ end
41
+
42
+ def self.find_create_by_name(name)
43
+ self.all.detect{|summoner| summoner.name == name} || self.new(name)
44
+ end
45
+
46
+ end
@@ -0,0 +1,3 @@
1
+ module LeagueHelper
2
+ VERSION = "0.1.0"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,10 @@
1
+ Specs:
2
+
3
+ [x] Have a CLI for interfacing with the application
4
+ I made a file called league_helper in bin with a call function that starts a cli loop.
5
+
6
+ [x] Pull data from an external source
7
+ I made a scraper class to scrape na.op.gg and probuilds.net
8
+
9
+ [] Implement both list and detail views
10
+ I am not sure what exactly this means.
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: LeagueHelper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "'Omar Mason'"
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-19 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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
+ description:
42
+ email:
43
+ - "'mr.omarmason@gmail.com'"
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - CODE_OF_CONDUCT.md
50
+ - Gemfile
51
+ - LICENSE
52
+ - LeagueHelper.gemspec
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/league_helper
57
+ - bin/setup
58
+ - lib/LeagueHelper.rb
59
+ - lib/LeagueHelper/champions.rb
60
+ - lib/LeagueHelper/cli.rb
61
+ - lib/LeagueHelper/scraper.rb
62
+ - lib/LeagueHelper/summoner.rb
63
+ - lib/LeagueHelper/version.rb
64
+ - spec.md
65
+ homepage: https://github.com/PhreeMason/LeagueHelper-cli-app
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.6.11
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: A helper tool for League rank players
89
+ test_files: []