File: focus.rb

package info (click to toggle)
ruby-zentest 4.11.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 536 kB
  • sloc: ruby: 3,210; makefile: 13
file content (26 lines) | stat: -rw-r--r-- 555 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Module
  def focus *wanteds
    wanteds.map! { |m| m.to_s }
    unwanteds = public_instance_methods(false).grep(/test_/).map(&:to_s)
    unwanteds -= wanteds
    unwanteds.each do |unwanted|
      remove_method unwanted
    end
  end

  def focus_re regexp
    focus(*public_instance_methods.grep(regexp))
  end

  def blur
    parent = self.superclass

    ObjectSpace.each_object Class do |klass|
      next unless parent > klass
      next if klass == self

      klass.send :focus
      klass.send :undef_method, :default_test
    end
  end
end