zhexdump 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ZHexdump
2
2
 
3
- A highly flexible hexdump implementation.
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
@@ -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
@@ -88,6 +88,10 @@ end # module ZHexdump
88
88
 
89
89
  Zhexdump = ZHexdump
90
90
 
91
+ class String
92
+ include ZHexdump
93
+ end
94
+
91
95
  if $0 == __FILE__
92
96
  h = {}
93
97
  case ARGV.size
@@ -1,3 +1,3 @@
1
1
  module ZHexdump
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zhexdump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: