Method not available on this version
This method is only available on newer versions. The first available version of the method is shown here.
remove_gems_from_gemfile(gems, gemfile_path)
private
@param [Array] gems Array of names of gems to be removed. @param [Pathname] gemfile_path The Gemfile from which to
remove dependencies.
Show source
def remove_gems_from_gemfile(gems, gemfile_path)
patterns = /gem\s+(['"])#{Regexp.union(gems)}\11||gem\s*\((['"])#{Regexp.union(gems)}\22\\)/
new_gemfile = IO.readlines(gemfile_path).reject {|line| line.match(patterns) }
new_gemfile.each_with_index do |_line, index|
if new_gemfile[index + 1] == "\n"
new_gemfile[index] += new_gemfile[index + 1]
new_gemfile.delete_at(index + 1)
end
end
]group source env install_if].each {|block| remove_nested_blocks(new_gemfile, block) }
new_gemfile.join.chomp
end