This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'optparse' | |
class OptionParser | |
def list_opts(prior_opts) | |
opts = enum_for(:visit, :tap).map(&:list).flatten(1) | |
prior_opts = opts.select{|opt| opt.long.any?{|name| prior_opts.include?(name)} } | |
opts -= prior_opts | |
simple_opts = opts.select{|opt| !opt.short.empty? && opt.arg.nil? }.sort_by{|x| x.short.sort.first} | |
opts -= simple_opts | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def declare(decorator, *args) | |
orig_method_added = method(:method_added) | |
metaclass = (class << self; self end) | |
defined_methods = [] | |
metaclass.send(:define_method, :method_added) do |name| | |
orig_method_added.call(name) | |
defined_methods << name | |
end | |
begin |
NewerOlder