Thor is a toolkit that makes it easy to build CLI apps. Since my CLI app allows the user to pass in parameters like -category, I ended up using Thor. My initial plan was to use sendmail for sending emails, but I ended up using SMTP to improve deliverability. You guessed it! The mail gem lets you send emails. I used this for parsing HTML data fetched from the remote website and to convert them into domain objects. If you’re dealing with parsing XML/HTML, chances are you’ll run into Nokogiri. My goal was to follow the KISS principle as strictly as possible. I’ve been using Lando for Drupal projects for a while, so I decided to use it here as well. I like Docker because it helps me keep my laptop clean. To kick it off, I created a Docker based dev env with Lando, using a community-maintained ruby image. $ ruby spcas.rb -verbose -email -interval=5 Test the code well because coding is less fun without tests □□♂️.Allow choosing a category to watch, i.e.Preferably, include images in the email body.Send email notifications to configured email addresses.Watch the SPCA website for new pets at intervals of 5 minutes.Working on a project is more fun with a checklist of features and a deadline, so I started with some project management. Io was my neighbour in Colombia, named after Jupiter’s moon. Explore the source code for the app and enjoy.I’d love to add some integration tests.I would’ve added more tests if this were a real, commercial app.The app has a reasonable number of tests. The app tries to keep code organized into logical classes.See the SPCA::Cli#scan method for further details.Send email notifications when new items are found.Watch the SPCA website for new items at regular intervals.I started by creating a list of features for my app:.This article does not aim to promote my app, but to share the underlying code and findings with Ruby enthusiasts who aim to write similar apps. Thus, I decided to do a Ruby coding marathon to celebrate my birthday! I decided to write a small CLI app to watch the pet adoption website and to send me emails when new cats are available □. Having lost my Ruby job, I had been hungry for writing Ruby for over a month □. Usually, pets get adopted very fast! Thus, I felt the need for an app which would notify me of new arrivals.Īlso, having worked with Ruby throughout 2020, I had realized that I love writing Ruby code. In Montréal, one can adopt pets from the SPCA.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |