Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue One command and Run Multiple Ruby Files

Tags:

scripting

ruby

I have to run a whole bunch of ruby scripts to generate some results. In which order does not matter. I just don't want to do Ruby file1.rb, Ruby file2.rb, Ruby file3.rb...one by one.

Could I write a script that group all files together and issue command only once to run them all?

like image 812
Terry Li Avatar asked Jan 26 '26 06:01

Terry Li


1 Answers

I would do it ruby-style and use rake gem.

I would create file named "rakefile.rb" and this would be its content:

task :default do
    FileList['file*.rb'].each { |file| ruby file }
end

Then I would call rake in my favourite shell and I would enjoy it.

Bonus: It's multiplatform.

like image 55
maro Avatar answered Jan 28 '26 00:01

maro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!