Update plugin_generator.rb #30004
Update plugin_generator.rb #30004
Conversation
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. |
@@ -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}'" |
jerguslejko
Jul 30, 2017
wouldn't it be easier to preped \n
to entry
?
wouldn't it be easier to preped \n
to entry
?
I agree with not opening the file for writing twice. This should also have an associated test. |
Since this was quite old with no work, I applied the fixes. |
@@ -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') |
y-yagi
Sep 10, 2017
Member
Please use double-quoted strings.
Please use double-quoted strings.
@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, even if the Gemfile does not end with an empty line. [Lisa Ugray, Nikita Penzin]
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! |
@lugray No problem. Thanks!! |
Summary. Patch
I ran
rails plugin new engines/bot --mountable
Unless original
Gemfile
ends with empty line, plugin generator appendsentry
to the last line.E.g.,
Gemfile
ends withend
statement from previousgroup:
statement, after generation last line will becomeendgem...
before:
end
after:
endgem 'bot', path: 'engines/bot'