-
Notifications
You must be signed in to change notification settings - Fork 686
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
raise an exception when align value is not a Symbol #1057
raise an exception when align value is not a Symbol #1057
Conversation
@lucianosousa Hi! Thank you for your interest in giving back to community! Could you please give a bit of context for this PR? |
@pointlessone sure man. |
Prawn is not a part of the Ruby on Rails framework. We do not quite share an outlook on API design with Rails. I agree that it's suboptimal to break document rendering. But I think a proper solution here to let the user know what's wrong instead of extending the API. We generally do not accept strings where only a limited number of named options can be accepted and I don't want to diverge from that in this case. What do you think of an alternative solution? Add an |
@pointlessone cool. better raise an exception then ;) |
@lucianosousa Would you like to change the code in this PR or l it to someone else? |
@pointlessone sorry the delay. it's here! ;) |
@lucianosousa I would very much prefer if the exception was risen in every unrecognized case not only when it's not a symbol. |
sorry being late. updated |
NP. Thank you for keeping working on this. Could you please put the |
lib/prawn/text/formatted/box.rb
Outdated
@@ -267,6 +267,9 @@ def draw_fragment( | |||
else | |||
@at[0] + @width - line_width | |||
end | |||
else | |||
raise ArgumentError, 'align value needs to have a valid value: left, right, center or justify as symbol' unless |
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.
- The
unless
part is not needed any more. It's covered by the precedingcase
branches. - You also can write valid values in Ruby syntax (e.g.
:left
). I believe developers would pick that up. - I'm not a native speaker myself but overall wording is a bit awkward to me. What do you think of the following:
align must be one of :left, :right, :center or :justify
done @pointlessone sorry being late |
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.
Well done!
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.
Could you please fix code style to make RuboCop happy?
@pointlessone I guess we need merge #1060 first here |
@pointlessone just merged and passes! :D ready for u |
@lucianosousa Could you please clean up the history a bit? |
@pointlessone done |
Thank you for your contribution. |
No description provided.