If you just need to perform a simple script like creating a file, you can simply use a Ruby script without creating a rake task.
# file origin.rb
target = "target.rb"
content = <<-RUBY
puts "I'm the target!"
RUBY
File.open(target, "w+") do |f|
f.write(content)
end
And you can execute the file with
$ ruby origin.rb
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…