soccer-quiz 0.1.4 → 0.1.5
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/quiz +28 -2
- data/lib/quiz/cli.rb +10 -3
- data/lib/quiz/scraper.rb +11 -8
- data/lib/quiz/version.rb +1 -1
- metadata +2 -3
- data/soccer-quiz-0.1.3.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d1b7f0a4503c846912b2cee8e99ab83e7c5f63598515f51fda558e7c26bb56
|
4
|
+
data.tar.gz: a2948b710b67d54274803adcaab90db96f1b0efc96511c282dabd8221c1772ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e4c00a7bd40185b53d25d08f7b1d6e16cd3b10dbcd2930295b3483a8e0d830ffed001cb2515da648c654e7d01e37e0899e49ce21023d8a2f361ff731bf8f7f2
|
7
|
+
data.tar.gz: 1722039f50710738648b6c7f81d7e979266b40849ad3a2f59ae6369ebae678aeb4cc805583a0ad447b60ebf483c9c34af8104ce5dbbc24654ae30f19717a71f5
|
data/Gemfile.lock
CHANGED
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/lib/quiz/cli.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
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
8
|
start_quiz
|
@@ -58,11 +60,16 @@ class Quiz::CLI
|
|
58
60
|
runner_ups = objects.map{|item|item.runner_up}
|
59
61
|
random_year = years.sample
|
60
62
|
random_winner = winners.sample
|
61
|
-
|
63
|
+
|
64
|
+
instace_for_answers = objects.select{|item|item.year == random_year}
|
65
|
+
|
62
66
|
answer_for_how_many = objects.select{|item|item.winner == random_winner}.size
|
63
|
-
|
67
|
+
|
68
|
+
winner = instace_for_answers[0].winner
|
69
|
+
|
64
70
|
host = instace_for_answers[0].host
|
65
71
|
runner_up = instace_for_answers[0].runner_up
|
72
|
+
|
66
73
|
if all_question("none",random_year)[question].include?("host")
|
67
74
|
puts all_question(host,random_year)[question]
|
68
75
|
multiple_choice(host,hosts)
|
@@ -77,7 +84,7 @@ class Quiz::CLI
|
|
77
84
|
while obtions.size < 13
|
78
85
|
obtions << counter
|
79
86
|
counter += 1
|
80
|
-
end
|
87
|
+
end
|
81
88
|
multiple_choice(answer_for_how_many,obtions)
|
82
89
|
else
|
83
90
|
puts all_question(winner,random_year)[question]
|
data/lib/quiz/scraper.rb
CHANGED
@@ -18,8 +18,8 @@ class Quiz::Scraper
|
|
18
18
|
while counter < players[0].size
|
19
19
|
all_players << {:winner => players[0][counter],:year => players[0][counter + 1]}
|
20
20
|
counter += 2
|
21
|
-
end
|
22
|
-
|
21
|
+
end
|
22
|
+
all_players
|
23
23
|
end
|
24
24
|
|
25
25
|
|
@@ -32,25 +32,28 @@ class Quiz::Scraper
|
|
32
32
|
while counter < world_cup[0].size
|
33
33
|
all_countries << {:year => world_cup[0][counter], :host => world_cup[0][counter + 1], :winner => world_cup[0][counter + 2], :runner_up => world_cup[0][counter + 3], :thirth_place => world_cup[0][counter + 4]}
|
34
34
|
counter += 9
|
35
|
-
end
|
35
|
+
end
|
36
36
|
all_countries
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.champion_league
|
40
40
|
champion_league_url = "https://en.wikipedia.org/wiki/List_of_European_Cup_and_UEFA_Champions_League_finals"
|
41
41
|
champion_league_file = "tbody"
|
42
|
-
|
43
|
-
|
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
|
44
47
|
10.times{champions[0].shift}
|
45
|
-
23.times{champions[0].pop}
|
46
|
-
champions[0].
|
48
|
+
23.times{champions[0].pop}
|
49
|
+
7.times{champions[0].delete_at(145)}
|
47
50
|
counter = 0
|
48
51
|
all_teams = []
|
49
52
|
while counter < champions[0].size
|
50
53
|
all_teams << {:year => champions[0][counter], :winner => champions[0][counter + 2], :score => champions[0][counter + 3], :runner_up => champions[0][counter + 5], :host => champions[0][counter + 6]}
|
51
54
|
counter += 8
|
52
55
|
end
|
53
|
-
|
56
|
+
all_teams
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yarvin Hernandez
|
8
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
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- lib/quiz/version.rb
|
94
94
|
- lib/quiz/world_cup.rb
|
95
95
|
- quiz.gemspec
|
96
|
-
- soccer-quiz-0.1.3.gem
|
97
96
|
homepage: https://rubygems.org/gems/soccer_quiz
|
98
97
|
licenses:
|
99
98
|
- MIT
|
data/soccer-quiz-0.1.3.gem
DELETED
Binary file
|