Skip to content
David Copeland edited this page Jun 10, 2020 · 1 revision

This gem was originally called "methadone" because I thought it was very clever, as it allowed you to "kick the bash habit", the same way actual methadone can be used to kick a narcotic drug habit.

After some reflection (that I should've done a long time ago), it seems like programmers who have suffered addiction problems and had to use methadone (which I understand is not pleasant) may not appreciate having to see it emblazoned in code they are working on.

Granted, this is not a very popular or widely-used gem and granted, the overlap of recovering addicts writing Ruby command-line applications is not a lot of people, but still. Why make them uncomfortable so that I can feel clever?

Upgrading

Given that this gem is not that popular, I have chosen not to include an upgrade mechanism, however I was able to upgrade this gem with a single ruby script I will paste below. This should work for you, too

#!/usr/bin/env ruby

require "pathname"
require "fileutils"


ARGV.each do |filename|
  filename = Pathname(filename)

  contents = File.read(filename).split(/\n/)
  File.open(filename,"w") do |file|
    contents.each do |line|
      file.puts line.gsub(/methadone/,"optparse_plus").gsub(/Methadone/,"OptparsePlus")
    end
  end

  if filename.split.any? { |_| _ == "methadone" }
    new_filename = filename.split.map { |_|
      if _ == "methadone"
        "optparse_plus"
      else
        _
      end
    }.join
    FileUtils.mkdir_p new_filename.dirname
    FileUtils.mv filename new_filename
  end

end
Clone this wiki locally