diff options
author | Agrim Mittal <agrimmittal97@gmail.com> | 2018-06-26 11:32:09 +0530 |
---|---|---|
committer | Agrim Mittal <agrimmittal97@gmail.com> | 2018-06-28 15:35:17 +0530 |
commit | df258d9f5098d4ed103adcff2eb01afacfa2abe7 (patch) | |
tree | 2ba6c5db43c48b09e2a671c82c755f8458ccee69 /lib | |
parent | e0c0c4b696c64b42729173922703ab7e75163a8a (diff) | |
download | bundler-df258d9f5098d4ed103adcff2eb01afacfa2abe7.tar.gz |
Move write_to_gemfile to SharedHelpers
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/injector.rb | 10 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index d8f283aa68..5bbb6aeae0 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -139,7 +139,7 @@ module Bundler cleaned_gemfile = remove_gems_from_gemfile(@deps, gemfile_path) - write_to_gemfile(gemfile_path, cleaned_gemfile) + SharedHelpers.write_to_gemfile(gemfile_path, cleaned_gemfile) # check for errors # including extra gems being removed @@ -191,12 +191,6 @@ module Bundler new_gemfile.join.chomp end - # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies. - # @param [String] contents Content to written to Gemfile. - def write_to_gemfile(gemfile_path, contents) - SharedHelpers.filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } } - end - # @param [Array] gemfile Array of gemfile contents. # @param [String] block_name Name of block name to look for. def remove_nested_blocks(gemfile, block_name) @@ -235,7 +229,7 @@ module Bundler # if some extra gems were removed then raise error # and revert Gemfile to original unless extra_removed_gems.empty? - write_to_gemfile(gemfile_path, initial_gemfile.join) + SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join) raise InvalidOption, "Gems could not be removed. #{extra_removed_gems.join(", ")} would also have been removed. Bundler cannot continue." end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 326ffa466b..93e2a35b54 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -226,6 +226,10 @@ module Bundler Digest(name) end + def write_to_gemfile(gemfile_path, contents) + filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } } + end + private def validate_bundle_path |