Class: Megatest::Selector::NameMatchFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/megatest/selector.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ NameMatchFilter

Returns a new instance of NameMatchFilter.



208
209
210
# File 'lib/megatest/selector.rb', line 208

def initialize(pattern)
  @pattern = Regexp.new(pattern)
end

Class Method Details

.parse(arg) ⇒ Object



201
202
203
204
205
# File 'lib/megatest/selector.rb', line 201

def parse(arg)
  if match = arg.match(%r{\A/(.+)\z})
    new(match[1])
  end
end

Instance Method Details

#select(test_cases) ⇒ Object



212
213
214
215
216
# File 'lib/megatest/selector.rb', line 212

def select(test_cases)
  test_cases.select do |t|
    @pattern.match?(t.name) || @pattern.match?(t.id)
  end
end