Module: Removers

Defined in:
lib/tasks/helpers/removers.rb

Overview

This file is distributed under New Relic’s license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#remove_generated_gemfile_lockfilesObject



26
27
28
29
30
31
32
# File 'lib/tasks/helpers/removers.rb', line 26

def remove_generated_gemfile_lockfiles
  file_path = File.expand_path('test/environments')
  Dir.glob(File.join(file_path, '**', 'Gemfile.lock')).each do |fn|
    puts "Removing #{fn.gsub(file_path, '.../environments')}"
    FileUtils.rm(fn)
  end
end

#remove_generated_gemfilesObject



18
19
20
21
22
23
24
# File 'lib/tasks/helpers/removers.rb', line 18

def remove_generated_gemfiles
  file_path = File.expand_path('test/multiverse/suites')
  Dir.glob(File.join(file_path, '**', 'Gemfile*')).each do |fn|
    puts "Removing #{fn.gsub(file_path, '.../suites')}"
    FileUtils.rm(fn)
  end
end

#remove_local_multiverse_databasesObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/tasks/helpers/removers.rb', line 6

def remove_local_multiverse_databases
  list_databases_command = %(echo "show databases" | mysql -u root)
  databases = `#{list_databases_command}`.chomp!.split("\n").select { |s| s.include?('multiverse') }
  databases.each do |database|
    puts "Dropping #{database}"
    `echo "drop database #{database}" | mysql -u root`
  end
rescue => error
  puts 'ERROR: Cannot get MySQL databases...'
  puts error.message
end