Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

HotFusionMan
Copy link
Contributor

No description provided.

@@ -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'
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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!)

Copy link
Contributor Author

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.

@HotFusionMan
Copy link
Contributor Author

Closing in favor of a new pull request to address the comment about the ERb handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants