From b83b77daeb7011e0a71cd11024b8cb65371ab75d Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Tue, 9 Dec 2025 16:10:30 +0900 Subject: [PATCH 1/2] CC-2062: Update Ruby to 3.4 --- compiled_starters/ruby/.codecrafters/run.sh | 2 +- compiled_starters/ruby/README.md | 6 +++--- compiled_starters/ruby/app/main.rb | 5 +++++ compiled_starters/ruby/codecrafters.yml | 4 ++-- compiled_starters/ruby/your_program.sh | 2 +- dockerfiles/ruby-3.4.Dockerfile | 19 +++++++++++++++++++ .../ruby/01-at4/code/.codecrafters/run.sh | 2 +- solutions/ruby/01-at4/code/README.md | 6 +++--- solutions/ruby/01-at4/code/app/main.rb | 2 ++ solutions/ruby/01-at4/code/codecrafters.yml | 4 ++-- solutions/ruby/01-at4/code/your_program.sh | 2 +- solutions/ruby/01-at4/diff/app/main.rb.diff | 7 +++++++ .../ruby/code/.codecrafters/run.sh | 2 +- starter_templates/ruby/code/app/main.rb | 5 +++++ starter_templates/ruby/config.yml | 4 ++-- 15 files changed, 55 insertions(+), 17 deletions(-) create mode 100644 compiled_starters/ruby/app/main.rb create mode 100644 dockerfiles/ruby-3.4.Dockerfile create mode 100644 solutions/ruby/01-at4/code/app/main.rb create mode 100644 solutions/ruby/01-at4/diff/app/main.rb.diff create mode 100644 starter_templates/ruby/code/app/main.rb diff --git a/compiled_starters/ruby/.codecrafters/run.sh b/compiled_starters/ruby/.codecrafters/run.sh index d6d88c5..619aa01 100755 --- a/compiled_starters/ruby/.codecrafters/run.sh +++ b/compiled_starters/ruby/.codecrafters/run.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -exec bundle exec ruby app/server.rb "$@" +exec bundle exec ruby app/main.rb "$@" diff --git a/compiled_starters/ruby/README.md b/compiled_starters/ruby/README.md index c6ce1a8..b4f4bba 100644 --- a/compiled_starters/ruby/README.md +++ b/compiled_starters/ruby/README.md @@ -16,7 +16,7 @@ and more. # Passing the first stage -The entry point for your HTTP server implementation is in `app/server.rb`. Study +The entry point for your HTTP server implementation is in `app/main.rb`. Study and uncomment the relevant code, and push your changes to pass the first stage: ```sh @@ -30,8 +30,8 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `ruby (3.3)` installed locally +1. Ensure you have `ruby (3.4)` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in - `app/server.rb`. + `app/main.rb`. 1. Commit your changes and run `git push origin master` to submit your solution to CodeCrafters. Test output will be streamed to your terminal. diff --git a/compiled_starters/ruby/app/main.rb b/compiled_starters/ruby/app/main.rb new file mode 100644 index 0000000..d5bc268 --- /dev/null +++ b/compiled_starters/ruby/app/main.rb @@ -0,0 +1,5 @@ +# You can use print statements as follows for debugging, they'll be visible when running tests. +$stderr.puts "Logs from your program will appear here!" + +# Uncomment this block to pass the first stage +# puts "Implement code here!" \ No newline at end of file diff --git a/compiled_starters/ruby/codecrafters.yml b/compiled_starters/ruby/codecrafters.yml index 09d9152..d4cad15 100644 --- a/compiled_starters/ruby/codecrafters.yml +++ b/compiled_starters/ruby/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Ruby version used to run your code # on Codecrafters. # -# Available versions: ruby-3.3 -buildpack: ruby-3.3 +# Available versions: ruby-3.4 +buildpack: ruby-3.4 diff --git a/compiled_starters/ruby/your_program.sh b/compiled_starters/ruby/your_program.sh index 604d815..fcb2853 100755 --- a/compiled_starters/ruby/your_program.sh +++ b/compiled_starters/ruby/your_program.sh @@ -12,4 +12,4 @@ set -e # Exit early if any commands fail # # - Edit this to change how your program runs locally # - Edit .codecrafters/run.sh to change how your program runs remotely -exec bundle exec ruby app/server.rb "$@" +exec bundle exec ruby app/main.rb "$@" diff --git a/dockerfiles/ruby-3.4.Dockerfile b/dockerfiles/ruby-3.4.Dockerfile new file mode 100644 index 0000000..9140b73 --- /dev/null +++ b/dockerfiles/ruby-3.4.Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1.7-labs +FROM ruby:3.4-alpine3.23 + +# Required for installing the json/async gems +RUN apk add --no-cache \ + build-base~=0.5 \ + libssl3~=3.5 \ + readline-dev~=8.3 \ + zlib-dev~=1.3 + +# Re-build if Gemfile or Gemfile.lock changes +ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Gemfile,Gemfile.lock" + +WORKDIR /app + +# .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses +COPY --exclude=.git --exclude=README.md . /app + +RUN bundle install --verbose diff --git a/solutions/ruby/01-at4/code/.codecrafters/run.sh b/solutions/ruby/01-at4/code/.codecrafters/run.sh index d6d88c5..619aa01 100755 --- a/solutions/ruby/01-at4/code/.codecrafters/run.sh +++ b/solutions/ruby/01-at4/code/.codecrafters/run.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -exec bundle exec ruby app/server.rb "$@" +exec bundle exec ruby app/main.rb "$@" diff --git a/solutions/ruby/01-at4/code/README.md b/solutions/ruby/01-at4/code/README.md index c6ce1a8..b4f4bba 100644 --- a/solutions/ruby/01-at4/code/README.md +++ b/solutions/ruby/01-at4/code/README.md @@ -16,7 +16,7 @@ and more. # Passing the first stage -The entry point for your HTTP server implementation is in `app/server.rb`. Study +The entry point for your HTTP server implementation is in `app/main.rb`. Study and uncomment the relevant code, and push your changes to pass the first stage: ```sh @@ -30,8 +30,8 @@ Time to move on to the next stage! Note: This section is for stages 2 and beyond. -1. Ensure you have `ruby (3.3)` installed locally +1. Ensure you have `ruby (3.4)` installed locally 1. Run `./your_program.sh` to run your program, which is implemented in - `app/server.rb`. + `app/main.rb`. 1. Commit your changes and run `git push origin master` to submit your solution to CodeCrafters. Test output will be streamed to your terminal. diff --git a/solutions/ruby/01-at4/code/app/main.rb b/solutions/ruby/01-at4/code/app/main.rb new file mode 100644 index 0000000..3935d21 --- /dev/null +++ b/solutions/ruby/01-at4/code/app/main.rb @@ -0,0 +1,2 @@ +# Uncomment this block to pass the first stage +# puts "Implement code here!" \ No newline at end of file diff --git a/solutions/ruby/01-at4/code/codecrafters.yml b/solutions/ruby/01-at4/code/codecrafters.yml index 09d9152..d4cad15 100644 --- a/solutions/ruby/01-at4/code/codecrafters.yml +++ b/solutions/ruby/01-at4/code/codecrafters.yml @@ -7,5 +7,5 @@ debug: false # Use this to change the Ruby version used to run your code # on Codecrafters. # -# Available versions: ruby-3.3 -buildpack: ruby-3.3 +# Available versions: ruby-3.4 +buildpack: ruby-3.4 diff --git a/solutions/ruby/01-at4/code/your_program.sh b/solutions/ruby/01-at4/code/your_program.sh index 604d815..fcb2853 100755 --- a/solutions/ruby/01-at4/code/your_program.sh +++ b/solutions/ruby/01-at4/code/your_program.sh @@ -12,4 +12,4 @@ set -e # Exit early if any commands fail # # - Edit this to change how your program runs locally # - Edit .codecrafters/run.sh to change how your program runs remotely -exec bundle exec ruby app/server.rb "$@" +exec bundle exec ruby app/main.rb "$@" diff --git a/solutions/ruby/01-at4/diff/app/main.rb.diff b/solutions/ruby/01-at4/diff/app/main.rb.diff new file mode 100644 index 0000000..262c7ec --- /dev/null +++ b/solutions/ruby/01-at4/diff/app/main.rb.diff @@ -0,0 +1,7 @@ +@@ -1,5 +1,2 @@ +-# You can use print statements as follows for debugging, they'll be visible when running tests. +-$stderr.puts "Logs from your program will appear here!" +- + # Uncomment this block to pass the first stage + # puts "Implement code here!" +\ No newline at end of file diff --git a/starter_templates/ruby/code/.codecrafters/run.sh b/starter_templates/ruby/code/.codecrafters/run.sh index d6d88c5..619aa01 100755 --- a/starter_templates/ruby/code/.codecrafters/run.sh +++ b/starter_templates/ruby/code/.codecrafters/run.sh @@ -8,4 +8,4 @@ set -e # Exit on failure -exec bundle exec ruby app/server.rb "$@" +exec bundle exec ruby app/main.rb "$@" diff --git a/starter_templates/ruby/code/app/main.rb b/starter_templates/ruby/code/app/main.rb new file mode 100644 index 0000000..d5bc268 --- /dev/null +++ b/starter_templates/ruby/code/app/main.rb @@ -0,0 +1,5 @@ +# You can use print statements as follows for debugging, they'll be visible when running tests. +$stderr.puts "Logs from your program will appear here!" + +# Uncomment this block to pass the first stage +# puts "Implement code here!" \ No newline at end of file diff --git a/starter_templates/ruby/config.yml b/starter_templates/ruby/config.yml index 2e68e84..bbda1a7 100644 --- a/starter_templates/ruby/config.yml +++ b/starter_templates/ruby/config.yml @@ -1,3 +1,3 @@ attributes: - required_executable: ruby (3.3) - user_editable_file: app/server.rb + required_executable: ruby (3.4) + user_editable_file: app/main.rb From f08a31aeec1f80ebeee2c6461f05ddbae3b031e1 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Wed, 10 Dec 2025 01:11:53 +0900 Subject: [PATCH 2/2] Refactor Ruby starter templates: replace server.rb with inline server code in main.rb and update logging method. Added TODO for server implementation. --- compiled_starters/ruby/app/main.rb | 10 +++++++--- compiled_starters/ruby/app/server.rb | 9 --------- solutions/ruby/01-at4/code/app/main.rb | 6 ++++-- solutions/ruby/01-at4/code/app/server.rb | 4 ---- solutions/ruby/01-at4/diff/app/main.rb.diff | 15 ++++++++++----- solutions/ruby/01-at4/diff/app/server.rb.diff | 12 ------------ starter_templates/ruby/code/app/main.rb | 10 +++++++--- starter_templates/ruby/code/app/server.rb | 9 --------- 8 files changed, 28 insertions(+), 47 deletions(-) delete mode 100644 compiled_starters/ruby/app/server.rb delete mode 100644 solutions/ruby/01-at4/code/app/server.rb delete mode 100644 solutions/ruby/01-at4/diff/app/server.rb.diff delete mode 100644 starter_templates/ruby/code/app/server.rb diff --git a/compiled_starters/ruby/app/main.rb b/compiled_starters/ruby/app/main.rb index d5bc268..e24d4b4 100644 --- a/compiled_starters/ruby/app/main.rb +++ b/compiled_starters/ruby/app/main.rb @@ -1,5 +1,9 @@ +require "socket" + # You can use print statements as follows for debugging, they'll be visible when running tests. -$stderr.puts "Logs from your program will appear here!" +print("Logs from your program will appear here!") -# Uncomment this block to pass the first stage -# puts "Implement code here!" \ No newline at end of file +# TODO: Uncomment the code below to pass the first stage +# +# server = TCPServer.new("localhost", 4221) +# client_socket, client_address = server.accept diff --git a/compiled_starters/ruby/app/server.rb b/compiled_starters/ruby/app/server.rb deleted file mode 100644 index e24d4b4..0000000 --- a/compiled_starters/ruby/app/server.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "socket" - -# You can use print statements as follows for debugging, they'll be visible when running tests. -print("Logs from your program will appear here!") - -# TODO: Uncomment the code below to pass the first stage -# -# server = TCPServer.new("localhost", 4221) -# client_socket, client_address = server.accept diff --git a/solutions/ruby/01-at4/code/app/main.rb b/solutions/ruby/01-at4/code/app/main.rb index 3935d21..98756b3 100644 --- a/solutions/ruby/01-at4/code/app/main.rb +++ b/solutions/ruby/01-at4/code/app/main.rb @@ -1,2 +1,4 @@ -# Uncomment this block to pass the first stage -# puts "Implement code here!" \ No newline at end of file +require "socket" + +server = TCPServer.new("localhost", 4221) +client_socket, client_address = server.accept diff --git a/solutions/ruby/01-at4/code/app/server.rb b/solutions/ruby/01-at4/code/app/server.rb deleted file mode 100644 index 98756b3..0000000 --- a/solutions/ruby/01-at4/code/app/server.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "socket" - -server = TCPServer.new("localhost", 4221) -client_socket, client_address = server.accept diff --git a/solutions/ruby/01-at4/diff/app/main.rb.diff b/solutions/ruby/01-at4/diff/app/main.rb.diff index 262c7ec..faae56e 100644 --- a/solutions/ruby/01-at4/diff/app/main.rb.diff +++ b/solutions/ruby/01-at4/diff/app/main.rb.diff @@ -1,7 +1,12 @@ -@@ -1,5 +1,2 @@ +@@ -1,9 +1,4 @@ + require "socket" + -# You can use print statements as follows for debugging, they'll be visible when running tests. --$stderr.puts "Logs from your program will appear here!" +-print("Logs from your program will appear here!") - - # Uncomment this block to pass the first stage - # puts "Implement code here!" -\ No newline at end of file +-# TODO: Uncomment the code below to pass the first stage +-# +-# server = TCPServer.new("localhost", 4221) +-# client_socket, client_address = server.accept ++server = TCPServer.new("localhost", 4221) ++client_socket, client_address = server.accept diff --git a/solutions/ruby/01-at4/diff/app/server.rb.diff b/solutions/ruby/01-at4/diff/app/server.rb.diff deleted file mode 100644 index faae56e..0000000 --- a/solutions/ruby/01-at4/diff/app/server.rb.diff +++ /dev/null @@ -1,12 +0,0 @@ -@@ -1,9 +1,4 @@ - require "socket" - --# You can use print statements as follows for debugging, they'll be visible when running tests. --print("Logs from your program will appear here!") -- --# TODO: Uncomment the code below to pass the first stage --# --# server = TCPServer.new("localhost", 4221) --# client_socket, client_address = server.accept -+server = TCPServer.new("localhost", 4221) -+client_socket, client_address = server.accept diff --git a/starter_templates/ruby/code/app/main.rb b/starter_templates/ruby/code/app/main.rb index d5bc268..e24d4b4 100644 --- a/starter_templates/ruby/code/app/main.rb +++ b/starter_templates/ruby/code/app/main.rb @@ -1,5 +1,9 @@ +require "socket" + # You can use print statements as follows for debugging, they'll be visible when running tests. -$stderr.puts "Logs from your program will appear here!" +print("Logs from your program will appear here!") -# Uncomment this block to pass the first stage -# puts "Implement code here!" \ No newline at end of file +# TODO: Uncomment the code below to pass the first stage +# +# server = TCPServer.new("localhost", 4221) +# client_socket, client_address = server.accept diff --git a/starter_templates/ruby/code/app/server.rb b/starter_templates/ruby/code/app/server.rb deleted file mode 100644 index e24d4b4..0000000 --- a/starter_templates/ruby/code/app/server.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "socket" - -# You can use print statements as follows for debugging, they'll be visible when running tests. -print("Logs from your program will appear here!") - -# TODO: Uncomment the code below to pass the first stage -# -# server = TCPServer.new("localhost", 4221) -# client_socket, client_address = server.accept