From d539d7739a2b65e234057e46dce292dd353fc6cc Mon Sep 17 00:00:00 2001 From: sue445 Date: Thu, 9 Jan 2025 23:30:26 +0900 Subject: [PATCH 1/2] Support rake task arguments within task block --- gems/rake/13.0/_test/test.rb | 11 +++++++++++ gems/rake/13.0/rake.rbs | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gems/rake/13.0/_test/test.rb b/gems/rake/13.0/_test/test.rb index 4bcfe9f12..5a7235aec 100644 --- a/gems/rake/13.0/_test/test.rb +++ b/gems/rake/13.0/_test/test.rb @@ -10,5 +10,16 @@ def create_task task :test do ruby "test/unittest.rb" end + + task :test_with_1_arg, :name do |t, args| + value = args[:name] + puts "#{args[:name]}=#{value}" + end + + task :test_with_2_args, %i[name1 name2] do |t, args| + args.each do |name, value| + puts "#{name}=#{value}" + end + end end end diff --git a/gems/rake/13.0/rake.rbs b/gems/rake/13.0/rake.rbs index 70ae0e90d..2c4ecdbf3 100644 --- a/gems/rake/13.0/rake.rbs +++ b/gems/rake/13.0/rake.rbs @@ -3,6 +3,16 @@ module Rake include Rake::DSL end + class Task + end + + class TaskArguments + include Enumerable[untyped] + + def []: (untyped index) -> untyped + def each: () ?{ (untyped, untyped) -> void } -> void + end + module DSL private @@ -16,7 +26,7 @@ module Rake def multitask: (*untyped args) ?{ () -> void } -> void def namespace: (?untyped name) ?{ () -> void } -> void def rule: (*untyped args) ?{ () -> void } -> void - def task: (*untyped args) ?{ () -> void } -> void + def task: (*untyped args) ?{ (Rake::Task, Rake::TaskArguments) -> void } -> void end end From 6af03ea11a7b87e3343fa40ace1827c25caa1842 Mon Sep 17 00:00:00 2001 From: sue445 Date: Thu, 9 Jan 2025 23:50:39 +0900 Subject: [PATCH 2/2] Support env hash to FileUtils#sh in rake --- gems/rake/13.0/_test/test.rb | 7 +++++++ gems/rake/13.0/rake.rbs | 1 + 2 files changed, 8 insertions(+) diff --git a/gems/rake/13.0/_test/test.rb b/gems/rake/13.0/_test/test.rb index 5a7235aec..8556c7a25 100644 --- a/gems/rake/13.0/_test/test.rb +++ b/gems/rake/13.0/_test/test.rb @@ -21,5 +21,12 @@ def create_task puts "#{name}=#{value}" end end + + task :test_with_sh do + sh "ruby test/unittest_without_env.rb" + + env = { "RACK_ENV" => "test" } + sh env, "ruby test/unittest_with_env.rb" + end end end diff --git a/gems/rake/13.0/rake.rbs b/gems/rake/13.0/rake.rbs index 2c4ecdbf3..89e231fbc 100644 --- a/gems/rake/13.0/rake.rbs +++ b/gems/rake/13.0/rake.rbs @@ -32,6 +32,7 @@ end module FileUtils def sh: (*String cmd, **untyped options) ?{ (bool, Process::Status) -> void } -> void + | (Hash[String, String] env, *String cmd, **untyped options) ?{ (bool, Process::Status) -> void } -> void def ruby: (*String args, **untyped options) ?{ (bool, Process::Status) -> void } -> void def safe_ln: (*untyped args, **untyped options) -> void def split_all: (String path) -> Array[String]