hexify 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hexify.rb +15 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2a4e0e6e9f529314b50e1751900ef75864dbb71
4
- data.tar.gz: e716d3b44cb441a3b2010e2cdd488fdbb509a9aa
3
+ metadata.gz: 295d63a1673bc856ce8965ec47393232a9b26172
4
+ data.tar.gz: d596a87ca82684d9aa6cdf33f1cd2b46423b98bf
5
5
  SHA512:
6
- metadata.gz: ecaacce1d20690ad4548dc382fea242e336ce71689af11e09609d6404d55ee6e8f2920890d04cba07b068b7322a47ae1c4cd42c58156668edefeb40091b369bc
7
- data.tar.gz: c3ea9500e7834b52e7c015d011abfa6bb85c7ee70be224aa6420b0e782a8dc9888e1c56921e201d0a28d7e5503e99520800e6fdce1dd5ca06657c4ecfce6482a
6
+ metadata.gz: fde065908e3dc1dfcb7156d88a6be3be4b6473c9a4591982a60afd0eba0eaa2e0cd5d2937f91e028fc2a8e58c73c29c212299c70327cf5a376763838aaafb8c6
7
+ data.tar.gz: 0b9a2cc6926599bb8c4e1d4b765f8e572b9c05f669281721b9df56481a9b658b8e22197a614a9d66f6c68d54ccb7148c0cd640e39df6bf781ffc26aac7cb5bf9
@@ -1,7 +1,20 @@
1
1
  class Hexify
2
2
 
3
- def self.following(data)
4
- data.bytes.each.inject("") { |output, byte| output += "%02X " % [ byte.ord ] }
3
+ def self.listing(data, options={})
4
+ text = " "
5
+ raw(data).each_with_index do |byte, i|
6
+ if i != 0 and i%16 == 0
7
+ puts text # takes care of \n
8
+ text = " "
9
+ end
10
+ print "%08x: " % [i] if i == 0 or i%16 == 0
11
+ print "#{byte} "
12
+ text += "%s" % [ byte.hex.chr.gsub(/[^[:print:]]/,'.') ]
13
+ end
14
+ end
15
+
16
+ def self.raw(data)
17
+ data.bytes.each.inject([]) { |output, byte| output << "%02x" % [byte.ord] }
5
18
  end
6
19
 
7
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexify
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrzej Dyjak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Turning data blobs into hex, one dump at a time.
14
14
  email: dyjakan@gmail.com