Skip to content

Ruby 2.3 magic comments support #302

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

Merged
merged 4 commits into from
Dec 21, 2015
Merged

Conversation

b264
Copy link
Contributor

@b264 b264 commented Dec 10, 2015

My attempt to support Ruby 2.3 magic comments

@ctran
Copy link
Owner

ctran commented Dec 11, 2015

I haven't heard of this. Where can I find more info on this?

@b264
Copy link
Contributor Author

b264 commented Dec 11, 2015

nithinbekal.com/posts/ruby-2-3-features/

@b264
Copy link
Contributor Author

b264 commented Dec 11, 2015

Also I tried the current version with ruby-2.3.0-preview1

'# -*- encoding : utf-8 -*-',
"# encoding: utf-8\n# frozen_string_literal: true",
"# frozen_string_literal: true\n# encoding: utf-8",
'# frozen_string_literal: true',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading this correctly? These seem to be repeated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any are duplicated

@ctran
Copy link
Owner

ctran commented Dec 11, 2015

This seems like an optional feature since some people may not want to turn it on. I think we have an option to append additional text so that may be a better option. Can you enlighten me?

@b264
Copy link
Contributor Author

b264 commented Dec 12, 2015

If you have the # encoding: utf-8 magic comment (aka directive pragma) at the top of the file, annotate already leaves this there. 👍 Ruby 2.3.0 will have an additional magic comment now which I for one will be using immediately. This PR will cause annotate to leave that magic comment alone at the top of the file, as it leaves the encoding one there also. I thought I had read somewhere that it had to be on the first 2 lines, but after additional searching and an experiment, it seems at least in the preview the magic comment can be anywhere before the first executable line and still affect the compile mode. However, moving it from the top of the file in my opinion is still messy and makes it harder to know you're working in frozen string land. So the entire point is that it leaves it at the top of the file, like the other one, instead of burying it under the schema. This does not turn the feature on if they hadn't already turned it on; it preserves their action to activate it.

ctran added a commit that referenced this pull request Dec 21, 2015
Ruby 2.3 magic comments support
@ctran ctran merged commit 056fd42 into ctran:develop Dec 21, 2015
@ctran ctran added the feature label Dec 21, 2015
@ctran ctran added this to the v2.7.0 milestone Dec 21, 2015
@ctran
Copy link
Owner

ctran commented Dec 21, 2015

Thanks

@b264 b264 deleted the 2_3_ruby__support branch December 21, 2015 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants