soccer-quiz 0.1.2 → 0.1.6
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/Gemfile.lock +1 -1
- data/bin/bundle +114 -0
- data/bin/console +1 -1
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/nokogiri +29 -0
- data/bin/quiz +28 -2
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/lib/quiz/champion_league.rb +1 -1
- data/lib/quiz/cli.rb +80 -86
- data/lib/quiz/scraper.rb +20 -10
- data/lib/quiz/version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a51b5eb46f550cc543246f71eb5d3cee28b6020cd808733640c9aad5af1496
|
4
|
+
data.tar.gz: c5cfc34d7ce3d71c613eb08ef13ced9cb7f7d382031cdc3b0a99926ee5db43cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d741e302a8af2fd60c841e07f57f3132a50d95053c1ca99705ecf612ea4940e39bc45d74bf825b37710ffccead1fba2aac2eae9141066e73c9b998031dcacf5e
|
7
|
+
data.tar.gz: e6b337b9b880ca741aade6be49dc67fed7837763c2a3cc17b2805798656b67f63e647cdb3663a699b1d58a71de2c6074ab809b2c8e257ff3495d4235d0611ba0
|
data/Gemfile.lock
CHANGED
data/bin/bundle
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||=
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
71
|
+
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
73
|
+
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
75
|
+
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
77
|
+
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
79
|
+
|
80
|
+
requirement
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_bundler!
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
85
|
+
|
86
|
+
activate_bundler
|
87
|
+
end
|
88
|
+
|
89
|
+
def activate_bundler
|
90
|
+
gem_error = activation_error_handling do
|
91
|
+
gem "bundler", bundler_requirement
|
92
|
+
end
|
93
|
+
return if gem_error.nil?
|
94
|
+
require_error = activation_error_handling do
|
95
|
+
require "bundler/version"
|
96
|
+
end
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
99
|
+
exit 42
|
100
|
+
end
|
101
|
+
|
102
|
+
def activation_error_handling
|
103
|
+
yield
|
104
|
+
nil
|
105
|
+
rescue StandardError, LoadError => e
|
106
|
+
e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
m.load_bundler!
|
111
|
+
|
112
|
+
if m.invoked_as_script?
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
114
|
+
end
|
data/bin/console
CHANGED
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/nokogiri
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'nokogiri' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("nokogiri", "nokogiri")
|
data/bin/quiz
CHANGED
@@ -1,3 +1,29 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'quiz' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("soccer-quiz", "quiz")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/lib/quiz/champion_league.rb
CHANGED
data/lib/quiz/cli.rb
CHANGED
@@ -1,28 +1,14 @@
|
|
1
1
|
|
2
2
|
class Quiz::CLI
|
3
3
|
@@points = []
|
4
|
+
def initialize
|
5
|
+
end
|
4
6
|
def call
|
5
7
|
puts "Welcome to football soccer quiz."
|
6
|
-
|
7
|
-
champion_league_file = Quiz::Scraper.champion_league(champion_league_url,"tbody")
|
8
|
-
Quiz::CHAMPIONLEAGUE.champion_league_files(champion_league_file)
|
9
|
-
champion_league = Quiz::CHAMPIONLEAGUE.all
|
10
|
-
|
11
|
-
world_cup_url = "https://www.foxsports.com/soccer/fifa-world-cup/history"
|
12
|
-
world_cup = Quiz::Scraper.world_cup(world_cup_url,"tbody")
|
13
|
-
Quiz::Worldcup.world_cup_file(world_cup)
|
14
|
-
world_cup = Quiz::Worldcup.all
|
15
|
-
|
16
|
-
|
17
|
-
balon_d_or_url = "https://www.goal.com/es/noticias/todos-los-ganadores-del-balon-de-oro/wn19xivn1eh91t0jrslbzz5kq"
|
18
|
-
players = Quiz::Scraper.balon_d_or_players(balon_d_or_url,".tableizer-table")
|
19
|
-
Quiz::BALONDOR.balon_d_or(players)
|
20
|
-
balon_d_or = Quiz::BALONDOR.all
|
21
|
-
|
22
|
-
start_quiz(balon_d_or,champion_league,world_cup)
|
8
|
+
start_quiz
|
23
9
|
end
|
24
10
|
|
25
|
-
def start_quiz
|
11
|
+
def start_quiz
|
26
12
|
puts "*************************************************************************"
|
27
13
|
puts "Take this 10 question quiz to find out how much you know about soccer."
|
28
14
|
puts "*************************************************************************"
|
@@ -30,8 +16,10 @@ class Quiz::CLI
|
|
30
16
|
puts "*************************************************************************"
|
31
17
|
puts "To take the quiz press enter, to exit press 1 and enter."
|
32
18
|
input = gets
|
19
|
+
|
20
|
+
|
33
21
|
while input.to_i != 1
|
34
|
-
question_processor
|
22
|
+
question_processor
|
35
23
|
puts "To take the quiz one more time press enter. to exit press 1 and enter."
|
36
24
|
input = gets
|
37
25
|
end
|
@@ -41,7 +29,7 @@ class Quiz::CLI
|
|
41
29
|
def multiple_choice(answer,winners)
|
42
30
|
multiple_choice = []
|
43
31
|
multiple_choice << answer
|
44
|
-
until multiple_choice.size == 4
|
32
|
+
until multiple_choice.size == 4
|
45
33
|
multiple_choice << winners.sample
|
46
34
|
multiple_choice = multiple_choice.uniq
|
47
35
|
end
|
@@ -65,40 +53,44 @@ class Quiz::CLI
|
|
65
53
|
gets
|
66
54
|
end
|
67
55
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
56
|
+
def question_selector(objects,question)
|
57
|
+
years = objects.map{|item| item.year}
|
58
|
+
winners = objects.map{|item|item.winner}
|
59
|
+
hosts = objects.map{|item|item.host}
|
60
|
+
runner_ups = objects.map{|item|item.runner_up}
|
61
|
+
random_year = years.sample
|
62
|
+
random_winner = winners.sample
|
63
|
+
|
64
|
+
instace_for_answers = objects.select{|item|item.year == random_year}
|
65
|
+
|
66
|
+
answer_for_how_many = objects.select{|item|item.winner == random_winner}.size
|
67
|
+
|
68
|
+
winner = instace_for_answers[0].winner
|
69
|
+
|
70
|
+
host = instace_for_answers[0].host
|
71
|
+
runner_up = instace_for_answers[0].runner_up
|
72
|
+
|
73
|
+
if all_question("none",random_year)[question].include?("host")
|
74
|
+
puts all_question(host,random_year)[question]
|
75
|
+
multiple_choice(host,hosts)
|
76
|
+
elsif all_question("none",random_year)[question].include?("runner-up")
|
77
|
+
runner_ups = runner_ups.reject{|item| item == winner}
|
78
|
+
puts all_question(winner,random_year)[question]
|
79
|
+
multiple_choice(runner_up,runner_ups)
|
88
80
|
elsif all_question("none",random_year)[question].include?("How many")
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
81
|
+
puts all_question(random_winner,'none')[question]
|
82
|
+
obtions = []
|
83
|
+
counter = 1
|
84
|
+
while obtions.size < 13
|
85
|
+
obtions << counter
|
86
|
+
counter += 1
|
95
87
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
88
|
+
multiple_choice(answer_for_how_many,obtions)
|
89
|
+
else
|
90
|
+
puts all_question(winner,random_year)[question]
|
91
|
+
multiple_choice(winner,winners)
|
92
|
+
end
|
93
|
+
end
|
102
94
|
|
103
95
|
def all_question(team, year)
|
104
96
|
["Who won the world cup in #{year}?",
|
@@ -113,51 +105,51 @@ class Quiz::CLI
|
|
113
105
|
"How many Champion league #{team} has won?"
|
114
106
|
]
|
115
107
|
end
|
108
|
+
|
116
109
|
|
117
|
-
|
118
|
-
|
110
|
+
def question_processor
|
111
|
+
Quiz::CHAMPIONLEAGUE.champion_league_files(Quiz::Scraper.champion_league)
|
112
|
+
Quiz::Worldcup.world_cup_file(Quiz::Scraper.world_cup)
|
113
|
+
Quiz::BALONDOR.balon_d_or(Quiz::Scraper.balon_d_or_players)
|
114
|
+
champion_league = Quiz::CHAMPIONLEAGUE.all
|
115
|
+
world_cup = Quiz::Worldcup.all
|
116
|
+
balon_d_or = Quiz::BALONDOR.all
|
119
117
|
last_20_champions = []
|
120
118
|
counter = 44
|
121
|
-
while counter <
|
122
|
-
last_20_champions <<
|
119
|
+
while counter < champion_league.size
|
120
|
+
last_20_champions << champion_league[counter]
|
123
121
|
counter += 1
|
124
|
-
end
|
125
|
-
# question_counter = 0
|
126
|
-
# until question_counter == 9
|
127
|
-
# if question_counter < 4
|
128
|
-
# question_selector(world_cup,question_counter)
|
129
|
-
# elsif question_counter > 4 && question_counter < 7
|
130
|
-
# question_selector(last_20_champions,question_counter)
|
131
|
-
# elsif question_counter > 6 && question_counter < 9
|
132
|
-
# question_selector(balon_d_or,question_counter)
|
133
|
-
# else question_selector(champion_leage,question_counter)
|
134
|
-
# question_counter += 1
|
135
|
-
# end
|
136
|
-
question_selector(world_cup,0)
|
137
|
-
question_selector(world_cup,1)
|
138
|
-
question_selector(world_cup,2)
|
139
|
-
question_selector(world_cup,3)
|
140
|
-
question_selector(last_20_champions,4)
|
141
|
-
question_selector(last_20_champions,5)
|
142
|
-
question_selector(last_20_champions,6)
|
143
|
-
question_selector(balon_d_or,7)
|
144
|
-
question_selector(balon_d_or,8)
|
145
|
-
question_selector(champion_leage,9)
|
146
|
-
points = 0
|
147
|
-
@@points.each{|i|points += i }
|
148
|
-
if points > 5
|
149
|
-
puts "Congratulation you score #{points} of 10 points."
|
150
|
-
else puts "Sorry you failed. you score #{points} of 10 points."
|
151
|
-
end
|
152
|
-
Quiz::CLI.clear
|
153
122
|
end
|
123
|
+
question_selector(world_cup,0)
|
124
|
+
question_selector(world_cup,1)
|
125
|
+
question_selector(world_cup,2)
|
126
|
+
question_selector(world_cup,3)
|
127
|
+
question_selector(last_20_champions,4)
|
128
|
+
question_selector(last_20_champions,5)
|
129
|
+
question_selector(last_20_champions,6)
|
130
|
+
question_selector(balon_d_or,7)
|
131
|
+
question_selector(balon_d_or,8)
|
132
|
+
question_selector(champion_league,9)
|
133
|
+
points = 0
|
134
|
+
@@points.each{|i|points += i }
|
135
|
+
if points > 5
|
136
|
+
puts "Congratulation you score #{points} of 10 points."
|
137
|
+
else puts "Sorry you failed. you score #{points} of 10 points."
|
138
|
+
end
|
139
|
+
Quiz::CLI.clear
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
|
154
144
|
|
155
145
|
def self.points
|
156
146
|
@@points
|
157
147
|
end
|
148
|
+
|
158
149
|
def self.clear
|
159
150
|
@@points.clear
|
160
|
-
end
|
151
|
+
end
|
152
|
+
|
161
153
|
end
|
162
154
|
|
163
155
|
|
@@ -165,3 +157,5 @@ end
|
|
165
157
|
|
166
158
|
|
167
159
|
|
160
|
+
|
161
|
+
|
data/lib/quiz/scraper.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
#scraper Class
|
2
2
|
class Quiz::Scraper
|
3
|
+
|
4
|
+
|
3
5
|
def self.scraper(url,clas)
|
4
6
|
doc = Nokogiri::HTML(open(url))
|
5
7
|
doc.css(clas)
|
6
8
|
end
|
7
9
|
|
8
|
-
def self.balon_d_or_players
|
9
|
-
|
10
|
+
def self.balon_d_or_players
|
11
|
+
balon_d_or_url = "https://www.goal.com/es/noticias/todos-los-ganadores-del-balon-de-oro/wn19xivn1eh91t0jrslbzz5kq"
|
12
|
+
balon_de_or_files = ".tableizer-table"
|
13
|
+
players = self.scraper(balon_d_or_url,balon_de_or_files).map{|l|l.text.split(/\t|\*/).reject{|e|e.empty? || e.include?("(FIFA Balón de Oro)")}}
|
10
14
|
2.times{players[0].shift}
|
11
15
|
players[0][16] = "Lionel Messi"
|
12
16
|
counter = 0
|
@@ -19,8 +23,10 @@ class Quiz::Scraper
|
|
19
23
|
end
|
20
24
|
|
21
25
|
|
22
|
-
def self.world_cup
|
23
|
-
|
26
|
+
def self.world_cup
|
27
|
+
world_cup_url = "https://www.foxsports.com/soccer/fifa-world-cup/history"
|
28
|
+
world_cup = "tbody"
|
29
|
+
world_cup = self.scraper(world_cup_url,world_cup).map{|l|l.text.split(/\r\n|\s{2,}/).reject{|e|e.empty?}}
|
24
30
|
counter = 0
|
25
31
|
all_countries = []
|
26
32
|
while counter < world_cup[0].size
|
@@ -30,12 +36,17 @@ class Quiz::Scraper
|
|
30
36
|
all_countries
|
31
37
|
end
|
32
38
|
|
33
|
-
def self.champion_league
|
34
|
-
|
35
|
-
|
39
|
+
def self.champion_league
|
40
|
+
champion_league_url = "https://en.wikipedia.org/wiki/List_of_European_Cup_and_UEFA_Champions_League_finals"
|
41
|
+
champion_league_file = "tbody"
|
42
|
+
|
43
|
+
champions = self.scraper(champion_league_url,champion_league_file).map{|l|l.text.split("\n").reject{|e|e.empty?}}
|
44
|
+
champions[0].shift
|
45
|
+
champions.shift
|
46
|
+
champions.shift
|
36
47
|
10.times{champions[0].shift}
|
37
|
-
|
38
|
-
champions[0].
|
48
|
+
23.times{champions[0].pop}
|
49
|
+
7.times{champions[0].delete_at(145)}
|
39
50
|
counter = 0
|
40
51
|
all_teams = []
|
41
52
|
while counter < champions[0].size
|
@@ -46,4 +57,3 @@ class Quiz::Scraper
|
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
|
-
|
data/lib/quiz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soccer-quiz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yarvin Hernandez
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,8 +81,14 @@ files:
|
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
|
+
- bin/bundle
|
84
85
|
- bin/console
|
86
|
+
- bin/htmldiff
|
87
|
+
- bin/ldiff
|
88
|
+
- bin/nokogiri
|
85
89
|
- bin/quiz
|
90
|
+
- bin/rake
|
91
|
+
- bin/rspec
|
86
92
|
- bin/setup
|
87
93
|
- config/environment.rb
|
88
94
|
- lib/quiz.rb
|
@@ -97,7 +103,7 @@ homepage: https://rubygems.org/gems/soccer_quiz
|
|
97
103
|
licenses:
|
98
104
|
- MIT
|
99
105
|
metadata: {}
|
100
|
-
post_install_message:
|
106
|
+
post_install_message:
|
101
107
|
rdoc_options: []
|
102
108
|
require_paths:
|
103
109
|
- lib
|
@@ -112,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
118
|
- !ruby/object:Gem::Version
|
113
119
|
version: '0'
|
114
120
|
requirements: []
|
115
|
-
rubygems_version: 3.0.
|
116
|
-
signing_key:
|
121
|
+
rubygems_version: 3.0.8
|
122
|
+
signing_key:
|
117
123
|
specification_version: 4
|
118
124
|
summary: 10 questions quiz about soccer.
|
119
125
|
test_files: []
|