-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added handling of ERb files and nil lines #4
Conversation
…s pointless unless that's the case, anyway.
@@ -3,14 +3,15 @@ | |||
# A simple library to prepend magic comments to multiple ".rb" files | |||
|
|||
module AddMagicComment | |||
MAGIC_COMMENT_PREFIX = "frozen_string_literal" | |||
MAGIC_COMMENT_PATTERN = /^-?# *#{MAGIC_COMMENT_PREFIX}/ | |||
MAGIC_COMMENT_PREFIX = 'frozen_string_literal' |
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.
Just curious: what's wrong with double quotes?
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.
It's a stylistic preference, mostly (e.g., RubyMine flags double-quoted literal strings not containing interpolation), but it's actually faster for Ruby to parse, because it's not possible for there to be anything dynamic going on inside the string. For a similar reason, it's easier for humans to parse as a non-dynamic string.
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.
Except you can't use \
in single-quoted strings either. So now as a human you have to reason about whether a \
appears in the string, as you did below for the 'erb' EXTENSION. It's not worth the thrash IMO.
(Now I remember disabling that Rubymine warning!)
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.
Yeah, as I said, it's largely a matter of taste. I actually also like knowing that no special characters occur in a string, though that is of way less importance than knowing that there's no interpolation going on inside it. But it's fine, I'll revert to double quotes.
Closing in favor of a new pull request to address the comment about the ERb handling. |
No description provided.