zhexdump 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zhexdump/version.rb +1 -1
- data/lib/zhexdump.rb +18 -9
- data/spec/hexdump_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87be9581b8556e6969275cb73e07ff353805db106f1f741bb522a941db276919
|
4
|
+
data.tar.gz: 0f75b82fe5bb212b0f4ad29d9aea29f89b62f21de3fabc7496c5eb75a387b1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc327641290592b335173fc7385ef73344f0f5f45bad467f25e7edc5a20a130a0f5a4daf54888932c8084fe500823446ed69676c286fa1d48fc199310a92c5c
|
7
|
+
data.tar.gz: 0231db65834152f9a9afce551a689a4a786c6a77863acf981929054db6254e8e96f74df59e4aa5e3a8c8c18f5c289107f819abb0b84405e10cf096140fb9eba3
|
data/lib/zhexdump/version.rb
CHANGED
data/lib/zhexdump.rb
CHANGED
@@ -19,7 +19,15 @@ module ZHexdump
|
|
19
19
|
r
|
20
20
|
end
|
21
21
|
|
22
|
+
@defaults = {}
|
23
|
+
|
22
24
|
class << self
|
25
|
+
attr_accessor :defaults
|
26
|
+
|
27
|
+
def _get_param(h, key, default)
|
28
|
+
h[key] || defaults[key] || default
|
29
|
+
end
|
30
|
+
|
23
31
|
def dump data, h = {}
|
24
32
|
offset = h.fetch(:offset, 0)
|
25
33
|
dedup = h.fetch(:dedup, true)
|
@@ -30,13 +38,13 @@ module ZHexdump
|
|
30
38
|
offset = 0
|
31
39
|
end
|
32
40
|
|
33
|
-
add = h
|
34
|
-
size = h
|
35
|
-
tail = h
|
36
|
-
width = h
|
37
|
-
output = h
|
38
|
-
indent = h
|
39
|
-
offset_format = h
|
41
|
+
add = _get_param(h, :add, 0)
|
42
|
+
size = _get_param(h, :size, data.size-offset)
|
43
|
+
tail = _get_param(h, :tail, "\n")
|
44
|
+
width = _get_param(h, :width, 16)
|
45
|
+
output = _get_param(h, :output, $stdout)
|
46
|
+
indent = _get_param(h, :indent, 0)
|
47
|
+
offset_format = _get_param(h, :offset_format, "%08x: ")
|
40
48
|
|
41
49
|
indent = ' ' * indent
|
42
50
|
size = data.size-offset if size+offset > data.size
|
@@ -47,8 +55,9 @@ module ZHexdump
|
|
47
55
|
width.times do |i|
|
48
56
|
hex << ' ' if i%8==0 && i>0
|
49
57
|
if c = ((size > 0) && data[offset+i])
|
50
|
-
|
51
|
-
|
58
|
+
ord = c.ord
|
59
|
+
hex << "%02x " % ord
|
60
|
+
ascii << (ord == 0 ? ' ' : ((32..126).include?(ord) ? c : '.'))
|
52
61
|
else
|
53
62
|
hex << ' '
|
54
63
|
ascii << ' '
|
data/spec/hexdump_spec.rb
CHANGED
@@ -59,10 +59,10 @@ describe ZHexdump do
|
|
59
59
|
s = ''
|
60
60
|
ZHexdump.dump data, :output => s, :indent => 2
|
61
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
|
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
64
|
a[2].should == " *"
|
65
|
-
a[3].should == " 00000060: 00 00 00 00 00 00 00 00 00 00
|
65
|
+
a[3].should == " 00000060: 00 00 00 00 00 00 00 00 00 00 | |"
|
66
66
|
end
|
67
67
|
|
68
68
|
it "adds :add to offset shown" do
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,6 @@ require File.join(File.dirname(__FILE__), '../lib/zhexdump.rb')
|
|
2
2
|
|
3
3
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
4
4
|
RSpec.configure do |config|
|
5
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
5
|
config.run_all_when_everything_filtered = true
|
7
6
|
#config.filter_run :focus
|
8
7
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zhexdump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey "Zed" Zaikin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
|
-
rubygems_version: 3.5.
|
64
|
+
rubygems_version: 3.5.16
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: A highly flexible hexdump implementation.
|