This repository has been archived by the owner on Jul 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfragen.rb
executable file
·65 lines (55 loc) · 1.61 KB
/
fragen.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env ruby
require 'bundler/setup'
require 'octokit'
require 'chromatic'
class NerdkundeFrageStunde
def initialize
puts "Lade GitHub issues von nerdkunde/fragestunde"
@handled_issues = []
@issues = Octokit.issues("nerdkunde/fragestunde", limit: 1000)
end
def start_game
# Clear Screen
puts "\e[H\e[2J"
puts "Willkommen zur Nerdkunde Fragestunde".yellow
puts "n - Nächste Frage, q - Beenden, r - Fragen neu laden"
begin
system("stty raw -echo")
while true
str = STDIN.getc
case str
when 'n'
pick_question
when 'r'
@issues = Octokit.issues("nerdkunde/fragestunde")
puts "Issues geladen ... es kann weitergehen\r"
when 'q'
puts "Ende\r"
break
end
end
ensure
system("stty -raw echo")
end
end
def pick_question
if @handled_issues.count < @issues.count
begin
current_issue = if @handled_issues.count == 0
@issues.select { |issue| issue.number == 32 }.first
else
@issues.sample
end
end while @handled_issues.include?(current_issue.number)
labels = current_issue.labels.map { |label| " #{label.name} ".blue.on_white }
@handled_issues << current_issue.number
puts "\n\n\n#{labels.join} #{current_issue.title.yellow}\r"
puts "Von: #{current_issue.user.login}\r"
puts "#{current_issue.body}\r"
puts
else
puts "#{"Keine weiteren Fragen".red}\r"
end
end
end
NerdkundeFrageStunde.new.start_game