Sha256: dade54d84c74ca9f9725e074fc0c1c0c6d2229a294037b49fe42da49b8ceec8a

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require 'bundler/gem_tasks'

RELISH_PROJECT = 'trema/pio'
FLAY_THRESHOLD = 452

task default: :travis
task test: [:spec, :cucumber]
task travis: [:test, :quality, 'coveralls:push']

desc 'Check for code quality'
task quality: [:reek, :flog, :flay, :rubocop]

Dir.glob('tasks/*.rake').each { |each| import each }

require 'pio/pcap'

def dump_in_hex(data)
  hexdump = data.unpack('C*').map do |each|
    format('0x%02x', each)
  end
  puts "[#{hexdump.join(', ')}]"
end

desc 'Dump packet data file in Array'
task :dump do
  unless ENV['PACKET_FILE']
    fail 'Usage: rake PACKET_FILE="foobar.{pcap,raw}" dump'
  end
  packet_file =
    File.join(File.dirname(__FILE__), 'features/', ENV['PACKET_FILE'])
  case File.extname(packet_file)
  when '.raw'
    dump_in_hex(IO.read(packet_file))
  when '.pcap'
    File.open(packet_file) do |file|
      Pio::Pcap::Frame.read(file).records.each do |each|
        dump_in_hex(each.data)
      end
    end
  else
    fail "Unsupported file extension: #{ENV['PACKET_FILE']}"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pio-0.23.1 Rakefile
pio-0.23.0 Rakefile