[RUBY] Rake

!Mac OS X-10.15.7!ruby-2.7.1p83

Rake

rake is a ruby ​​version of make and ant The contents of the rake command create a task in the Rakefile In Rakefile

task :default do
  system 'rake -T'
  exit
end

desc 'hello NAME'
task :hello do
  name = ARGV[1]
  puts "Hello #{name}!"
  exit
end

Execution result

$ rake hello Cyoukou
hello Cyoukou

This means that you have executed the task "hello" in the Rakefile.

System Call

Now you can operate git with system call in one shot

desc 'git push'
task :push do
  p comm = "git pull origin main"
  system comm
  p comm = "git add -A"
  system comm
  p comm = "git commit -m \'commit\'"
  system comm
  p comm = "git push origin main"
  system comm
  exit
end

Convenient to do from pull to push like this! !!


Recommended Posts

Rake
8th class: rake
[Week 8] rake, ruby_fourth
Chart type ruby-appendix-IV (rake)
[Rails] Implement rake task