hexdump 0.2.1 → 0.2.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.
- data/.gitignore +2 -0
- data/.yardopts +1 -1
- data/ChangeLog.md +15 -0
- data/README.md +2 -2
- data/Rakefile +6 -6
- data/benchmarks/hexdump.rb +2 -2
- data/gemspec.yml +3 -4
- data/hexdump.gemspec +56 -11
- data/lib/hexdump.rb +1 -0
- data/lib/hexdump/dumper.rb +21 -13
- data/lib/hexdump/hexdump.rb +4 -0
- data/lib/hexdump/version.rb +4 -0
- metadata +64 -56
data/.gitignore
ADDED
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--markup markdown --title "hexdump Documentation" --protected
|
1
|
+
--markup markdown --title "hexdump Documentation" --protected --quiet
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
### 0.2.3 / 2012-05-28
|
2
|
+
|
3
|
+
* Fixed a typo in the gemspec, which incorrectly set
|
4
|
+
`required_rubygems_version` to the same value as `required_ruby_version`.
|
5
|
+
|
6
|
+
### 0.2.2 / 2012-05-27
|
7
|
+
|
8
|
+
* Added {Hexdump::VERSION}.
|
9
|
+
* Rescue `RangeError`s in {Hexdump::Dumper#format_printable}.
|
10
|
+
* Fixed a typo in `benchmarks/hexdump.rb` (thanks ColMcp).
|
11
|
+
* Fixed a typo in Source URL, in the README (thanks Lawrence Woodman).
|
12
|
+
* Documented the `:endian` option for {Hexdump.dump}.
|
13
|
+
* Replaced ore-tasks with
|
14
|
+
[rubygems-tasks](https://github.com/postmodern/rubygems-tasks#readme).
|
15
|
+
|
1
16
|
### 0.2.1 / 2011-06-11
|
2
17
|
|
3
18
|
* Fixed a major bug in {Hexdump::Dumper#dump}, where the line buffers
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# hexdump
|
2
2
|
|
3
|
-
* [
|
4
|
-
* [Issues](
|
3
|
+
* [Source](https://github.com/postmodern/hexdump)
|
4
|
+
* [Issues](https://github.com/postmodern/hexdump/issues)
|
5
5
|
* [Documentation](http://rubydoc.info/gems/hexdump/frames)
|
6
6
|
* [Email](mailto:postmodern.mod3 at gmail.com)
|
7
7
|
|
data/Rakefile
CHANGED
@@ -2,13 +2,13 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
|
4
4
|
begin
|
5
|
-
gem '
|
6
|
-
require '
|
5
|
+
gem 'rubygems-tasks', '~> 0.1'
|
6
|
+
require 'rubygems/tasks'
|
7
7
|
|
8
|
-
|
8
|
+
Gem::Tasks.new
|
9
9
|
rescue LoadError => e
|
10
|
-
|
11
|
-
|
10
|
+
warn e.message
|
11
|
+
warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
|
12
12
|
end
|
13
13
|
|
14
14
|
begin
|
@@ -26,7 +26,7 @@ task :test => :spec
|
|
26
26
|
task :default => :spec
|
27
27
|
|
28
28
|
begin
|
29
|
-
gem 'yard', '~> 0.
|
29
|
+
gem 'yard', '~> 0.7'
|
30
30
|
require 'yard'
|
31
31
|
|
32
32
|
YARD::Rake::YardocTask.new
|
data/benchmarks/hexdump.rb
CHANGED
@@ -26,11 +26,11 @@ Benchmark.bm(27) do |b|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
b.report('hexdump ascii=true (block)') do
|
29
|
-
Hexdump.dump(DATA, :
|
29
|
+
Hexdump.dump(DATA, :ascii => true) { |index,hex,print| }
|
30
30
|
end
|
31
31
|
|
32
32
|
b.report('hexdump ascii=true') do
|
33
|
-
Hexdump.dump(DATA, :
|
33
|
+
Hexdump.dump(DATA, :ascii => true, :output => OUTPUT)
|
34
34
|
end
|
35
35
|
|
36
36
|
[2, 4, 8].each do |word_size|
|
data/gemspec.yml
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
name: hexdump
|
2
|
-
version: 0.2.1
|
3
2
|
summary: Hexdump Strings and IO objects.
|
4
3
|
description: Simple and Fast hexdumping for Ruby.
|
5
4
|
license: MIT
|
6
5
|
authors: Postmodern
|
7
6
|
email: postmodern.mod3@gmail.com
|
8
|
-
homepage:
|
7
|
+
homepage: https://github.com/postmodern/hexdump#readme
|
9
8
|
has_yard: true
|
10
9
|
|
11
10
|
required_ruby_version: ">= 1.8.7"
|
12
11
|
|
13
12
|
development_dependencies:
|
14
|
-
|
13
|
+
rubygems-tasks: ~> 0.1
|
15
14
|
rspec: ~> 2.4
|
16
|
-
yard: ~> 0.
|
15
|
+
yard: ~> 0.7
|
data/hexdump.gemspec
CHANGED
@@ -1,15 +1,60 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gemspec = YAML.load_file('gemspec.yml')
|
7
|
+
|
8
|
+
gem.name = gemspec.fetch('name')
|
9
|
+
gem.version = gemspec.fetch('version') do
|
10
|
+
lib_dir = File.join(File.dirname(__FILE__),'lib')
|
11
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
12
|
+
|
13
|
+
require 'hexdump/version'
|
14
|
+
Hexdump::VERSION
|
15
|
+
end
|
16
|
+
|
17
|
+
gem.summary = gemspec['summary']
|
18
|
+
gem.description = gemspec['description']
|
19
|
+
gem.licenses = Array(gemspec['license'])
|
20
|
+
gem.authors = Array(gemspec['authors'])
|
21
|
+
gem.email = gemspec['email']
|
22
|
+
gem.homepage = gemspec['homepage']
|
23
|
+
|
24
|
+
glob = lambda { |patterns| gem.files & Dir[*patterns] }
|
25
|
+
|
26
|
+
gem.files = `git ls-files`.split($/)
|
27
|
+
gem.files = glob[gemspec['files']] if gemspec['files']
|
28
|
+
|
29
|
+
gem.executables = gemspec.fetch('executables') do
|
30
|
+
glob['bin/*'].map { |path| File.basename(path) }
|
6
31
|
end
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
32
|
+
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
33
|
+
|
34
|
+
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
35
|
+
gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
|
36
|
+
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
37
|
+
|
38
|
+
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
39
|
+
%w[ext lib].select { |dir| File.directory?(dir) }
|
40
|
+
})
|
41
|
+
|
42
|
+
gem.requirements = gemspec['requirements']
|
43
|
+
gem.required_ruby_version = gemspec['required_ruby_version']
|
44
|
+
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
45
|
+
gem.post_install_message = gemspec['post_install_message']
|
46
|
+
|
47
|
+
split = lambda { |string| string.split(/,\s*/) }
|
48
|
+
|
49
|
+
if gemspec['dependencies']
|
50
|
+
gemspec['dependencies'].each do |name,versions|
|
51
|
+
gem.add_dependency(name,split[versions])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if gemspec['development_dependencies']
|
56
|
+
gemspec['development_dependencies'].each do |name,versions|
|
57
|
+
gem.add_development_dependency(name,split[versions])
|
58
|
+
end
|
14
59
|
end
|
15
60
|
end
|
data/lib/hexdump.rb
CHANGED
data/lib/hexdump/dumper.rb
CHANGED
@@ -27,9 +27,9 @@ module Hexdump
|
|
27
27
|
# Format Strings for the various bases
|
28
28
|
FORMATS = {
|
29
29
|
:hexadecimal => proc { |width| "%.#{width}x" },
|
30
|
-
:decimal
|
31
|
-
:octal
|
32
|
-
:binary
|
30
|
+
:decimal => proc { |width| "%#{width}.d" },
|
31
|
+
:octal => proc { |width| "%.#{width}o" },
|
32
|
+
:binary => proc { |width| "%.#{width}b" }
|
33
33
|
}
|
34
34
|
|
35
35
|
# Character to represent unprintable characters
|
@@ -160,6 +160,10 @@ module Hexdump
|
|
160
160
|
# @option options [Integer] :width (16)
|
161
161
|
# The number of bytes to dump for each line.
|
162
162
|
#
|
163
|
+
# @option options [Integer] :endian (:little)
|
164
|
+
# The endianness that the bytes are organized in. Supported endianness
|
165
|
+
# include `:little` and `:big`.
|
166
|
+
#
|
163
167
|
# @option options [Integer] :word_size (1)
|
164
168
|
# The number of bytes within a word.
|
165
169
|
#
|
@@ -245,7 +249,7 @@ module Hexdump
|
|
245
249
|
end
|
246
250
|
|
247
251
|
if @word_size > 1
|
248
|
-
word
|
252
|
+
word = 0
|
249
253
|
count = 0
|
250
254
|
|
251
255
|
init_shift = if @endian == :big
|
@@ -269,7 +273,7 @@ module Hexdump
|
|
269
273
|
if count >= @word_size
|
270
274
|
yield word
|
271
275
|
|
272
|
-
word
|
276
|
+
word = 0
|
273
277
|
count = 0
|
274
278
|
shift = init_shift
|
275
279
|
end
|
@@ -316,13 +320,13 @@ module Hexdump
|
|
316
320
|
printable = []
|
317
321
|
|
318
322
|
each_word(data) do |word|
|
319
|
-
numeric
|
323
|
+
numeric << format_numeric(word)
|
320
324
|
printable << format_printable(word)
|
321
325
|
|
322
326
|
count += 1
|
323
327
|
|
324
328
|
if count >= @width
|
325
|
-
yield
|
329
|
+
yield index, numeric, printable
|
326
330
|
|
327
331
|
numeric.clear
|
328
332
|
printable.clear
|
@@ -334,7 +338,7 @@ module Hexdump
|
|
334
338
|
|
335
339
|
if count > 0
|
336
340
|
# yield the remaining data
|
337
|
-
yield
|
341
|
+
yield index, numeric, printable
|
338
342
|
end
|
339
343
|
end
|
340
344
|
|
@@ -365,11 +369,11 @@ module Hexdump
|
|
365
369
|
index = 0
|
366
370
|
count = 0
|
367
371
|
|
368
|
-
numeric
|
372
|
+
numeric = ''
|
369
373
|
printable = ''
|
370
374
|
|
371
375
|
each_word(data) do |word|
|
372
|
-
numeric
|
376
|
+
numeric << format_numeric(word) << ' '
|
373
377
|
printable << format_printable(word)
|
374
378
|
|
375
379
|
count += 1
|
@@ -377,11 +381,11 @@ module Hexdump
|
|
377
381
|
if count >= @width
|
378
382
|
output << sprintf(line_format,index,numeric,printable)
|
379
383
|
|
380
|
-
numeric
|
384
|
+
numeric = ''
|
381
385
|
printable = ''
|
382
386
|
|
383
387
|
index += (@width * @word_size)
|
384
|
-
count
|
388
|
+
count = 0
|
385
389
|
end
|
386
390
|
end
|
387
391
|
|
@@ -431,7 +435,11 @@ module Hexdump
|
|
431
435
|
if @word_size == 1
|
432
436
|
PRINTABLE[word]
|
433
437
|
elsif (RUBY_VERSION > '1.9.' && (word >= -2 && word <= 0x7fffffff))
|
434
|
-
|
438
|
+
begin
|
439
|
+
word.chr(Encoding::UTF_8)
|
440
|
+
rescue RangeError
|
441
|
+
UNPRINTABLE
|
442
|
+
end
|
435
443
|
else
|
436
444
|
UNPRINTABLE
|
437
445
|
end
|
data/lib/hexdump/hexdump.rb
CHANGED
@@ -30,6 +30,10 @@ module Hexdump
|
|
30
30
|
# @option options [Integer] :width (16)
|
31
31
|
# The number of bytes to dump for each line.
|
32
32
|
#
|
33
|
+
# @option options [Integer] :endian (:little)
|
34
|
+
# The endianness that the bytes are organized in. Supported endianness
|
35
|
+
# include `:little` and `:big`.
|
36
|
+
#
|
33
37
|
# @option options [Integer] :word_size (1)
|
34
38
|
# The number of bytes within a word.
|
35
39
|
#
|
metadata
CHANGED
@@ -1,64 +1,76 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexdump
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Postmodern
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
prerelease: false
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-05-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rubygems-tasks
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
18
|
+
requirements:
|
21
19
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.1'
|
24
22
|
type: :development
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
30
33
|
none: false
|
31
|
-
requirements:
|
34
|
+
requirements:
|
32
35
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.4'
|
35
38
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: yard
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.4'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
41
49
|
none: false
|
42
|
-
requirements:
|
50
|
+
requirements:
|
43
51
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.7'
|
46
54
|
type: :development
|
47
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
48
62
|
description: Simple and Fast hexdumping for Ruby.
|
49
|
-
email:
|
50
|
-
- postmodern.mod3@gmail.com
|
63
|
+
email: postmodern.mod3@gmail.com
|
51
64
|
executables: []
|
52
|
-
|
53
65
|
extensions: []
|
54
|
-
|
55
|
-
extra_rdoc_files:
|
56
|
-
- README.md
|
66
|
+
extra_rdoc_files:
|
57
67
|
- ChangeLog.md
|
58
68
|
- LICENSE.txt
|
59
|
-
|
69
|
+
- README.md
|
70
|
+
files:
|
60
71
|
- .document
|
61
72
|
- .gemtest
|
73
|
+
- .gitignore
|
62
74
|
- .rspec
|
63
75
|
- .yardopts
|
64
76
|
- ChangeLog.md
|
@@ -76,38 +88,34 @@ files:
|
|
76
88
|
- lib/hexdump/extensions/string.rb
|
77
89
|
- lib/hexdump/extensions/string_io.rb
|
78
90
|
- lib/hexdump/hexdump.rb
|
91
|
+
- lib/hexdump/version.rb
|
79
92
|
- spec/dumper_spec.rb
|
80
93
|
- spec/extensions_spec.rb
|
81
94
|
- spec/hexdump_spec.rb
|
82
95
|
- spec/spec_helper.rb
|
83
|
-
homepage:
|
84
|
-
licenses:
|
96
|
+
homepage: https://github.com/postmodern/hexdump#readme
|
97
|
+
licenses:
|
85
98
|
- MIT
|
86
99
|
post_install_message:
|
87
100
|
rdoc_options: []
|
88
|
-
|
89
|
-
require_paths:
|
101
|
+
require_paths:
|
90
102
|
- lib
|
91
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
104
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
96
108
|
version: 1.8.7
|
97
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
110
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version:
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
103
115
|
requirements: []
|
104
|
-
|
105
|
-
|
106
|
-
rubygems_version: 1.8.1
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.8.24
|
107
118
|
signing_key:
|
108
119
|
specification_version: 3
|
109
120
|
summary: Hexdump Strings and IO objects.
|
110
|
-
test_files:
|
111
|
-
- spec/dumper_spec.rb
|
112
|
-
- spec/hexdump_spec.rb
|
113
|
-
- spec/extensions_spec.rb
|
121
|
+
test_files: []
|