Sha256: 3ed1b7249eb209e826b337ab0a56a01284136bac79ef92f304b176f47750980c

Contents?: true

Size: 820 Bytes

Versions: 13

Compression:

Stored size: 820 Bytes

Contents

require 'json'

module Norikra
  class Stats
    attr_accessor :host, :port, :ui_port, :threads, :log
    attr_accessor :targets, :queries

    def initialize(opts={})
      @host = opts[:host]
      @port = opts[:port]
      @ui_port = opts[:ui_port]
      @threads = opts[:threads]
      @log = opts[:log]
      @targets = opts[:targets] || []
      @queries = opts[:queries] || []
    end

    def to_hash
      {host: @host, port: @port, ui_port: @ui_port, threads: @threads, log: @log, targets: @targets, queries: @queries}
    end

    def dump(path)
      File.open(path, 'w') do |file|
        file.write(JSON.pretty_generate(self.to_hash))
      end
    end

    def self.load(path)
      File.open(path, 'r') do |file|
        self.new(JSON.parse(file.read, symbolize_names: true))
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
norikra-0.1.4-java lib/norikra/stats.rb
norikra-0.1.3-java lib/norikra/stats.rb
norikra-0.1.2-java lib/norikra/stats.rb
norikra-0.1.1-java lib/norikra/stats.rb
norikra-0.1.0-java lib/norikra/stats.rb
norikra-0.0.24-java lib/norikra/stats.rb
norikra-0.0.23-java lib/norikra/stats.rb
norikra-0.0.22-java lib/norikra/stats.rb
norikra-0.0.21-java lib/norikra/stats.rb
norikra-0.0.20-java lib/norikra/stats.rb
norikra-0.0.19-java lib/norikra/stats.rb
norikra-0.0.18-java lib/norikra/stats.rb
norikra-0.0.17-java lib/norikra/stats.rb