Class: Waffle::Maker::Filter

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Filter

Returns a new instance of Filter.



21
22
23
24
25
26
27
28
29
30
# File 'lib/waffle/maker.rb', line 21

def initialize(argv)
  (@options = default_options).tap do |options|
    OptionParser.new { |o|
      o.banner = "Usage: #{$0}"
      o.on("-f number", "Column number that contains the rails path") { |v| options[:f] << v.to_i }
      o.on("-w number", "Column number that contains the waf path") { |v| options[:w] << v.to_i }
      o.on("--silent-error", "Hide parsing errors, default is false") { |v| options[:silent_error] << v }
    }.parse!(argv)
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/waffle/maker.rb', line 13

def options
  @options
end

Class Method Details

.executeObject



16
17
18
# File 'lib/waffle/maker.rb', line 16

def execute
  Waffle::Maker::Filter.new(ARGV.dup).execute
end

Instance Method Details

#default_optionsObject



33
34
35
# File 'lib/waffle/maker.rb', line 33

def default_options
  { f: 2, w: 2, silent_error: false }
end

#executeObject



37
38
39
40
41
# File 'lib/waffle/maker.rb', line 37

def execute
  wafs.each do |waf|
    puts waf[:raw] if Waffle::Maker::Matcher.new(waf[:path], routes).matched?
  end
end