class Switcher

Public Class Methods

new(env_filename) click to toggle source
# File lib/env_switch/switcher.rb, line 2
def initialize(env_filename)
  @env_filename = env_filename
end

Public Instance Methods

switch() click to toggle source
# File lib/env_switch/switcher.rb, line 6
def switch
  files = Dir.glob("*.env")

  result = files.select { |f| f == "#{@env_filename}.env" }

  if !result.empty?
    FileUtils.cp(result.first, '.env')
    puts "Copied #{result.first} to .env"
  else
    puts "No env found for #{@env_filename}"
  end

end