#242 Thor
Nov 29, 2010 | 8 minutes |
Tools
Thor is an alternative to Rake. It has better support for command line arguments and provides a way to add global scripts.
- Download:
- source codeProject Files in Zip (96.5 KB)
- mp4Full Size H.264 Video (13.2 MB)
- m4vSmaller H.264 Video (9.11 MB)
- webmFull Size VP8 Video (25 MB)
- ogvFull Size Theora Video (18.1 MB)
Great episode again! How do you do that your config/environment.rb gets required within a second? I get 15 seconds always.
I do not see really as competitors, more as complementary services, rake for the local project and thor for more system-wide tasks.
How to define rails environment in which Thor will run?
Nice. I have implemented copying my config examples as a rails generator (which is implemented in thor), but you're right, for more general purposes, thor shines (even as a full deployment system, I might add).
I believe you could use require "./config/environment" in 1.9 :)
rake is a tool tested by time. Thank you Ryan for good introduction for new tool, but I will stick with rake.
Leave it to @wycats to create useful tools for the rest of us.
I can't thank you enough for these screen casts, they are my go-to ruby on rails reference library.
I'd love to see some specifically on testing. That is definitely my weak point, but it feels like another system with it's own language to learn, even if you just go with the basic system. Anyone know some great screencasts for testing? I don't even know what framework to go with now.
Seems interesting, I will keep in my bookmarks and try it when I will have some time.
@Ahmed, that's just a bit of video editing so the viewers don't have to wait. The Rails environment takes a while on my end too.
@ARTSIOM, I haven't tried it yet, but I think setting the RAILS_ENV environment variable will work just like with Rake. You could turn this into its own command option in Thor to make it more convenient.
@Mark, cool, I didn't realize the "./" notation worked in require. Thanks.
@Carl, thanks for the suggestion. I hope to do more episodes on testing in the future.
Great episode as usual!
I would really be interrested in an episode about rails engine (with rails 3 ).
Looks pretty more integrated than in rails 2...
I enjoy using thor quite a bit. I wish thor would handle some of the simple things rake handles.
For example the file copy example. I like rake's file declaration syntax.
http://www.jbarnette.com/2009/08/27/on-rake.html
@Ryan: you should really use Disqus or reCAPTCHA here
A n00b question: What's the difference between a method option and an argument? While watching this, I couldn't tell my you chose, for example, to make the "count" for the article-generation method an option rather than an argument. I'll watch again to see if it's clear…
I'm really loving thor. I made a gem to talk to Fusemail's API (email provider), and I wanted to build a CLI app so I didn't have to deal with their web interface. With thor I was able to throw together a compelte CLI app for every method with less code (~100 lines) than using optparser would have taken alone:
https://github.com/mudbugmedia/fusebox/blob/master/lib/fusebox/cli.rb
https://github.com/mudbugmedia/fusebox/tree/master/bin/fusebox
Much thanks to wycats! :)
neat, clear, interesting as usual, they're nice to watch just to appreciate the quality!
One interesting difference between rake and thor: If you have a compile error in just one of your rakefiles, "rake -T" doesn't work at all. But if you have a similar bug in a thor file, "thor list" will still display valid tasks from other files.
Microsoft phone number, Microsoft number, Microsoft support number, microsoft customer service number, contact microsoft, microsoft contact, microsoft tech support phone number, Microsoft contact number, microsoft support phone number, microsofts number, call microsoft,Microsoft tech support number, microsoft phone support, Microsoft technical support phone number , microsoft help number, microsoft customer service phone number, Microsoft customer support number, Microsoft help phone number, phone number for microsoft, contact microsoft support, How to contact Microsoft