File tree 2 files changed +39
-1
lines changed 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
12
12
13
- _ 1211 TILs and counting..._
13
+ _ 1212 TILs and counting..._
14
14
15
15
---
16
16
@@ -1028,6 +1028,7 @@ _1211 TILs and counting..._
1028
1028
- [ Silence The Output Of A Ruby Statement In Pry] ( ruby/silence-the-output-of-a-ruby-statement-in-pry.md )
1029
1029
- [ Single And Double Quoted String Notation] ( ruby/single-and-double-quoted-string-notation.md )
1030
1030
- [ Skip Specific CVEs When Auditing Your Bundle] ( ruby/skip-specific-cves-when-auditing-your-bundle.md )
1031
+ - [ Specify Dependencies For A Rake Task] ( ruby/specify-dependencies-for-a-rake-task.md )
1031
1032
- [ Squeeze Out The Extra Space] ( ruby/squeeze-out-the-extra-space.md )
1032
1033
- [ String Interpolation With Instance Variables] ( ruby/string-interpolation-with-instance-variables.md )
1033
1034
- [ Summing Collections] ( ruby/summing-collections.md )
Original file line number Diff line number Diff line change
1
+ # Specify Dependencies For A Rake Task
2
+
3
+ Let's say you have rake task that performs some important business task. For
4
+ instance, a book seller might want a task that can tell them the top selling
5
+ books from a CSV report.
6
+
7
+ ``` ruby
8
+ task :top_selling_books do
9
+ # read in CSV and process for top selling books
10
+ end
11
+ ```
12
+
13
+ This works great if the CSV file already exists on the machine from which this
14
+ task is run. What if it isn't tho?
15
+
16
+ The CSV is a prerequesite for this task. We explicitly define it as a
17
+ prerequisite using the task dependency syntax.
18
+
19
+ ``` ruby
20
+ task :download_latest_book_sales_csv do
21
+ # saves a CSV of book sales
22
+ end
23
+
24
+ task top_selling_books: :download_latest_book_sales_csv do
25
+ # read in CSV and process for top selling books
26
+ end
27
+ ```
28
+
29
+ We can even define multiple task dependencies with an array.
30
+
31
+ ``` ruby
32
+ task top_selling_books: [:download_latest_book_sales_csv , :clean_csv ] do
33
+ # read in CSV and process for top selling books
34
+ end
35
+ ```
36
+
37
+ [ source] ( https://subscription.packtpub.com/book/hardware_and_creative/9781783280773/1/ch01lvl1sec13/task-dependencies-prerequisites )
You can’t perform that action at this time.
0 commit comments