ufc_rankings 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 22b11af10a64260380f8dcd10b50e52ea9127052
4
+ data.tar.gz: 505df7a29e55218e05de149deae66a68edb2c280
5
+ SHA512:
6
+ metadata.gz: 9a174870116ddfa7751a0df0365db6a8d9a7828cfa2dc02866cb31711383b7d114e9622d663ac7881b1d5733671beb16422f67d9bf95b14edf51741b002a8d72
7
+ data.tar.gz: ee7956b4cc35eb492e2b2742f4fbab1d8bf7ca40a159f64372c0f6def8efe58e76b2cc099de4a36eb07a99d06ff27798b600a96ee261f133797bd721f80d0ca1
@@ -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
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ufc_rankings.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 johnram528
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.
@@ -0,0 +1,41 @@
1
+ # UfcRankings
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ufc_rankings`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ufc_rankings'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ufc_rankings
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ufc_rankings. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ufc_rankings"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "ufc_rankings"
4
+
5
+ UfcRankings::CLI.new.call
@@ -0,0 +1,8 @@
1
+ require "ufc_rankings/version"
2
+ require "open-uri"
3
+ require "nokogiri"
4
+ require "pry"
5
+
6
+ require_relative "ufc_rankings/cli.rb"
7
+ require_relative "ufc_rankings/rankings.rb"
8
+
@@ -0,0 +1,87 @@
1
+ class UfcRankings::CLI
2
+ def call
3
+ UfcRankings::Rankings.scrape_rankings
4
+ welcome
5
+ menu
6
+ end
7
+
8
+ def welcome
9
+ puts "Welcome to the UFC Rankings CLI!"
10
+ puts ""
11
+ end
12
+
13
+ def menu
14
+ puts "Please select the weight class rankings you'd like to see from the list below by entering the number assigned to each class. ."
15
+ puts ""
16
+ list_classes
17
+ input = gets.strip
18
+ show_rankings(input.to_i)
19
+ puts ""
20
+ puts ""
21
+ puts "press 1 to see more rankings, 2 to exit."
22
+ input = gets.strip.to_i
23
+ if input == 1
24
+ menu
25
+ else
26
+ exit
27
+ end
28
+ end
29
+
30
+ def list_classes
31
+ puts "1.Pound for Pound "
32
+ puts "2.Flyweight "
33
+ puts "3.Bantamweight"
34
+ puts "4.Featherweight "
35
+ puts "5.Lightweight "
36
+ puts "6.Welterweight "
37
+ puts "7.Middleweight "
38
+ puts "8.Light Heavyweight "
39
+ puts "9.Heavyweight "
40
+ puts "10.Women's Strawweight "
41
+ puts "11.Women's Bantamweight"
42
+ puts ""
43
+ end
44
+
45
+ def show_rankings(num)
46
+ case num
47
+ when 1
48
+ puts "Pound for Pound Rankings"
49
+ UfcRankings::Rankings.p4p
50
+ when 2
51
+ puts "Flyweight Rankings"
52
+ UfcRankings::Rankings.fly
53
+ when 3
54
+ puts "Bantameweight Rankings"
55
+ UfcRankings::Rankings.bantam
56
+ when 4
57
+ puts "Featherweight Rankings"
58
+ UfcRankings::Rankings.feather
59
+ when 5
60
+ puts "Lightweight Rankings"
61
+ UfcRankings::Rankings.light
62
+ when 6
63
+ puts "Welterweight Rankings"
64
+ UfcRankings::Rankings.welter
65
+ when 7
66
+ puts "Middleweight Rankings"
67
+ UfcRankings::Rankings.middle
68
+ when 8
69
+ puts "Light Heavyweight Rankings"
70
+ UfcRankings::Rankings.light_heavy
71
+ when 9
72
+ puts "Heavyweight Rankings"
73
+ UfcRankings::Rankings.heavy
74
+ when 10
75
+ puts "Women's Strawweight"
76
+ UfcRankings::Rankings.womens_straw
77
+ when 11
78
+ puts "Women's Bantamweight"
79
+ UfcRankings::Rankings.womens_bantam
80
+ end
81
+ end
82
+
83
+ def exit
84
+ puts "Come back soon to see who's climbing the ladder of Ultimate Fighters!"
85
+ end
86
+
87
+ end
@@ -0,0 +1,99 @@
1
+ class UfcRankings::Rankings
2
+
3
+ @@champions = []
4
+ @@p4p = []
5
+ @@fly = []
6
+ @@bantam = []
7
+ @@feather = []
8
+ @@light = []
9
+ @@welter = []
10
+ @@middle = []
11
+ @@light_heavy = []
12
+ @@heavy = []
13
+ @@womens_straw = []
14
+ @@womens_bantam = []
15
+
16
+
17
+ def self.scrape_rankings
18
+ doc = Nokogiri::HTML(open("http://www.ufc.com/rankings"))
19
+ rankings = doc.css(".ranking-list")
20
+ pound_for_pound = rankings[0].css("a").children.each {|fighter| @@p4p << fighter.text.strip.split.join(" ")}
21
+ rankings[1].css("a").children.each {|fighter| @@fly << fighter.text.strip.split.join(" ")}
22
+ rankings[2].css("a").children.each {|fighter| @@bantam << fighter.text.strip.split.join(" ")}
23
+ rankings[3].css("a").children.each {|fighter| @@feather << fighter.text.strip.split.join(" ")}
24
+ rankings[4].css("a").children.each {|fighter| @@light << fighter.text.strip.split.join(" ")}
25
+ rankings[5].css("a").children.each {|fighter| @@welter << fighter.text.strip.split.join(" ")}
26
+ rankings[6].css("a").children.each {|fighter| @@middle << fighter.text.strip.split.join(" ")}
27
+ rankings[7].css("a").children.each {|fighter| @@light_heavy << fighter.text.strip.split.join(" ")}
28
+ rankings[8].css("a").children.each {|fighter| @@heavy << fighter.text.strip.split.join(" ")}
29
+ rankings[9].css("a").children.each {|fighter| @@womens_straw << fighter.text.strip.split.join(" ")}
30
+ rankings[10].css("a").children.each {|fighter| @@womens_bantam << fighter.text.strip.split.join(" ")}
31
+ @@champions << @@fly[0] << @@bantam[0] << @@feather[0] << @@light[0] << @@welter[0] << @@middle[0] << @@light_heavy[0] << @@heavy[0] << @@womens_straw[0] << @@womens_bantam[0]
32
+
33
+
34
+ end
35
+
36
+ def self.p4p
37
+ @@p4p.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
38
+ end
39
+
40
+ def self.fly
41
+ puts "Champion: #{@@champions[0]}"
42
+ @@fly.shift
43
+ @@fly.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
44
+ end
45
+
46
+ def self.bantam
47
+ puts "Champion: #{@@champions[1]}"
48
+ @@bantam.shift
49
+ @@bantam.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
50
+ end
51
+
52
+ def self.feather
53
+ puts "Champion: #{@@champions[2]}"
54
+ @@feather.shift
55
+ @@feather.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
56
+ end
57
+
58
+ def self.light
59
+ puts "Champion: #{@@champions[3]}"
60
+ @@light.shift
61
+ @@light.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
62
+ end
63
+
64
+ def self.welter
65
+ puts "Champion: #{@@champions[4]}"
66
+ @@welter.shift
67
+ @@welter.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
68
+ end
69
+
70
+ def self.middle
71
+ puts "Champion: #{@@champions[5]}"
72
+ @@middle.shift
73
+ @@middle.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
74
+ end
75
+
76
+ def self.light_heavy
77
+ puts "Champion: #{@@champions[6]}"
78
+ @@light_heavy.shift
79
+ @@light_heavy.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
80
+ end
81
+
82
+ def self.heavy
83
+ puts "Champion: #{@@champions[7]}"
84
+ @@heavy.shift
85
+ @@heavy.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
86
+ end
87
+
88
+ def self.womens_straw
89
+ puts "Champion: #{@@champions[8]}"
90
+ @@womens_straw.shift
91
+ @@womens_straw.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
92
+ end
93
+
94
+ def self.womens_bantam
95
+ puts "Champion: #{@@champions[9]}"
96
+ @@womens_bantam.shift
97
+ @@womens_bantam.each_with_index {|fighter, i|puts "#{i+1}. #{fighter}"}
98
+ end
99
+ end
@@ -0,0 +1,3 @@
1
+ module UfcRankings
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ufc_rankings/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ufc_rankings"
8
+ spec.version = UfcRankings::VERSION
9
+ spec.authors = ["johnram528"]
10
+ spec.email = ["johnram528@gmail.com"]
11
+
12
+ spec.summary = "Quickly view rankings UFC Rankings"
13
+ spec.description = "This gem allows you to see the most up to date UFC rankings for every weight class."
14
+ spec.homepage = "https://github.com/johnram528/ufc-rankings-cli-gem"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_development_dependency "pry"
34
+
35
+ spec.add_dependency "nokogiri"
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ufc_rankings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - johnram528
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-05 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: This gem allows you to see the most up to date UFC rankings for every
84
+ weight class.
85
+ email:
86
+ - johnram528@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - bin/ufc_rankings
102
+ - lib/ufc_rankings.rb
103
+ - lib/ufc_rankings/cli.rb
104
+ - lib/ufc_rankings/rankings.rb
105
+ - lib/ufc_rankings/version.rb
106
+ - ufc_rankings.gemspec
107
+ homepage: https://github.com/johnram528/ufc-rankings-cli-gem
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Quickly view rankings UFC Rankings
132
+ test_files: []