zhexdump 0.0.1 → 0.0.2
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.
- data/README.md +19 -1
- data/README.md.tpl +11 -0
- data/lib/zhexdump.rb +4 -0
- data/lib/zhexdump/version.rb +1 -1
- data/spec/hexdump_spec.rb +19 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ZHexdump
|
2
2
|
|
3
|
-
A
|
3
|
+
A very flexible hexdump implementation.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -39,6 +39,24 @@ Or install it yourself as:
|
|
39
39
|
END
|
40
40
|
```
|
41
41
|
|
42
|
+
### String#hexdump
|
43
|
+
```ruby
|
44
|
+
"foobar".hexdump
|
45
|
+
|
46
|
+
# output:
|
47
|
+
00000000: 66 6f 6f 62 61 72 |foobar |
|
48
|
+
```
|
49
|
+
|
50
|
+
### String#to_hexdump
|
51
|
+
```ruby
|
52
|
+
s = 32.upto(63).map(&:chr).join
|
53
|
+
puts s.to_hexdump
|
54
|
+
|
55
|
+
# output:
|
56
|
+
00000000: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&'()*+,-./|
|
57
|
+
00000010: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |0123456789:;<=>?|
|
58
|
+
```
|
59
|
+
|
42
60
|
### Custom width
|
43
61
|
```ruby
|
44
62
|
ZHexdump.dump "abc123"*2, :width => 3
|
data/README.md.tpl
CHANGED
@@ -30,6 +30,17 @@ Or install it yourself as:
|
|
30
30
|
puts "START\n#{s}END"
|
31
31
|
```
|
32
32
|
|
33
|
+
### String#hexdump
|
34
|
+
```ruby
|
35
|
+
"foobar".hexdump
|
36
|
+
```
|
37
|
+
|
38
|
+
### String#to_hexdump
|
39
|
+
```ruby
|
40
|
+
s = 32.upto(63).map(&:chr).join
|
41
|
+
puts s.to_hexdump
|
42
|
+
```
|
43
|
+
|
33
44
|
### Custom width
|
34
45
|
```ruby
|
35
46
|
ZHexdump.dump "abc123"*2, :width => 3
|
data/lib/zhexdump.rb
CHANGED
data/lib/zhexdump/version.rb
CHANGED
data/spec/hexdump_spec.rb
CHANGED
@@ -139,4 +139,23 @@ describe ZHexdump do
|
|
139
139
|
end
|
140
140
|
s.should == "00000000: 66 6f 6f |xxx |\n"
|
141
141
|
end
|
142
|
+
|
143
|
+
it "String#hexdump dumps to stdout" do
|
144
|
+
data = "foo"
|
145
|
+
io = StringIO.new
|
146
|
+
begin
|
147
|
+
saved_stdout, $> = $>, io
|
148
|
+
data.hexdump
|
149
|
+
ensure
|
150
|
+
$> = saved_stdout
|
151
|
+
end
|
152
|
+
|
153
|
+
io.rewind
|
154
|
+
io.read.should == "00000000: 66 6f 6f |foo |\n"
|
155
|
+
end
|
156
|
+
|
157
|
+
it "String#to_hexdump dumps to a new string" do
|
158
|
+
data = "foo"
|
159
|
+
data.to_hexdump.should == "00000000: 66 6f 6f |foo |\n"
|
160
|
+
end
|
142
161
|
end
|