Sha256: 7aa344a0c6f2dae7a525fec061201978f15349e7631b10b97dd9466cdfa63ed0

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

require 'open3'
require "nmapr/version"
require "nmapr/scanner"

module Nmapr
  def self.scan(type = :object, &block)
    scan = Scanner.new
    scan.instance_eval(&block)
    case type
    when :object
      scan 
    when :cmd
      scan.to_cmd
    when :run
      run(scan.to_cmd)
    end
  end

  def self.run(cmd)
    results = Hash.new
    stdout, stderr, status = Open3.capture3(cmd)
    results[:stdout] = stdout
    results[:stderr] = stderr
    results[:status] = status
    return results unless block_given?
    yield results
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nmapr-1.0.0 lib/nmapr.rb