mls_standings 0.1.3 → 0.1.4
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 +4 -4
- data/.gitignore +9 -9
- data/Gemfile +4 -4
- data/LICENSE.md +8 -8
- data/README.md +20 -20
- data/Rakefile +2 -2
- data/bin/console +13 -13
- data/bin/mls_standings +11 -11
- data/bin/setup +7 -7
- data/config/environment.rb +9 -9
- data/lib/mls_standings/cli.rb +140 -140
- data/lib/mls_standings/scrapper.rb +35 -35
- data/lib/mls_standings/team.rb +27 -27
- data/lib/mls_standings/version.rb +3 -3
- data/lib/mls_standings.rb +9 -9
- data/mls_standings-0.1.3.gem +0 -0
- data/mls_standings.gemspec +33 -33
- data/spec.md +14 -14
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da397376826afd42e8c33c4ba53f218e82678084
|
|
4
|
+
data.tar.gz: ad15f77ff4eae73f61a522b854325192dec68b70
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1cb6e21a74050a122d924029886de3f72db6fd73fc19da7ea5faa10e2896b01da9f855f371087ce478107bcb8bb5de29bc9e836545ae1ba55921bd31c6a37bd
|
|
7
|
+
data.tar.gz: 79fdff2b5d40ed13b09f5e5a0bf99e0034981f8adc410d7594eb27c4a0ecd2222c62ac3001a752cf0bb9c339929d7b31120ad20298092cbaf00734f2fe03ce64
|
data/.gitignore
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/Gemfile.lock
|
|
4
|
-
/_yardoc/
|
|
5
|
-
/coverage/
|
|
6
|
-
/doc/
|
|
7
|
-
/pkg/
|
|
8
|
-
/spec/reports/
|
|
9
|
-
/tmp/
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/Gemfile.lock
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/coverage/
|
|
6
|
+
/doc/
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/tmp/
|
data/Gemfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in mls_standings.gemspec
|
|
4
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in mls_standings.gemspec
|
|
4
|
+
gemspec
|
|
5
5
|
gem 'require_all'
|
data/LICENSE.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
MIT LICENSE
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Alberto Mayanga
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Alberto Mayanga
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
9
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# MLS Standings
|
|
2
|
-
|
|
3
|
-
This Ruby gem provides a CLI to view the current standings of teams in Major League Soccer during the season.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
You can install this gem via ```gem install mls_standings```. The ```mls_standings``` CLI will be installed and you can run ```mls_standings``` to get a live table to Major League Soccer's current season standings.
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
Run: ```mls_standings``` after installing the gem.
|
|
12
|
-
Drill Down to MLS conference standings and team record.
|
|
13
|
-
|
|
14
|
-
## Contributing
|
|
15
|
-
|
|
16
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/Booligan/mls-standings-cli-app.
|
|
17
|
-
|
|
18
|
-
## License
|
|
19
|
-
|
|
20
|
-
The gem is available as open source under the terms of the [MIT](https://github.com/Booligan/mls-standings-cli-app/blob/master/LICENSE.md) License.
|
|
1
|
+
# MLS Standings
|
|
2
|
+
|
|
3
|
+
This Ruby gem provides a CLI to view the current standings of teams in Major League Soccer during the season.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install this gem via ```gem install mls_standings```. The ```mls_standings``` CLI will be installed and you can run ```mls_standings``` to get a live table to Major League Soccer's current season standings.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Run: ```mls_standings``` after installing the gem.
|
|
12
|
+
Drill Down to MLS conference standings and team record.
|
|
13
|
+
|
|
14
|
+
## Contributing
|
|
15
|
+
|
|
16
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Booligan/mls-standings-cli-app.
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
The gem is available as open source under the terms of the [MIT](https://github.com/Booligan/mls-standings-cli-app/blob/master/LICENSE.md) License.
|
data/Rakefile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require "bundler/gem_tasks"
|
|
2
|
-
task :default => :spec
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
task :default => :spec
|
data/bin/console
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "mls_standings"
|
|
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"
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "mls_standings"
|
|
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
14
|
IRB.start(__FILE__)
|
data/bin/mls_standings
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
require "bundler/setup"
|
|
3
|
-
require "mls_standings"
|
|
4
|
-
# require "./lib/mls_standings"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def reload!
|
|
8
|
-
load_all './lib'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
MlsStandings::CLI.new.call
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
require "mls_standings"
|
|
4
|
+
# require "./lib/mls_standings"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def reload!
|
|
8
|
+
load_all './lib'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
MlsStandings::CLI.new.call
|
data/bin/setup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
set -vx
|
|
5
|
-
|
|
6
|
-
bundle install
|
|
7
|
-
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
set -vx
|
|
5
|
+
|
|
6
|
+
bundle install
|
|
7
|
+
|
|
8
8
|
# Do any other automated setup that you need to do here
|
data/config/environment.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require 'pry'
|
|
2
|
-
require 'open-uri'
|
|
3
|
-
require 'nokogiri'
|
|
4
|
-
require 'colorize'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
require_relative '../lib/mls_standings/scrapper'
|
|
8
|
-
require_relative '../lib/mls_standings/team'
|
|
9
|
-
require_relative '../lib/mls_standings/cli'
|
|
1
|
+
require 'pry'
|
|
2
|
+
require 'open-uri'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require 'colorize'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
require_relative '../lib/mls_standings/scrapper'
|
|
8
|
+
require_relative '../lib/mls_standings/team'
|
|
9
|
+
require_relative '../lib/mls_standings/cli'
|
data/lib/mls_standings/cli.rb
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
class MlsStandings::CLI
|
|
2
|
-
|
|
3
|
-
def call
|
|
4
|
-
MlsStandings::Scrapper.create_teams
|
|
5
|
-
start_menu
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def start_menu
|
|
9
|
-
system "clear"
|
|
10
|
-
puts " ***************".colorize(:blue)
|
|
11
|
-
puts " *MLS Standings*".colorize(:red)
|
|
12
|
-
puts " ***************".colorize(:blue)
|
|
13
|
-
|
|
14
|
-
puts "\n1. Eastern Conference."
|
|
15
|
-
puts "2. Western Conference.\n\n"
|
|
16
|
-
puts "Enter '1' for the MLS Eastern Conference."
|
|
17
|
-
puts "Enter '2' for the MLS Western Conference."
|
|
18
|
-
puts "\nSelect a conference or type 'e' to exit: "
|
|
19
|
-
input = nil
|
|
20
|
-
|
|
21
|
-
until input == 'e' || input == '1' || input == '2'
|
|
22
|
-
input = gets.strip.downcase
|
|
23
|
-
case input.downcase
|
|
24
|
-
when "1"
|
|
25
|
-
eastern_conf
|
|
26
|
-
when "2"
|
|
27
|
-
western_conf
|
|
28
|
-
when "e"
|
|
29
|
-
exit
|
|
30
|
-
else
|
|
31
|
-
puts "Not Valid. Please select a conference: "
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def eastern_conf
|
|
37
|
-
system "clear"
|
|
38
|
-
puts " MLS Eastern Conference".colorize(:blue)
|
|
39
|
-
puts " **********************".colorize(:blue)
|
|
40
|
-
i = 1
|
|
41
|
-
teams= MlsStandings::Team.eastern_conf
|
|
42
|
-
teams.each do |team|
|
|
43
|
-
puts "#{i}. #{team.name}"
|
|
44
|
-
i += 1
|
|
45
|
-
end
|
|
46
|
-
puts "\nSelect 1-11 to get more information on the team, 's' to switch conference, or exit:"
|
|
47
|
-
input = nil
|
|
48
|
-
|
|
49
|
-
until input == 'et' || input == 's' || input.to_i.between?(1, 11)
|
|
50
|
-
input = gets.strip.downcase
|
|
51
|
-
case
|
|
52
|
-
when input.to_i.between?(1, 11)
|
|
53
|
-
east_team_record(input.to_i)
|
|
54
|
-
when input.downcase == "s"
|
|
55
|
-
western_conf
|
|
56
|
-
when input.downcase == "e"
|
|
57
|
-
exit
|
|
58
|
-
else
|
|
59
|
-
puts "Not a valid team. Please select a valid team or, 's' to switch or 'e' to exit: "
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def western_conf
|
|
65
|
-
system "clear"
|
|
66
|
-
puts " MLS Western Conference".colorize(:red)
|
|
67
|
-
puts " **********************".colorize(:red)
|
|
68
|
-
i = 1
|
|
69
|
-
teams = MlsStandings::Team.western_conf
|
|
70
|
-
teams.each do |team|
|
|
71
|
-
puts "#{i}. #{team.name}"
|
|
72
|
-
i += 1
|
|
73
|
-
end
|
|
74
|
-
puts "\nSelect 1-11 to get more information on the team, 's' to switch conference, or exit:"
|
|
75
|
-
input = nil
|
|
76
|
-
|
|
77
|
-
until input == 'e' || input == 's'||input.to_i.between?(1,
|
|
78
|
-
input = gets.strip.downcase
|
|
79
|
-
case
|
|
80
|
-
when input.to_i.between?(1,
|
|
81
|
-
west_team_record(input.to_i)
|
|
82
|
-
when input.downcase == "s"
|
|
83
|
-
eastern_conf
|
|
84
|
-
when input.downcase == "e"
|
|
85
|
-
exit
|
|
86
|
-
else
|
|
87
|
-
puts "Not a valid team. Please select a valid team or, 's' or 'e': "
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def east_team_record(input)
|
|
93
|
-
system "clear"
|
|
94
|
-
team = MlsStandings::Team.eastern_conf[input - 1]
|
|
95
|
-
puts "#{team.name}".colorize(:blue)
|
|
96
|
-
puts "***********************".colorize(:blue)
|
|
97
|
-
puts "Games Played: #{team.games_played}"
|
|
98
|
-
puts "Wins: #{team.wins}"
|
|
99
|
-
puts "Losses: #{team.losses}"
|
|
100
|
-
puts "Ties: #{team.ties}"
|
|
101
|
-
puts "\n Type 'MLS' to restart CLI or 'e' to exit:"
|
|
102
|
-
|
|
103
|
-
until input == 'e' || input == 'mls'
|
|
104
|
-
input = gets.strip.downcase
|
|
105
|
-
case input.downcase
|
|
106
|
-
when "e"
|
|
107
|
-
exit
|
|
108
|
-
when "mls"
|
|
109
|
-
start_menu
|
|
110
|
-
else
|
|
111
|
-
puts "Not Valid. Please select type 'MLS' or 'e': "
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def west_team_record(input)
|
|
117
|
-
system "clear"
|
|
118
|
-
team = MlsStandings::Team.western_conf[input - 1]
|
|
119
|
-
puts "#{team.name}".colorize(:red)
|
|
120
|
-
puts "***********************".colorize(:red)
|
|
121
|
-
puts "Games Played: #{team.games_played}"
|
|
122
|
-
puts "Wins: #{team.wins}"
|
|
123
|
-
puts "Losses: #{team.losses}"
|
|
124
|
-
puts "Ties: #{team.ties}"
|
|
125
|
-
puts "\n Type 'MLS' to restart CLI or 'e' to exit:"
|
|
126
|
-
|
|
127
|
-
until input == 'e' || input == 'mls'
|
|
128
|
-
input = gets.strip.downcase
|
|
129
|
-
case input.downcase
|
|
130
|
-
when "e"
|
|
131
|
-
exit
|
|
132
|
-
when "mls"
|
|
133
|
-
start_menu
|
|
134
|
-
else
|
|
135
|
-
puts "Not Valid. Please select type 'MLS' or 'exit': "
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
end
|
|
1
|
+
class MlsStandings::CLI
|
|
2
|
+
|
|
3
|
+
def call
|
|
4
|
+
MlsStandings::Scrapper.create_teams
|
|
5
|
+
start_menu
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def start_menu
|
|
9
|
+
system "clear"
|
|
10
|
+
puts " ***************".colorize(:blue)
|
|
11
|
+
puts " *MLS Standings*".colorize(:red)
|
|
12
|
+
puts " ***************".colorize(:blue)
|
|
13
|
+
|
|
14
|
+
puts "\n1. Eastern Conference."
|
|
15
|
+
puts "2. Western Conference.\n\n"
|
|
16
|
+
puts "Enter '1' for the MLS Eastern Conference."
|
|
17
|
+
puts "Enter '2' for the MLS Western Conference."
|
|
18
|
+
puts "\nSelect a conference or type 'e' to exit: "
|
|
19
|
+
input = nil
|
|
20
|
+
|
|
21
|
+
until input == 'e' || input == '1' || input == '2'
|
|
22
|
+
input = gets.strip.downcase
|
|
23
|
+
case input.downcase
|
|
24
|
+
when "1"
|
|
25
|
+
eastern_conf
|
|
26
|
+
when "2"
|
|
27
|
+
western_conf
|
|
28
|
+
when "e"
|
|
29
|
+
exit
|
|
30
|
+
else
|
|
31
|
+
puts "Not Valid. Please select a conference: "
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def eastern_conf
|
|
37
|
+
system "clear"
|
|
38
|
+
puts " MLS Eastern Conference".colorize(:blue)
|
|
39
|
+
puts " **********************".colorize(:blue)
|
|
40
|
+
i = 1
|
|
41
|
+
teams= MlsStandings::Team.eastern_conf
|
|
42
|
+
teams.each do |team|
|
|
43
|
+
puts "#{i}. #{team.name}"
|
|
44
|
+
i += 1
|
|
45
|
+
end
|
|
46
|
+
puts "\nSelect 1-11 to get more information on the team, 's' to switch conference, or exit:"
|
|
47
|
+
input = nil
|
|
48
|
+
|
|
49
|
+
until input == 'et' || input == 's' || input.to_i.between?(1, 11)
|
|
50
|
+
input = gets.strip.downcase
|
|
51
|
+
case
|
|
52
|
+
when input.to_i.between?(1, 11)
|
|
53
|
+
east_team_record(input.to_i)
|
|
54
|
+
when input.downcase == "s"
|
|
55
|
+
western_conf
|
|
56
|
+
when input.downcase == "e"
|
|
57
|
+
exit
|
|
58
|
+
else
|
|
59
|
+
puts "Not a valid team. Please select a valid team or, 's' to switch or 'e' to exit: "
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def western_conf
|
|
65
|
+
system "clear"
|
|
66
|
+
puts " MLS Western Conference".colorize(:red)
|
|
67
|
+
puts " **********************".colorize(:red)
|
|
68
|
+
i = 1
|
|
69
|
+
teams = MlsStandings::Team.western_conf
|
|
70
|
+
teams.each do |team|
|
|
71
|
+
puts "#{i}. #{team.name}"
|
|
72
|
+
i += 1
|
|
73
|
+
end
|
|
74
|
+
puts "\nSelect 1-11 to get more information on the team, 's' to switch conference, or exit:"
|
|
75
|
+
input = nil
|
|
76
|
+
|
|
77
|
+
until input == 'e' || input == 's'||input.to_i.between?(1, 12)
|
|
78
|
+
input = gets.strip.downcase
|
|
79
|
+
case
|
|
80
|
+
when input.to_i.between?(1, 12)
|
|
81
|
+
west_team_record(input.to_i)
|
|
82
|
+
when input.downcase == "s"
|
|
83
|
+
eastern_conf
|
|
84
|
+
when input.downcase == "e"
|
|
85
|
+
exit
|
|
86
|
+
else
|
|
87
|
+
puts "Not a valid team. Please select a valid team or, 's' or 'e': "
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def east_team_record(input)
|
|
93
|
+
system "clear"
|
|
94
|
+
team = MlsStandings::Team.eastern_conf[input - 1]
|
|
95
|
+
puts "#{team.name}".colorize(:blue)
|
|
96
|
+
puts "***********************".colorize(:blue)
|
|
97
|
+
puts "Games Played: #{team.games_played}"
|
|
98
|
+
puts "Wins: #{team.wins}"
|
|
99
|
+
puts "Losses: #{team.losses}"
|
|
100
|
+
puts "Ties: #{team.ties}"
|
|
101
|
+
puts "\n Type 'MLS' to restart CLI or 'e' to exit:"
|
|
102
|
+
|
|
103
|
+
until input == 'e' || input == 'mls'
|
|
104
|
+
input = gets.strip.downcase
|
|
105
|
+
case input.downcase
|
|
106
|
+
when "e"
|
|
107
|
+
exit
|
|
108
|
+
when "mls"
|
|
109
|
+
start_menu
|
|
110
|
+
else
|
|
111
|
+
puts "Not Valid. Please select type 'MLS' or 'e': "
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def west_team_record(input)
|
|
117
|
+
system "clear"
|
|
118
|
+
team = MlsStandings::Team.western_conf[input - 1]
|
|
119
|
+
puts "#{team.name}".colorize(:red)
|
|
120
|
+
puts "***********************".colorize(:red)
|
|
121
|
+
puts "Games Played: #{team.games_played}"
|
|
122
|
+
puts "Wins: #{team.wins}"
|
|
123
|
+
puts "Losses: #{team.losses}"
|
|
124
|
+
puts "Ties: #{team.ties}"
|
|
125
|
+
puts "\n Type 'MLS' to restart CLI or 'e' to exit:"
|
|
126
|
+
|
|
127
|
+
until input == 'e' || input == 'mls'
|
|
128
|
+
input = gets.strip.downcase
|
|
129
|
+
case input.downcase
|
|
130
|
+
when "e"
|
|
131
|
+
exit
|
|
132
|
+
when "mls"
|
|
133
|
+
start_menu
|
|
134
|
+
else
|
|
135
|
+
puts "Not Valid. Please select type 'MLS' or 'exit': "
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
class MlsStandings::Scrapper
|
|
2
|
-
|
|
3
|
-
def self.get_page
|
|
4
|
-
html = open("https://www.mlssoccer.com/standings")
|
|
5
|
-
Nokogiri::HTML(html)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.scrape_teams
|
|
9
|
-
html = self.get_page
|
|
10
|
-
table = html.css('.standings_table tbody tr')
|
|
11
|
-
teams_hash_array = []
|
|
12
|
-
|
|
13
|
-
table.each do |team|
|
|
14
|
-
name = team.css('[data-title="Club"] .hide-on-mobile-inline').text
|
|
15
|
-
games_played = team.css('[data-title="Games Played"]').text
|
|
16
|
-
wins = team.css('[data-title="Wins"]').text
|
|
17
|
-
losses = team.css('[data-title="Losses"]').text
|
|
18
|
-
ties = team.css('[data-title="Ties"]').text
|
|
19
|
-
name.slice!('x - ')
|
|
20
|
-
name.slice!('s - ')
|
|
21
|
-
name.slice!('y - ')
|
|
22
|
-
team_hash = {:name => name, :games_played => games_played, :wins => wins, :losses => losses, :ties => ties}
|
|
23
|
-
teams_hash_array << team_hash
|
|
24
|
-
end
|
|
25
|
-
teams_hash_array.delete_at(0)
|
|
26
|
-
teams_hash_array.delete_at(11)
|
|
27
|
-
teams_hash_array
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.create_teams
|
|
31
|
-
teams = self.scrape_teams
|
|
32
|
-
teams.each{|team| MlsStandings::Team.create_from_scrape(team)}
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
1
|
+
class MlsStandings::Scrapper
|
|
2
|
+
|
|
3
|
+
def self.get_page
|
|
4
|
+
html = open("https://www.mlssoccer.com/standings")
|
|
5
|
+
Nokogiri::HTML(html)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.scrape_teams
|
|
9
|
+
html = self.get_page
|
|
10
|
+
table = html.css('.standings_table tbody tr')
|
|
11
|
+
teams_hash_array = []
|
|
12
|
+
|
|
13
|
+
table.each do |team|
|
|
14
|
+
name = team.css('[data-title="Club"] .hide-on-mobile-inline').text
|
|
15
|
+
games_played = team.css('[data-title="Games Played"]').text
|
|
16
|
+
wins = team.css('[data-title="Wins"]').text
|
|
17
|
+
losses = team.css('[data-title="Losses"]').text
|
|
18
|
+
ties = team.css('[data-title="Ties"]').text
|
|
19
|
+
name.slice!('x - ')
|
|
20
|
+
name.slice!('s - ')
|
|
21
|
+
name.slice!('y - ')
|
|
22
|
+
team_hash = {:name => name, :games_played => games_played, :wins => wins, :losses => losses, :ties => ties}
|
|
23
|
+
teams_hash_array << team_hash
|
|
24
|
+
end
|
|
25
|
+
teams_hash_array.delete_at(0)
|
|
26
|
+
teams_hash_array.delete_at(11)
|
|
27
|
+
teams_hash_array
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.create_teams
|
|
31
|
+
teams = self.scrape_teams
|
|
32
|
+
teams.each{|team| MlsStandings::Team.create_from_scrape(team)}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
data/lib/mls_standings/team.rb
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
class MlsStandings::Team
|
|
2
|
-
attr_accessor :name, :games_played, :wins, :losses, :ties
|
|
3
|
-
|
|
4
|
-
@@all = []
|
|
5
|
-
|
|
6
|
-
def initialize(team_hash)
|
|
7
|
-
team_hash.each_key{|k| self.send("#{k}=", team_hash[k])}
|
|
8
|
-
@@all << self
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.all
|
|
12
|
-
@@all
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.create_from_scrape(team)
|
|
16
|
-
self.new(team)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def self.eastern_conf
|
|
20
|
-
self.all[0..10]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def self.western_conf
|
|
24
|
-
self.all[11..22]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
1
|
+
class MlsStandings::Team
|
|
2
|
+
attr_accessor :name, :games_played, :wins, :losses, :ties
|
|
3
|
+
|
|
4
|
+
@@all = []
|
|
5
|
+
|
|
6
|
+
def initialize(team_hash)
|
|
7
|
+
team_hash.each_key{|k| self.send("#{k}=", team_hash[k])}
|
|
8
|
+
@@all << self
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.all
|
|
12
|
+
@@all
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.create_from_scrape(team)
|
|
16
|
+
self.new(team)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.eastern_conf
|
|
20
|
+
self.all[0..10]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.western_conf
|
|
24
|
+
self.all[11..22]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module MlsStandings
|
|
2
|
-
VERSION = "0.1.
|
|
3
|
-
end
|
|
1
|
+
module MlsStandings
|
|
2
|
+
VERSION = "0.1.4"
|
|
3
|
+
end
|
data/lib/mls_standings.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require 'open-uri'
|
|
2
|
-
require 'nokogiri'
|
|
3
|
-
require 'colorize'
|
|
4
|
-
|
|
5
|
-
require_relative './mls_standings/version'
|
|
6
|
-
require_relative './mls_standings/team'
|
|
7
|
-
require_relative './mls_standings/cli'
|
|
8
|
-
require_relative './mls_standings/scrapper'
|
|
9
|
-
require_relative '../config/environment'
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
require 'colorize'
|
|
4
|
+
|
|
5
|
+
require_relative './mls_standings/version'
|
|
6
|
+
require_relative './mls_standings/team'
|
|
7
|
+
require_relative './mls_standings/cli'
|
|
8
|
+
require_relative './mls_standings/scrapper'
|
|
9
|
+
require_relative '../config/environment'
|
|
Binary file
|
data/mls_standings.gemspec
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'mls_standings/version'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name = "mls_standings"
|
|
9
|
-
spec.version = MlsStandings::VERSION
|
|
10
|
-
spec.authors = ["Alberto Mayanga"]
|
|
11
|
-
spec.email = ["aamayanga@gmail.com"]
|
|
12
|
-
|
|
13
|
-
spec.summary = %q{Command line app to view the table standings of Major League Soccer’s current season}
|
|
14
|
-
spec.description = %q{Live table standings coming stright from MLSsoccer.com}
|
|
15
|
-
spec.homepage = "https://github.com/Booligan/mls-standings-cli-app"
|
|
16
|
-
spec.license = "MIT"
|
|
17
|
-
|
|
18
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
19
|
-
f.match(%r{^(test|spec|features)/})
|
|
20
|
-
end
|
|
21
|
-
spec.bindir = "bin"
|
|
22
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
23
|
-
spec.require_paths = ["lib"]
|
|
24
|
-
spec.post_install_message = "What is your favorite team's record? Find out now!"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
|
28
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
29
|
-
spec.add_development_dependency "pry", '~> 0.11.3'
|
|
30
|
-
|
|
31
|
-
spec.add_dependency "nokogiri", '~> 1.8', '>= 1.8.2'
|
|
32
|
-
spec.add_dependency "colorize", '~> 0.8.1'
|
|
33
|
-
end
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'mls_standings/version'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "mls_standings"
|
|
9
|
+
spec.version = MlsStandings::VERSION
|
|
10
|
+
spec.authors = ["Alberto Mayanga"]
|
|
11
|
+
spec.email = ["aamayanga@gmail.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = %q{Command line app to view the table standings of Major League Soccer’s current season}
|
|
14
|
+
spec.description = %q{Live table standings coming stright from MLSsoccer.com}
|
|
15
|
+
spec.homepage = "https://github.com/Booligan/mls-standings-cli-app"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
|
20
|
+
end
|
|
21
|
+
spec.bindir = "bin"
|
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ["lib"]
|
|
24
|
+
spec.post_install_message = "What is your favorite team's record? Find out now!"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
29
|
+
spec.add_development_dependency "pry", '~> 0.11.3'
|
|
30
|
+
|
|
31
|
+
spec.add_dependency "nokogiri", '~> 1.8', '>= 1.8.2'
|
|
32
|
+
spec.add_dependency "colorize", '~> 0.8.1'
|
|
33
|
+
end
|
data/spec.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Specifications for the CLI Assessment
|
|
2
|
-
|
|
3
|
-
Specs:
|
|
4
|
-
- [x] Have a CLI for interfacing with the application
|
|
5
|
-
# I built the initial menu for the CLI. It currently displays the title and a menu for which Conference to select, or to exit.
|
|
6
|
-
# Each Conference calls a method to display the teams in the selected conference.
|
|
7
|
-
- [x] Pull data from an external source
|
|
8
|
-
# Used Nokogiri to scrape a table into a variable. I was then able to iterate over each 'tr' tag, and grab the attributes for each team instance.
|
|
9
|
-
# Once all of the data was scraped and pushed into the teams_hash_array, I was able to turn this data into instances of the Team class.
|
|
10
|
-
- [x ] Implement both list and detail views
|
|
11
|
-
# Once all of my instances were created and added to the @@all array, I was able to complete the CLI.
|
|
12
|
-
# The first menu splits Team.all in half to list the league conferences.
|
|
13
|
-
# The second menu shows all of the teams in their respective conferences sorted by their current place on the league table.
|
|
14
|
-
# The third menu shows games played and win-lose-tie record for the selected team.
|
|
1
|
+
# Specifications for the CLI Assessment
|
|
2
|
+
|
|
3
|
+
Specs:
|
|
4
|
+
- [x] Have a CLI for interfacing with the application
|
|
5
|
+
# I built the initial menu for the CLI. It currently displays the title and a menu for which Conference to select, or to exit.
|
|
6
|
+
# Each Conference calls a method to display the teams in the selected conference.
|
|
7
|
+
- [x] Pull data from an external source
|
|
8
|
+
# Used Nokogiri to scrape a table into a variable. I was then able to iterate over each 'tr' tag, and grab the attributes for each team instance.
|
|
9
|
+
# Once all of the data was scraped and pushed into the teams_hash_array, I was able to turn this data into instances of the Team class.
|
|
10
|
+
- [x ] Implement both list and detail views
|
|
11
|
+
# Once all of my instances were created and added to the @@all array, I was able to complete the CLI.
|
|
12
|
+
# The first menu splits Team.all in half to list the league conferences.
|
|
13
|
+
# The second menu shows all of the teams in their respective conferences sorted by their current place on the league table.
|
|
14
|
+
# The third menu shows games played and win-lose-tie record for the selected team.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mls_standings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alberto Mayanga
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-03-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -111,6 +111,7 @@ files:
|
|
|
111
111
|
- lib/mls_standings/team.rb
|
|
112
112
|
- lib/mls_standings/version.rb
|
|
113
113
|
- mls_standings-0.1.2.gem
|
|
114
|
+
- mls_standings-0.1.3.gem
|
|
114
115
|
- mls_standings.gemspec
|
|
115
116
|
- spec.md
|
|
116
117
|
homepage: https://github.com/Booligan/mls-standings-cli-app
|
|
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
134
|
version: '0'
|
|
134
135
|
requirements: []
|
|
135
136
|
rubyforge_project:
|
|
136
|
-
rubygems_version: 2.6.
|
|
137
|
+
rubygems_version: 2.6.13
|
|
137
138
|
signing_key:
|
|
138
139
|
specification_version: 4
|
|
139
140
|
summary: Command line app to view the table standings of Major League Soccer’s current
|