git_game_show 0.1.2 → 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/bin/git-game-show +18 -0
- data/lib/git_game_show/cli.rb +100 -40
- data/lib/git_game_show/game_server.rb +1 -1
- data/lib/git_game_show/player_client.rb +201 -189
- data/lib/git_game_show/updater.rb +107 -0
- data/lib/git_game_show/version.rb +2 -2
- data/lib/git_game_show.rb +5 -4
- metadata +3 -2
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'colorize'
|
6
|
+
require 'tty-prompt'
|
7
|
+
|
8
|
+
module GitGameShow
|
9
|
+
class Updater
|
10
|
+
class << self
|
11
|
+
def check_for_updates
|
12
|
+
current_version = GitGameShow::VERSION
|
13
|
+
latest_version = fetch_latest_version
|
14
|
+
|
15
|
+
return if latest_version.nil?
|
16
|
+
|
17
|
+
# Compare versions
|
18
|
+
if newer_version_available?(current_version, latest_version)
|
19
|
+
display_update_prompt(current_version, latest_version)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def fetch_latest_version
|
26
|
+
begin
|
27
|
+
uri = URI.parse("https://rubygems.org/api/v1/gems/git_game_show.json")
|
28
|
+
response = Net::HTTP.get_response(uri)
|
29
|
+
|
30
|
+
if response.code == "200"
|
31
|
+
data = JSON.parse(response.body)
|
32
|
+
return data["version"]
|
33
|
+
else
|
34
|
+
# Silently fail on network errors
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
rescue => e
|
38
|
+
# Silently fail on connection errors
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def newer_version_available?(current, latest)
|
44
|
+
# Convert version strings to comparable arrays
|
45
|
+
current_parts = current.split('.').map(&:to_i)
|
46
|
+
latest_parts = latest.split('.').map(&:to_i)
|
47
|
+
|
48
|
+
# Compare each part numerically
|
49
|
+
latest_parts.zip(current_parts).each do |latest_part, current_part|
|
50
|
+
return true if latest_part > current_part
|
51
|
+
return false if latest_part < current_part
|
52
|
+
end
|
53
|
+
|
54
|
+
# If we get here and versions are different lengths, the longer one is newer
|
55
|
+
return latest_parts.length > current_parts.length
|
56
|
+
end
|
57
|
+
|
58
|
+
def display_update_prompt(current_version, latest_version)
|
59
|
+
prompt = TTY::Prompt.new
|
60
|
+
|
61
|
+
# Clear the terminal for better visibility
|
62
|
+
puts "\n\n"
|
63
|
+
|
64
|
+
puts "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓".colorize(:cyan)
|
65
|
+
puts "┃ UPDATE AVAILABLE FOR GIT GAME SHOW ┃".colorize(:cyan)
|
66
|
+
puts "┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫".colorize(:cyan)
|
67
|
+
puts "┃ ┃".colorize(:cyan)
|
68
|
+
puts "┃ Current version: #{current_version.ljust(44)}┃".colorize(:cyan)
|
69
|
+
puts "┃ Latest version: #{latest_version.ljust(44)}┃".colorize(:cyan)
|
70
|
+
puts "┃ ┃".colorize(:cyan)
|
71
|
+
puts "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛".colorize(:cyan)
|
72
|
+
puts "\n"
|
73
|
+
|
74
|
+
update_now = prompt.yes?("Would you like to update now?")
|
75
|
+
|
76
|
+
if update_now
|
77
|
+
perform_update
|
78
|
+
else
|
79
|
+
puts "You can update later by running: gem update git_game_show".colorize(:yellow)
|
80
|
+
puts "\nContinuing with current version...\n\n"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def perform_update
|
85
|
+
puts "\nUpdating Git Game Show to the latest version...".colorize(:cyan)
|
86
|
+
|
87
|
+
begin
|
88
|
+
# Use system to capture both stdout and stderr
|
89
|
+
update_command = "gem update git_game_show"
|
90
|
+
result = system(update_command)
|
91
|
+
|
92
|
+
if result
|
93
|
+
puts "\n✅ Update completed successfully!".colorize(:green)
|
94
|
+
puts "Please restart Git Game Show to use the new version.".colorize(:yellow)
|
95
|
+
exit(0)
|
96
|
+
else
|
97
|
+
puts "\n❌ Update failed with exit code: #{$?.exitstatus}".colorize(:red)
|
98
|
+
puts "You can manually update by running: gem update git_game_show".colorize(:yellow)
|
99
|
+
end
|
100
|
+
rescue => e
|
101
|
+
puts "\n❌ Update failed: #{e.message}".colorize(:red)
|
102
|
+
puts "You can manually update by running: gem update git_game_show".colorize(:yellow)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/git_game_show.rb
CHANGED
@@ -12,20 +12,21 @@ require 'uri'
|
|
12
12
|
require 'clipboard'
|
13
13
|
require 'readline'
|
14
14
|
require 'timeout'
|
15
|
+
require 'net/http'
|
15
16
|
|
16
17
|
# Define module and constants first before loading any other files
|
17
18
|
module GitGameShow
|
18
19
|
# VERSION is defined in version.rb
|
19
|
-
|
20
|
+
|
20
21
|
# Default configuration
|
21
22
|
DEFAULT_CONFIG = {
|
22
|
-
|
23
|
+
internal_port: 80,
|
23
24
|
rounds: 3,
|
24
25
|
question_timeout: 30, # seconds
|
25
26
|
question_display_time: 5, # seconds to show results before next question
|
26
27
|
transition_delay: 5 # seconds between rounds
|
27
28
|
}.freeze
|
28
|
-
|
29
|
+
|
29
30
|
# Message types for WebSocket communication
|
30
31
|
module MessageType
|
31
32
|
JOIN_REQUEST = 'join_request'
|
@@ -46,4 +47,4 @@ end
|
|
46
47
|
Dir[File.join(__dir__, 'git_game_show', '*.rb')].sort.each { |file| require file }
|
47
48
|
|
48
49
|
# Load all mini-games
|
49
|
-
Dir[File.join(__dir__, '..', 'mini_games', '*.rb')].sort.each { |file| require file }
|
50
|
+
Dir[File.join(__dir__, '..', 'mini_games', '*.rb')].sort.each { |file| require file }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_game_show
|
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
|
- Justin Paulson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- lib/git_game_show/game_server.rb
|
211
211
|
- lib/git_game_show/mini_game.rb
|
212
212
|
- lib/git_game_show/player_client.rb
|
213
|
+
- lib/git_game_show/updater.rb
|
213
214
|
- lib/git_game_show/version.rb
|
214
215
|
- mini_games/author_quiz.rb
|
215
216
|
- mini_games/commit_message_completion.rb
|