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

Update plugin_generator.rb #30004

Merged
merged 1 commit into from Nov 14, 2017

Conversation

Projects
None yet
8 participants
@npenzin
Contributor

npenzin commented Jul 30, 2017

Summary. Patch

I ran rails plugin new engines/bot --mountable

Unless original Gemfile ends with empty line, plugin generator appends entry to the last line.

E.g., Gemfile ends with end statement from previous group: statement, after generation last line will become endgem...

before:
end

after:
endgem 'bot', path: 'engines/bot'

@rails-bot

This comment has been minimized.

rails-bot commented Jul 30, 2017

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

railties/lib/rails/generators/rails/plugin/plugin_generator.rb Outdated
@@ -167,6 +167,8 @@ def gemfile_entry
gemfile_in_app_path = File.join(rails_app_path, "Gemfile")
if File.exist? gemfile_in_app_path
append_file gemfile_in_app_path, "\n"
entry = "gem '#{name}', path: '#{relative_path}'"

This comment has been minimized.

@jerguslejko

jerguslejko Jul 30, 2017

wouldn't it be easier to preped \n to entry?

@lugray

This comment has been minimized.

Contributor

lugray commented Jul 31, 2017

I agree with not opening the file for writing twice. This should also have an associated test.

@lugray

This comment has been minimized.

Contributor

lugray commented Aug 21, 2017

Since this was quite old with no work, I applied the fixes.

railties/test/generators/plugin_generator_test.rb Outdated
@@ -530,10 +530,11 @@ def test_creating_plugin_in_app_directory_adds_gemfile_entry
gemfile_path = "#{Rails.root}/Gemfile"
Object.const_set("APP_PATH", Rails.root)
FileUtils.touch gemfile_path
File.write(gemfile_path, '#foo')

This comment has been minimized.

@y-yagi

y-yagi Sep 10, 2017

Member

Please use double-quoted strings.

@y-yagi

This comment has been minimized.

Member

y-yagi commented Nov 14, 2017

@npenzin @lugray Are you still interested this? There are code that violate Rubocop. If it is fixed, I will merge.

Ensure plugin_generator adds to new line in Gemfile
Ensure plugin_generator adds to new line in Gemfile, even if the Gemfile
does not end with an empty line.

[Lisa Ugray, Nikita Penzin]
@lugray

This comment has been minimized.

Contributor

lugray commented Nov 14, 2017

Thanks for the reminder @y-yagi! Your initial review came while I was on my honeymoon, and I declared email bankruptcy when I got back. Sorry for the delay!

@y-yagi y-yagi merged commit 874dae1 into rails:master Nov 14, 2017

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@y-yagi

This comment has been minimized.

Member

y-yagi commented Nov 14, 2017

@lugray No problem. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment