Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Rake
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Eric Hodel
May 25, 2016
Programming
380
0
Share
Introduction to Rake
How to write basic rake applications
Eric Hodel
May 25, 2016
More Decks by Eric Hodel
See All by Eric Hodel
Building maintainable command-line tools with MRuby
drbrain
0
680
Lazy Enumeration
drbrain
0
140
Lessons in Mentorship
drbrain
1
250
Open Source Maintenance — Ruby on Ales 2014
drbrain
1
140
Open Source Maintenance — RailsClub Moscow
drbrain
1
170
drbdump
drbrain
2
540
Other Decks in Programming
See All in Programming
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
110
Back to the roots of date
jinroq
0
620
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
160
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
19
9.3k
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
340
書き換えて学ぶTemporal #fukts
pirosikick
2
320
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
130
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.4k
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
440
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
210
AIと共に生きる技術選定 2026
sgash708
0
120
GoogleCloudとterraform完全に理解した
terisuke
1
180
Featured
See All Featured
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
30 Presentation Tips
portentint
PRO
1
280
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Between Models and Reality
mayunak
3
280
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
330
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
The SEO identity crisis: Don't let AI make you average
varn
0
460
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
210
The Art of Programming - Codeland 2020
erikaheidi
57
14k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
110
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Transcript
Introduc)on to Rake Eric Hodel – @drbrain
What is Rake? • Build automa)on tool • Dependency-oriented
Jim Weirich
Other “rake”s • make family • Java: ant, maven •
Clojure: leiningen • Scala: sbt • Python: A-P-P
Rake Basics
Rake Task task "test" do # test actions # …
end
Dependencies task "test" => ["compile"] do # test actions #
… end
Dependencies task test: "compile" do # test actions # …
end
Special Tasks MRUBY_DOWNLOAD = "tmp/mruby-1.2.0.tgz" directory "tmp" file MRUBY_DOWNLOAD =>
"tmp" do sh "curl", "-o", MRUBY_DOWNLOAD, … end
Namespacing namespace "test" do task "unit" # test:unit task "functional"
# test:functional end namespace "db" do task "create" # db:create end
Namespacing namespace "test" do task "unit" task "functional" end task
"test" => [ "test:unit", "test:functional" ]
Documenta)on desc "Run the tests" task "test" do # …
end
Default Task task "default" do puts "this task runs by
default" end
Default Task $ rake this task runs by default $
Programming with Rake
task "default" => "test" task "test" => [MRUBY_EXE, "tmp"] file
MRUBY_EXE => MRUBY_DOWNLOAD directory "tmp" file MRUBY_DOWNLOAD => "tmp"
Unordered is OK task "default" => "test" task "test" =>
MRUBY_EXE task "test" => MRUBY_EXE task "default" => "test" SAME
Dependencies default test MRUBY_EXE MRUBY_ DOWNLOAD tmp
Running rake $ rake # runs default task $ rake
test # runs test task $ rake test default # runs both $ rake -t # traces execution $ rake -t test # traces test task $ rake -T # show descriptions
Invoke & Execute Invoke checks dependencies Execute runs ac)ons (ac)ons
run only once)
$ rake -t ** Invoke default (first_time) ** Invoke test
(first_time) ** Invoke tmp/mruby-1.2.0/bin/mruby (first_time) ** Invoke tmp/mruby-1.2.0.tgz (first_time) ** Invoke tmp (first_time) ** Execute tmp mkdir -p tmp ** Execute tmp/mruby-1.2.0.tgz ** Execute tmp/mruby-1.2.0/bin/mruby mkdir -p tmp/mruby-1.2.0/bin/mruby ** Invoke tmp (not_needed) ** Execute test ** Execute default default test MRUBY_EXE MRUBY_ DOWNLOAD tmp
Rake Library
Shell commands cd MRUBY_DIR do end sh "curl", "-o", MRUBY_DOWNLOAD,
… ruby "my_script.rb" mv "a.txt", "b.txt" rm_rf "tmp"
Execu)on directory task "current_directory" do puts "rake's current directory is
#{Dir.pwd}" end
Execu)on directory $ rake current_directory rake's current directory is ~/tmp/rake-example
$ cd lib $ rake current_directory (in ~/tmp/rake-example) rake's current directory is ~/tmp/rake-example
FileList markdown_files = FileList["*.md"] # => ["ch1.md, "ch2.md", …] html_files
= markdown_files.ext "html" # => ["ch1.html, "ch2.html", …]
import (require) import "tasks/build.rake" import "tasks/test.rake"
Best Prac)ces
One Thing per Task file MRUBY_EXE => MRUBY_DOWNLOAD do #
1. unpack MRUBY_DOWNLOAD # 2. build mruby end
One Thing per Task MRUBY_DIR = "tmp/mruby-1.2.0" directory MRUBY_DIR =>
MRUBY_DOWNLOAD do # unpack MRUBY_DOWNLOAD end file MRUBY_EXE => MRUBY_DIR do # build mruby end
Make Aliases MRUBY_EXE = "tmp/mruby-1.2.0/bin/mruby" task "test" => MRUBY_EXE file
MRUBY_EXE => MRUBY_DIR
Make Aliases MRUBY_EXE = "tmp/mruby-1.2.0/bin/mruby" task "test" => "mruby" task
"mruby" => MRUBY_EXE file MRUBY_EXE => MRUBY_DIR
Document desc "Run tests" task "default" => "test" desc "Run
tests" task "test" => "mruby" desc "Build mruby" task "mruby" => MRUBY_EXE
Document $ rake -T rake default # Run tests rake
mruby # Build mruby rake test # Run tests
Organize namespace related tasks make separate .rake files import those
files
Organize $ grep rake Rakefile rakefiles = FileList['tasks/*.rake'] import(*rakefiles) $
find . -iname "*rake*" ./Rakefile ./tasks/test.rake
Advanced Rake
Re-declare tasks task "test" => "mruby" task "test" do #
run tests end tests = FileList["test/*.rb"] task "test" => tests
rake/clean require 'rake/clean' # remove temporary files CLEAN << "*.o"
<< "*.class" # rake clean # remove generated files CLOBBER << "*.so" << "*.jar" # rake clobber
rule Generates output Turns file X into file Y
rule rule ".html" => ".md" do |t| sh "md2html", t.source,
t.name end task "default" => html_files # md2html ch1.md ch1.html # md2html ch2.md ch1.html BACKWARD
Advanced import file "some.rake" => "do_this_first" import "some.rake"
Task Arguments task "name", [:first, :last] do |t, args| args.with_defaults
first: "Jamie", last: "Smith" puts "First name is #{args[:first]}" puts "Last name is #{args[:last]}" end
Task Arguments $ rake name First name is Jamie Last
name is Smith $ rake name[Eric,Hodel] First name is Eric Last name is Hodel
Task Arguments $ rake name[Eric, Hodel] rake aborted! Don't know
how to build task 'name[Eric,' (see --tasks)
h`ps:/ /github.com/ruby/rake