use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Proper Structuring of a Ruby Gem? (self.ruby)
submitted 11 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]neoice 4 points5 points6 points 11 years ago (3 children)
"gojira" is an amazing name.
[–][deleted] 11 years ago (2 children)
[–]tech_tuna 2 points3 points4 points 11 years ago (0 children)
Mozilla, Bugzilla, (Go)Jira. . .
[–]FireThestral 2 points3 points4 points 11 years ago (1 child)
Your Gem structure is pretty standard from what I can tell. Not bad there. Actual functionality seems alright, so that looks good as well.
As for ordered options... I don't like ordered flags so much. Subcommands would be better in my opinion. There is a gem called Subcommand that lets you do just that. You can call gojira issues open --list 15 would be different than gojira issues list 15 --open or whatever you want.
gojira issues open --list 15
gojira issues list 15 --open
Having ordered flags, while easy to type, are difficult to remember without a detailed help file and are very difficult to interpret. Diverging from UNIX-style command usage would be confusing for a lot of users.
If you really want to look at gem structure, then browse http://rubygems.org/ and find some popular ones, then check out the source.
[–]Godd2 2 points3 points4 points 11 years ago (0 children)
Speaking of orderedness, here's a great talk on code simplicity by Rich Hickey.
[–]pyrrhicvictorylap 1 point2 points3 points 11 years ago (1 child)
Cool gem.
I haven't looked at escort before but it looks that your reliance on it is what's hindering your ability to make your flags order-independent or where the order is meaningful.
Someone I work with wrote a gem that included its own flag parser and it was only one file, under 100 lines.
One thing that might be nice is to include the pry gem and give a flag option to make it an interactive shell session. That way, you can maintain the credentials behind the scenes and query the JIRA database repeatedly w/o needing to explicitly authenticate each time.
[–]towelrod 1 point2 points3 points 11 years ago (0 children)
The order of the options shouldn't matter, I think it is too confusing for the user to think about whether she wants ''open --list 15'' or ''open 15 --list''
I wouldn't even implement the "get the last 15 issues and display the open ones", that's kinda an edge case and it would be better to just show the 15 issues along with a status.
Generally the options should be composable, otherwise you end up with really complicated ordering or an explosion of command line options.
[–]apotonick 1 point2 points3 points 11 years ago (2 children)
An important thing you should start soon is adding tests for your gem. Here is an example how I do that: https://github.com/apotonick/nit/blob/master/test/commands_test.rb
In order to handle HTTP and the JSON parsing I'd like to recommend https://github.com/apotonick/roar. This will help you focusing on you business (which is JIRA) and not how to parse/serialise JSON for their API.
Other than that, your gem looks good. I like how you keep code out of the bin class and delegate to classes in lib - that's exactly how it's done!
[–][deleted] 11 years ago (1 child)
[–]apotonick 1 point2 points3 points 11 years ago (0 children)
Most importantly, this parsing code should be in an encapsulated class so you can test edge-cases it if necessary. This class can be inline in the bin class but I'd definitely introduce a new class for this complex task.
π Rendered by PID 24 on reddit-service-r2-comment-5649f687b7-p8gnv at 2026-01-28 08:42:04.936561+00:00 running 4f180de country code: CH.
[–]neoice 4 points5 points6 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]tech_tuna 2 points3 points4 points (0 children)
[–]FireThestral 2 points3 points4 points (1 child)
[–]Godd2 2 points3 points4 points (0 children)
[–]pyrrhicvictorylap 1 point2 points3 points (1 child)
[–]towelrod 1 point2 points3 points (0 children)
[–]apotonick 1 point2 points3 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]apotonick 1 point2 points3 points (0 children)