One-Liners exercise
Want to make a contribution to Whenbot? Let's get you started! The main goal of the exercise is to show that it's not all that hard to contribute to an open source project.
We've taken away the hard part of figuring out exactly what to contribute, by providing you with a list of one-liners that need to be added to Whenbot. We've also provided you a step-by-step guide to walk you through the process.
All you need to do is choose a One-Liner from the list below (be sure to reserve your choice), and follow the Contribution Guide here.
Never contributed to Open Source before?
If it's your first time making an Open Source contribution, don't worry, it's not that hard. Be excited, follow the guide below, and very soon you should have made your first Open Source contribution!
How to participate
Follow these steps:
-
Take a look at the list below and choose a One-Liner to work on.
-
Make sure that the One-Liner you picked hasn't already been chosen by checking the comments below this post. If your One-Liner has already been reserved, choose another one.
-
Then, reserve your One-Liner by posting a comment in this thread (below). Just write: "Working on one-liner number one-liner number in file path here, brief description of change". For example:
Working on one-liner number 8 in app/models/task.rb, to make the :name, :active, :trigger_attributes, and :action_attributes attributes accessible.
After posting your comment, you're ready to start working on your update. :)
-
Once you have your one-liner chosen and reserved, follow the Whenbot One-Liner Contribution Guide to learn how to create your own fork of the app, clone the repository, make your changes, push your changes back to your fork, and issue a Pull Request.
The One-Liners
Choose a One-Liner number below, and follow the instructions above. Soon, you'll have contributed to a cool, new Open-Source project. :)
If you need help, you can find the solution for your one-liner in this branch. Just browse to the file you're working on.
lib/whenbot.rb
- Line 15: add a call to #mattr_accessor to create a Module Attribute for :channels
- Line 50: Fill in the block to take a Channel class (e.g. Whenbot::Channels::Developer), convert it to a string, and extract the Channel's name out of the string. In the previous example, you'd want to get the word" Developer"
lib/whenbot/trigger.rb
- Line 14: In the
current_time method, return the current time in the set time zone.
app/controllers/whenbot_controller.rb
- Line 6: Call the
Task.handle_callback method (found in app/models/task.rb) with the following parameters in the given order, and set the response variable to the return value of that call:
params[:channel], params[:trigger], params, request.headers, request.body.read
- Line 7 and Line 20: Rename the
#validate_response method to "#parse_response``.
app/models/task.rb
- Line 3: Create a
has_many association with the Action model
- Line 7: Make the following accessible attributes:
:name, :active, :trigger_attributes, :action_attributes
- Line 17: Call the
Trigger#save_updated_triggers method with returned_triggers, and trigger_ids as parameters.
- Line 18: Return
response
app/models/trigger.rb
- Line 2: Create a named scope (use
scope) called active that returns records where the active field is set to true
- Line 4: Allow the
parameters field to be serializable as a Hash
- Line 5: Allow the
match_data field to be serializable as a Hash
- Line 6: Allow the
extra_data field to be serializable as a Hash
- Line 7: Set up a "belongs to" association with the
Task model
- Line 8: Make the following accessible attributes:
channel, trigger, parameters, active
- Line 9: Ensure that the model validates the presence of
channel, trigger, and ``parameters
One-Liners exercise
Want to make a contribution to Whenbot? Let's get you started! The main goal of the exercise is to show that it's not all that hard to contribute to an open source project.
We've taken away the hard part of figuring out exactly what to contribute, by providing you with a list of one-liners that need to be added to Whenbot. We've also provided you a step-by-step guide to walk you through the process.
All you need to do is choose a One-Liner from the list below (be sure to reserve your choice), and follow the Contribution Guide here.
Never contributed to Open Source before?
If it's your first time making an Open Source contribution, don't worry, it's not that hard. Be excited, follow the guide below, and very soon you should have made your first Open Source contribution!
How to participate
Follow these steps:
Take a look at the list below and choose a One-Liner to work on.
Make sure that the One-Liner you picked hasn't already been chosen by checking the comments below this post. If your One-Liner has already been reserved, choose another one.
Then, reserve your One-Liner by posting a comment in this thread (below). Just write: "Working on one-liner number
one-liner numberinfile path here,brief description of change". For example:Working on one-liner number 8 in
app/models/task.rb, to make the:name,:active,:trigger_attributes, and:action_attributesattributes accessible.After posting your comment, you're ready to start working on your update. :)
Once you have your one-liner chosen and reserved, follow the Whenbot One-Liner Contribution Guide to learn how to create your own fork of the app, clone the repository, make your changes, push your changes back to your fork, and issue a Pull Request.
The One-Liners
Choose a One-Liner number below, and follow the instructions above. Soon, you'll have contributed to a cool, new Open-Source project. :)
If you need help, you can find the solution for your one-liner in this branch. Just browse to the file you're working on.
lib/whenbot.rb
lib/whenbot/trigger.rb
current_timemethod, return the current time in the set time zone.app/controllers/whenbot_controller.rb
Task.handle_callbackmethod (found inapp/models/task.rb) with the following parameters in the given order, and set the response variable to the return value of that call:params[:channel], params[:trigger], params, request.headers, request.body.read#validate_responsemethod to "#parse_response``.app/models/task.rb
has_manyassociation with theActionmodel:name, :active, :trigger_attributes, :action_attributesTrigger#save_updated_triggersmethod withreturned_triggers, andtrigger_idsas parameters.responseapp/models/trigger.rb
scope) calledactivethat returns records where theactivefield is set totrueparametersfield to be serializable as aHashmatch_datafield to be serializable as aHashextra_datafield to be serializable as aHashTaskmodelchannel, trigger, parameters, activechannel,trigger, and ``parameters