Class: Machinery::FilterOptionParser

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

Overview

This class takes care of transforming the user-provided filter options into actual Filter objects.

Class Method Summary collapse

Class Method Details

.parse(command, options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/filter_option_parser.rb', line 22

def parse(command, options)
  filter = Machinery::Filter.from_default_definition(command)

  definitions = skip_files_definitions(options.delete("skip-files"))
  definitions += exclude_definitions(options["exclude"])

  definitions.map! { |definition| definition.gsub("\\@", "@") } # Unescape escaped @s
  definitions.each do |definition|
    filter.add_element_filter_from_definition(definition)
  end

  filter
end