Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rakeについてまとめる #8

Open
itume opened this issue Oct 19, 2019 · 2 comments
Open

rakeについてまとめる #8

itume opened this issue Oct 19, 2019 · 2 comments
Labels
Projects

Comments

@itume
Copy link
Collaborator

itume commented Oct 19, 2019

No description provided.

@itume itume added the 0.5 label Oct 19, 2019
@itume itume added this to やること in 復習 via automation Oct 19, 2019
@itume itume moved this from やること to 今週やること in 復習 Oct 19, 2019
@tararico tararico moved this from 今週やること to 作業中 in 復習 Nov 14, 2019
@tararico
Copy link
Owner

  • Rubyのrakeとは、Ruby-Makeの略でRuby製のビルドプログラムのこと。(C言語のmakeというビルドプログラムの影響を受けている)
  • ビルドプログラムとは、ソースコードを二進数に変換するプログラムのこと。
  • gemを作るためにrakeコマンドを使ったりもする。
  • rakeはRubyで記述できる仕様になっており、記述したものはRakefileというファイルに保存される。このファイル内の一連の処理をタスクと呼ぶ。
  • rake 実行タスク名で実行することができる
  • rake –Trake -Dでタスク一覧を表示することができる。

rakeの便利なところ

  1. ファイルを扱う処理を書くのが、Rubyだけでやるよりも手軽
  2. いろいろなファイルが絡んだ複雑な処理を、「タスク」と「依存関係」の組み合わせで簡単に書ける
  3. Rubyのほとんどのツールやライブラリが、Rake用のスクリプトを同梱してる(ほぼ事実上の標準ツール)

「Aを作るためにBが必要」「Bを作るためにCが必要」っていうような
ファイル同士の関連性(依存関係)を、次々と書いていくだけで
いろいろな種類のファイルを扱うややこしい処理も、それほど苦労せずに書くことができる!

基本的な書き方

desc 'Create hello-rake.txt'
task :testfile do
  open('hello-rake.txt', 'w'){|f|
    f.write('Hello Rake world.')
  }
end

decs部分でタスクの説明を書いて、taskに処理をかく

@tararico tararico moved this from 作業中 to 完了 in 復習 Nov 14, 2019
@itume
Copy link
Collaborator Author

itume commented Nov 23, 2019

ファイルを扱う処理を書くのが、Rubyだけでやるよりも手軽

これはなぜなのだろ?サンプルコード見てる限りふつーのRubyとあまり変わらないような気がするけど。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
復習
  
完了
Development

No branches or pull requests

2 participants