I had been really lazy to write this blog to finish off the thor application example. So I’ll just go right to the application, it’s nothing complicated. This application intends not to tweet actually in twitter but to demonstrate how thor tasks work.
So where I left from last post add a new folder bin in your application root and create a file tweet. This is going to be our executable file which will allow us to do something like,
tweet post hello
and will print You tweeted: hello.
Put the following in your bin/tweet file,
#!/usr/bin/ruby require "tweet" Tweet.start # this registers the thor class as task
Now install build and install the gem by executing ‘rake install’ command in application root. It will install the executable as well. So that’s it, the code can be downloaded from https://github.com/mftaher/Tweet-Thor. You can use it as a basic structure to create your own executable thor tasks.
Note: Before you install or build the gem always commit your git changes.