Posted almost 5 years ago. Visible to the public.

Rake [0.75d]

Research

  • What is rake good for?
  • Take a look at some of the Rake tasks that Rails gives you (rake -T within a Rails project)
  • Find the code that defines the rake stats task in the Rails gems
  • What are some ways how a Rake task can execute another task?
  • What does it mean if a Rake task "depends" on another task? E.g. understand what it means for a Rake task within a Rails app to depend on :environment.
  • Understand that Capistrano tasks are also defined using the Rake DSL, but a Capistrano task is not automatically a Rake task and vice versa.

Exercises

  • Write a Rake task rake public_methods that lists all public methods of all models in app/models.
    • Hint: Don't manually parse the source code. You can ask a Ruby class: Klass.public_methods.
    • Hint: It's OK if you show methods from both ActiveRecord and ActiveType classes
  • Use a namespace to rename your task to rake models:public_methods
  • Give your task a nice description and notice how it appears in rake -T

Owner of this card:

Avatar
Henning Koch
Last edit:
about 1 month ago
by Henning Koch
Posted by Henning Koch to makandra Curriculum
This website uses short-lived cookies to improve usability.
Accept or learn more