12
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rakeの使い方

Last updated at Posted at 2020-12-02

!Mac OS X-10.15.7 !ruby-2.7.1p83

rakeとは

rubyで処理内容を定美できるビルドツール.Rakefileにrakeあ実行する処理内容を定義する.
つまり,コマンドを実行するときに役に立つ

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

desc 'hello worldと表示'
task :hello do
   puts "Hello world!"
  exit
end

これをRakefileに書き込み,以下のように実行します.

> rake -T

すると,Rakefileが用意しているタスクが表示されます.

> rake hello                                                                  

でタスクの実行.

書き方としては,

  • desc:タスクの説明文
  • task <タスク名>
  • 標準のruby言語で,動作を記述
  • end

githubへの共有を簡単に

desc 'git pull'
task :pull do
  p comm = "git pull origin main"
  system comm
  exit
end

とRakefileに書き込み,以下のように実行します.

> rake pull                                                                        

すると, git pull が実行できます.

さらに,githubの共有をするためのコマンドも同じように.

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

[point] p commで命令(command)が何かをpしておくこと

参考


  • source ~/Desktop/grad_members_20f/members/mm-cell/post_org/rake.org
12
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?