Class: Megatest::Selector
- Inherits:
-
Object
- Object
- Megatest::Selector
- Defined in:
- lib/megatest/selector.rb
Defined Under Namespace
Classes: ExactLineFilter, List, Loader, NameFilter, NameMatchFilter, NegativeFilter, NegativeLoader, TagFilter
Constant Summary collapse
- FILTERS =
[ ExactLineFilter, TagFilter, NameMatchFilter, NameFilter, ].freeze
Instance Method Summary collapse
-
#initialize(config) ⇒ Selector
constructor
A new instance of Selector.
- #parse(argv) ⇒ Object
Constructor Details
#initialize(config) ⇒ Selector
Returns a new instance of Selector.
256 257 258 |
# File 'lib/megatest/selector.rb', line 256 def initialize(config) @config = config end |
Instance Method Details
#parse(argv) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/megatest/selector.rb', line 260 def parse(argv) if argv.empty? return List.new(@config, [], []) end argv = argv.dup loaders = [] filters = [] negative = false until argv.empty? case argument = argv.shift when "!" negative = true else loader_str, filter_str = argument.split(":", 2) loader_str = nil if loader_str.empty? filter = nil if filter_str FILTERS.each do |filter_class| if filter = filter_class.parse(filter_str) break end end end if loader_str loader = Loader.new(@config, loader_str, filter) if negative loader = NegativeLoader.new(loader) negative = false end loaders << loader else if negative filter = NegativeFilter.new(filter) negative = false end filters << filter end end end List.new(@config, loaders, filters) end |