hlockey-cli 3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/hlockey +4 -0
- data/lib/hlockey-cli/actions.rb +84 -0
- data/lib/hlockey-cli/user_selection.rb +21 -0
- data/lib/hlockey-cli/version.rb +3 -0
- data/lib/hlockey-cli.rb +27 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2e525ff3f2707721f9bef74532f8ca4a3ea9fb9aa18708a13fc56d56f3ebc615
|
4
|
+
data.tar.gz: ae05fa875ecd8b7ecd57d6a2d9256d69f6400286f5e9df66c52a656eeea68e66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37b4cf715312b89b4a1e226f67ff240195847aa6d12483888d73248c9f148631ca057a7a87de2159a1f30fae4daac5d9977326d00a73c2b7c021b494ce4ea109
|
7
|
+
data.tar.gz: 1588dcb597e6c17881107a38f0ab5cf26b37afe48a23c28fae90c63c30a2ba52bbd99ae9ee97208fd9151698ed805b272a1034b79f0aca1b2fe1cf7be949e792
|
data/bin/hlockey
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require("hlockey-cli/user_selection")
|
2
|
+
|
3
|
+
module HlockeyCLI
|
4
|
+
module Actions
|
5
|
+
ACTIONS = %i[games standings team_info election information].freeze
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def games(league)
|
9
|
+
if league.games.empty?
|
10
|
+
puts(Hlockey::Message.NoGames)
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
chosen_game = HlockeyCLI.user_selection(
|
15
|
+
league.games,
|
16
|
+
str_process: proc { |game| game.to_s + "\n Weather: #{game.weather}" }
|
17
|
+
)
|
18
|
+
return if chosen_game.nil?
|
19
|
+
|
20
|
+
puts("#{chosen_game.home.emoji} #{chosen_game} #{chosen_game.away.emoji}")
|
21
|
+
|
22
|
+
loop do
|
23
|
+
league.update_state
|
24
|
+
chosen_game.stream.each { |message| puts("#{message}\n\n") }
|
25
|
+
|
26
|
+
break unless chosen_game.in_progress
|
27
|
+
|
28
|
+
chosen_game.stream.clear
|
29
|
+
sleep(5)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def standings(league)
|
34
|
+
if league.champion_team
|
35
|
+
puts(Hlockey::Message.SeasonChampion(league.champion_team))
|
36
|
+
elsif league.playoff_teams
|
37
|
+
put_standings("Playoffs", league.playoff_teams)
|
38
|
+
end
|
39
|
+
league.divisions.each { |name, teams| put_standings(name, teams) }
|
40
|
+
end
|
41
|
+
|
42
|
+
def team_info(league)
|
43
|
+
chosen_team = HlockeyCLI.user_selection(league.teams)
|
44
|
+
return if chosen_team.nil?
|
45
|
+
|
46
|
+
puts("#{chosen_team.emoji} #{chosen_team}")
|
47
|
+
chosen_team.roster.each do |pos, player|
|
48
|
+
puts(" #{Hlockey::Team.pos_name(pos)}:\n #{player}")
|
49
|
+
player.stats.each do |stat, value|
|
50
|
+
puts(" #{stat}: #{value.round(1)}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
puts(" wins: #{chosen_team.wins}")
|
54
|
+
puts(" losses: #{chosen_team.losses}")
|
55
|
+
end
|
56
|
+
|
57
|
+
def election(_)
|
58
|
+
Hlockey::Data.election.each do |category, options|
|
59
|
+
puts(category)
|
60
|
+
options.each { |name, description| puts(" #{name}\n #{description}") }
|
61
|
+
end
|
62
|
+
# TODO: add an actual link to the website,
|
63
|
+
# probably should be from Hlockey lib data
|
64
|
+
puts("Go to the website to vote.")
|
65
|
+
end
|
66
|
+
|
67
|
+
def information(_)
|
68
|
+
Hlockey::Data.information.each do |title, info|
|
69
|
+
puts(title)
|
70
|
+
info.each_line { |line| puts(" #{line}") }
|
71
|
+
end
|
72
|
+
puts("Links")
|
73
|
+
Hlockey::Data.links.each { |site, link| puts(" #{site}: #{link}") }
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def put_standings(division_name, teams)
|
79
|
+
puts(division_name)
|
80
|
+
teams.each { |team| puts("#{team.emoji} #{team} ".ljust(27) + team.w_l) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HlockeyCLI
|
2
|
+
def self.user_selection(choices, default: nil, str_process: proc { |s| s })
|
3
|
+
puts("Please enter a number...")
|
4
|
+
|
5
|
+
# 1 is added to i when printing choices
|
6
|
+
# to avoid confusing a non-numerical input with the first choice
|
7
|
+
choices.each_with_index do |choice, i|
|
8
|
+
puts("#{(i + 1).to_s.rjust(2)} - #{str_process.call(choice)}")
|
9
|
+
end
|
10
|
+
puts("anything else - #{default || "Back"}")
|
11
|
+
|
12
|
+
# 1 is subracted to undo adding 1 earlier
|
13
|
+
choice_idx = $stdin.gets.to_i - 1
|
14
|
+
|
15
|
+
if !choice_idx.negative? && choice_idx < choices.length
|
16
|
+
choices[choice_idx]
|
17
|
+
else
|
18
|
+
default
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/hlockey-cli.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require("hlockey")
|
2
|
+
require("hlockey-cli/actions")
|
3
|
+
require("hlockey-cli/user_selection")
|
4
|
+
require("hlockey-cli/version")
|
5
|
+
|
6
|
+
module HlockeyCLI
|
7
|
+
def self.main
|
8
|
+
puts("Please wait...")
|
9
|
+
|
10
|
+
league = Hlockey::League.new
|
11
|
+
|
12
|
+
puts(Hlockey::Message.SeasonStarts(league.start_time)) if Time.now < league.start_time
|
13
|
+
|
14
|
+
loop do
|
15
|
+
league.update_state
|
16
|
+
puts(Hlockey::Message.SeasonDay(league.day))
|
17
|
+
|
18
|
+
selected_action = user_selection(
|
19
|
+
Actions::ACTIONS,
|
20
|
+
default: :Exit,
|
21
|
+
str_process: proc { |s| s.to_s.capitalize.sub("_", " ") }
|
22
|
+
)
|
23
|
+
exit if selected_action == :Exit
|
24
|
+
Actions.send(selected_action, league)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hlockey-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '3'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lavender Perry
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hlockey
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3'
|
27
|
+
description: Hlockey console application.
|
28
|
+
email: endie2@protonmail.com
|
29
|
+
executables:
|
30
|
+
- hlockey
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/hlockey
|
35
|
+
- lib/hlockey-cli.rb
|
36
|
+
- lib/hlockey-cli/actions.rb
|
37
|
+
- lib/hlockey-cli/user_selection.rb
|
38
|
+
- lib/hlockey-cli/version.rb
|
39
|
+
homepage: https://github.com/Hlockey/cli
|
40
|
+
licenses:
|
41
|
+
- LicenseRef-LICENSE.md
|
42
|
+
metadata:
|
43
|
+
source_code_uri: https://github.com/Hlockey/cli
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubygems_version: 3.4.10
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: Enjoy Hlockey from your terminal.
|
63
|
+
test_files: []
|