New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lower default lines of UD response to 5, adjust corresponding spec #2
Lower default lines of UD response to 5, adjust corresponding spec #2
Conversation
chriswoodrich
commented
Jan 23, 2015
This fixes issue #1 |
@jimmycuadra pls |
I think 20 is a reasonable default, but it'd be great to expose this limit as a configuration option if people want to change it. I also noticed that the definition that brought on this discussion was resulting in about 45 lines of response, so this PR will not address that problem – there's some other bug happening that's making it bypass this hard coded limit of 20. |
I'll add a config ceiling and investigate the bug at the same time. In the mean time, can you merge this to thwart @tristaneuan ? |
It won't have any effect as is, due to the bug I mentioned. :\ |
if lines.size > 20 | ||
lines = lines[0..19] | ||
# strip out tabs and spaces baked into lines repsonse | ||
lines = lines.map {|line| line.split(/[\r\n]+/)}.flatten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this logic into its own method so the comment isn't needed. Use flat_map
instead of map
+ flatten
for improved performance. For style, put a space after {
and before }
.
Looking pretty good! The new option should be added to the README, as well. |
Will do, @jimmycuadra |
I just pushed up a commit that fixes the bug where long examples don't get truncated and adds better test coverage. That will simplify this branch. Here's what's left:
Thanks! :D |
lolz, my bad |
e9cc99e
to
4069707
Compare
This is better UI. Default max response is now 20 lines, hard-coding is removed giving the user more control, and a |
@@ -43,9 +49,19 @@ def fetch_definition(term) | |||
end | |||
end | |||
|
|||
def determine_max_size(lines) | |||
unless config.max_response_size.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y u do dis? Change to if/else/end
Looks great. I agree with Mitch though, unless/else is a pattern to avoid. Switch that up and then I'll merge it. Thanks!! |
Actually, I can't merge this cleanly yet. You'll have to rebase your own commits onto the latest master. |
4069707
to
ba6dabf
Compare
Ready to go, @jimmycuadra |
… of nil values, document chages in README.
ba6dabf
to
e4504b2
Compare
Lower default lines of UD response to 5, adjust corresponding spec