I'm wondering where would be the best place to do option parsing in ruby, when creating a gem, with the traditional (bin/, lib/, test/) folder hierarchy.
Specifically, should options be parsed in the executable file in (bi开发者_C百科n/) or in a runner class in lib/? And why?
I've seen it done both ways. Personally, I think much of it depends on your gem; if the option parsing is unique to the binary, put it in the binary, and pass the necessary options to your library. ruby-debug's binary is a good example. However, if your arguments are tied to your classes, such as passing around commands as in Heroku's Command
class, feel free to parse the options in your library.
精彩评论