Module: ElchScan::Filter
- Included in:
- Application
- Defined in:
- lib/elch_scan/application/filter.rb
Instance Method Summary collapse
- #apply_filter(collection, file) ⇒ Object
- #filter_script(name) ⇒ Object
- #permute_script(collection, file = nil) ⇒ Object
- #record_filter(file = nil) ⇒ Object
Instance Method Details
#apply_filter(collection, file) ⇒ Object
7 8 9 10 11 |
# File 'lib/elch_scan/application/filter.rb', line 7 def apply_filter collection, file app = @app eval File.read(file), binding, file collection end |
#filter_script(name) ⇒ Object
3 4 5 |
# File 'lib/elch_scan/application/filter.rb', line 3 def filter_script name "#{ROOT}/tmp/#{name}.esss" end |
#permute_script(collection, file = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/elch_scan/application/filter.rb', line 13 def permute_script collection, file = nil file ||= "#{Dir.tmpdir}/#{SecureRandom.urlsafe_base64}" FileUtils.mkdir(File.dirname(file)) if !File.exist?(File.dirname(file)) if !File.exist?(file) || File.read(file).strip.empty? File.open(file, "w") {|f| f.puts("# Permute your collection, same as with the selector script filters.") } end system "#{cfg :application, :editor} #{file}" eval File.read(file), binding, file collection end |
#record_filter(file = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/elch_scan/application/filter.rb', line 24 def record_filter file = nil file ||= "#{Dir.tmpdir}/#{SecureRandom.urlsafe_base64}" FileUtils.mkdir(File.dirname(file)) if !File.exist?(File.dirname(file)) if !File.exist?(file) || File.read(file).strip.empty? FileUtils.cp("#{ROOT}/doc/filter.rb", file) end system "#{cfg :application, :editor} #{file}" file end |