Module: InteractiveFilter

Defined in:
lib/interactive_filter.rb,
lib/interactive_filter/input.rb,
lib/interactive_filter/interface.rb

Defined Under Namespace

Classes: Input, Interface

Class Method Summary collapse

Class Method Details

.filtering(repositories) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/interactive_filter.rb', line 5

def self.filtering(repositories)
  name = caller.last.match(/.+\/(.+?)(:|\.)/)[1].capitalize

  isatty = STDOUT.isatty

  unless isatty
    stdout_old = STDOUT.dup
    STDOUT.reopen('/dev/tty')
  end

  ifilter = Interface.new(name, repositories)
  result = ifilter.grep

  unless isatty
    STDOUT.flush
    STDOUT.reopen(stdout_old)
  end

  result
end