Sha256: 451d33133931a1141ed94d5e501911a1ee1e88a130fb3f5f024f1248e7863945

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module ElchScan
  module Filter
    def filter_script name
      "#{ROOT}/tmp/#{name}.esss"
    end

    def apply_filter collection, file
      app = @app
      eval File.read(file), binding, file
      collection
    end

    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

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elch_scan-0.1.2 lib/elch_scan/application/filter.rb
elch_scan-0.1.1 lib/elch_scan/application/filter.rb
elch_scan-0.1.0 lib/elch_scan/application/filter.rb