zhexdump 0.0.2 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/zhexdump/version.rb +1 -1
- data/lib/zhexdump.rb +12 -9
- data/spec/hexdump_spec.rb +12 -0
- metadata +14 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c0405a9a00093fb08a5ff3294e1636d3350e49c83f478c2d4e1fa1575b72bb83
|
4
|
+
data.tar.gz: 0cf51636f3344e94c0e9a5647fbe1cb9f54b1d134e0d22cd7c595d2f41a03552
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e117316024d5ecc48f7eefa79cff23603ef728959791c522a93aa50dafc50f05f202aeb17ee5994d2ebe9bd22c1d881840cfad3c6a392076c7aabd6da4f06b4d
|
7
|
+
data.tar.gz: c3d12f02963fa811e42d44f93a328eebb2a81964350b2f3edebd7666f4ef2122c1fd01488e05be2d690784dae86fbdb0c2d109f76d9d9d929360a4ab3d911171
|
data/lib/zhexdump/version.rb
CHANGED
data/lib/zhexdump.rb
CHANGED
@@ -30,12 +30,15 @@ module ZHexdump
|
|
30
30
|
offset = 0
|
31
31
|
end
|
32
32
|
|
33
|
-
add
|
34
|
-
size
|
35
|
-
tail
|
36
|
-
width
|
37
|
-
output
|
38
|
-
|
33
|
+
add = h[:add] || 0
|
34
|
+
size = h[:size] || (data.size-offset)
|
35
|
+
tail = h[:tail] || "\n"
|
36
|
+
width = h[:width] || 0x10 # row width, in bytes
|
37
|
+
output = h[:output] || $>
|
38
|
+
indent = h[:indent] || 0
|
39
|
+
offset_format = h[:offset_format] || "%08x: "
|
40
|
+
|
41
|
+
indent = ' ' * indent
|
39
42
|
size = data.size-offset if size+offset > data.size
|
40
43
|
|
41
44
|
prevhex = ''; c = nil; prevdup = false; start = offset
|
@@ -54,7 +57,7 @@ module ZHexdump
|
|
54
57
|
end
|
55
58
|
|
56
59
|
if dedup && hex == prevhex
|
57
|
-
row = "*"
|
60
|
+
row = indent + "*"
|
58
61
|
yield(row, offset+add, ascii) if block_given?
|
59
62
|
unless prevdup
|
60
63
|
output << "\n" if offset > start
|
@@ -62,7 +65,7 @@ module ZHexdump
|
|
62
65
|
end
|
63
66
|
prevdup = true
|
64
67
|
else
|
65
|
-
row = (show_offset ?
|
68
|
+
row = indent + (show_offset ? (offset_format % (offset + add)) : '') + hex
|
66
69
|
yield(row, offset+add, ascii) if block_given?
|
67
70
|
row << ' |' + ascii + "|"
|
68
71
|
output << "\n" if offset > start
|
@@ -75,7 +78,7 @@ module ZHexdump
|
|
75
78
|
break if size <= 0
|
76
79
|
end
|
77
80
|
if show_offset && prevdup
|
78
|
-
row =
|
81
|
+
row = indent + (offset_format % (offset + add))
|
79
82
|
yield(row) if block_given?
|
80
83
|
output << "\n" << row
|
81
84
|
end
|
data/spec/hexdump_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#coding: binary
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'stringio'
|
3
4
|
|
@@ -53,6 +54,17 @@ describe ZHexdump do
|
|
53
54
|
s.should == "00000002: 6f 62 61 |oba |\n"
|
54
55
|
end
|
55
56
|
|
57
|
+
it "respects :indent" do
|
58
|
+
data = 'foobar' + "\x00"*100
|
59
|
+
s = ''
|
60
|
+
ZHexdump.dump data, :output => s, :indent => 2
|
61
|
+
a = s.split("\n")
|
62
|
+
a[0].should == " 00000000: 66 6f 6f 62 61 72 00 00 00 00 00 00 00 00 00 00 |foobar..........|"
|
63
|
+
a[1].should == " 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|"
|
64
|
+
a[2].should == " *"
|
65
|
+
a[3].should == " 00000060: 00 00 00 00 00 00 00 00 00 00 |.......... |"
|
66
|
+
end
|
67
|
+
|
56
68
|
it "adds :add to offset shown" do
|
57
69
|
data = 'foo'*100
|
58
70
|
s = ''
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zhexdump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Andrey "Zed" Zaikin
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2024-06-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
description: A highly flexible hexdump implementation.
|
@@ -34,8 +31,8 @@ executables: []
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
- .gitignore
|
38
|
-
- .rspec
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
39
36
|
- Gemfile
|
40
37
|
- LICENSE.txt
|
41
38
|
- README.md
|
@@ -48,27 +45,25 @@ files:
|
|
48
45
|
- zhexdump.gemspec
|
49
46
|
homepage: ''
|
50
47
|
licenses: []
|
51
|
-
|
48
|
+
metadata: {}
|
49
|
+
post_install_message:
|
52
50
|
rdoc_options: []
|
53
51
|
require_paths:
|
54
52
|
- lib
|
55
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
54
|
requirements:
|
58
|
-
- -
|
55
|
+
- - ">="
|
59
56
|
- !ruby/object:Gem::Version
|
60
57
|
version: '0'
|
61
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
59
|
requirements:
|
64
|
-
- -
|
60
|
+
- - ">="
|
65
61
|
- !ruby/object:Gem::Version
|
66
62
|
version: '0'
|
67
63
|
requirements: []
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
specification_version: 3
|
64
|
+
rubygems_version: 3.5.6
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
72
67
|
summary: A highly flexible hexdump implementation.
|
73
68
|
test_files:
|
74
69
|
- spec/hexdump_spec.rb
|