hexdump 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +31 -0
- data/.gitignore +4 -2
- data/ChangeLog.md +5 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +7 -32
- data/gemspec.yml +1 -3
- data/lib/hexdump/dumper.rb +1 -1
- data/lib/hexdump/hexdump.rb +3 -3
- data/lib/hexdump/version.rb +1 -1
- data/spec/dumper_spec.rb +33 -33
- data/spec/extensions_spec.rb +4 -4
- data/spec/hexdump_spec.rb +5 -3
- data/spec/spec_helper.rb +0 -1
- metadata +19 -54
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: faba56a33b697742b30ee19df9e85ae6295f38ada5d3785c4facae5d5b7d9a84
|
4
|
+
data.tar.gz: c4347bfbd5347c53824b04dd617a07ae66dbe89e1b5494cbcf6ea05f16eaeb02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c2904b21732bbdfc99205113cfaaf35f508e0ccc76db1beed57d8204c86f7472f0b9e15305f0f4a74f6db13fc41d4aa7a7f15743db06bad1dfbc064798ae0813
|
7
|
+
data.tar.gz: 7b4f9802586c41e0f6e994c84951432854f06e5a48ed611e80e1d4f03ec38037707a919c18e8412fb3876789494ee8551b98b703b697ac435ee70ea080dc013d
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: ['**']
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- 2.4
|
17
|
+
- 2.5
|
18
|
+
- 2.6
|
19
|
+
- 2.7
|
20
|
+
- jruby
|
21
|
+
name: Ruby ${{ matrix.ruby }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
- name: Install dependencies
|
29
|
+
run: bundle install --jobs 4 --retry 3
|
30
|
+
- name: Run tests
|
31
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
data/Gemfile
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,38 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'rake'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
require 'rubygems/tasks'
|
3
|
+
require 'rubygems/tasks'
|
4
|
+
Gem::Tasks.new
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
|
12
|
-
end
|
13
|
-
|
14
|
-
begin
|
15
|
-
gem 'rspec', '~> 2.4'
|
16
|
-
require 'rspec/core/rake_task'
|
17
|
-
|
18
|
-
RSpec::Core::RakeTask.new
|
19
|
-
rescue LoadError => e
|
20
|
-
task :spec do
|
21
|
-
abort "Please run `gem install rspec` to install RSpec."
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
task :test => :spec
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
task :test => :spec
|
26
9
|
task :default => :spec
|
27
10
|
|
28
|
-
|
29
|
-
|
30
|
-
require 'yard'
|
31
|
-
|
32
|
-
YARD::Rake::YardocTask.new
|
33
|
-
rescue LoadError => e
|
34
|
-
task :yard do
|
35
|
-
abort "Please run `gem install yard` to install YARD."
|
36
|
-
end
|
37
|
-
end
|
11
|
+
require 'yard'
|
12
|
+
YARD::Rake::YardocTask.new
|
38
13
|
task :doc => :yard
|
data/gemspec.yml
CHANGED
data/lib/hexdump/dumper.rb
CHANGED
data/lib/hexdump/hexdump.rb
CHANGED
@@ -45,7 +45,7 @@ module Hexdump
|
|
45
45
|
# @option options [Boolean] :ascii (false)
|
46
46
|
# Print ascii characters when possible.
|
47
47
|
#
|
48
|
-
# @option options [#<<] :output (
|
48
|
+
# @option options [#<<] :output ($stdout)
|
49
49
|
# The output to print the hexdump to.
|
50
50
|
#
|
51
51
|
# @yield [index,numeric,printable]
|
@@ -68,8 +68,8 @@ module Hexdump
|
|
68
68
|
# the `:output` value does not support the `#<<` method or
|
69
69
|
# the `:base` value was unknown.
|
70
70
|
#
|
71
|
-
def
|
72
|
-
output = (options.delete(:output) ||
|
71
|
+
def self.dump(data,options={},&block)
|
72
|
+
output = (options.delete(:output) || $stdout)
|
73
73
|
dumper = Dumper.new(options)
|
74
74
|
|
75
75
|
if block
|
data/lib/hexdump/version.rb
CHANGED
data/spec/dumper_spec.rb
CHANGED
@@ -12,15 +12,15 @@ describe Hexdump::Dumper do
|
|
12
12
|
let(:data) { print_chars.join }
|
13
13
|
|
14
14
|
it "should only accept known :base values" do
|
15
|
-
|
15
|
+
expect {
|
16
16
|
described_class.new(data, :base => :foo)
|
17
|
-
}.
|
17
|
+
}.to raise_error(ArgumentError)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should only accept known :endian values" do
|
21
|
-
|
21
|
+
expect {
|
22
22
|
described_class.new(data, :endian => :foo)
|
23
|
-
}.
|
23
|
+
}.to raise_error(ArgumentError)
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "each_word" do
|
@@ -31,31 +31,31 @@ describe Hexdump::Dumper do
|
|
31
31
|
let(:custom_words) { [0x414241, 0x42] }
|
32
32
|
|
33
33
|
it "should check if the data defines '#each_byte'" do
|
34
|
-
|
34
|
+
expect {
|
35
35
|
subject.each_word(Object.new).to_a
|
36
|
-
}.
|
36
|
+
}.to raise_error(ArgumentError)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should iterate over each byte by default" do
|
40
|
-
subject.each_word(data).to_a.
|
40
|
+
expect(subject.each_word(data).to_a).to be == bytes
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should allow iterating over custom word-sizes" do
|
44
44
|
dumper = described_class.new(:word_size => 3)
|
45
45
|
|
46
|
-
dumper.each_word(data).to_a.
|
46
|
+
expect(dumper.each_word(data).to_a).to be == custom_words
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should iterate over little-endian words by default" do
|
50
50
|
dumper = described_class.new(:word_size => 2)
|
51
51
|
|
52
|
-
dumper.each_word(data).to_a.
|
52
|
+
expect(dumper.each_word(data).to_a).to be == shorts_le
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should iterate over big-endian words" do
|
56
56
|
dumper = described_class.new(:word_size => 2, :endian => :big)
|
57
57
|
|
58
|
-
dumper.each_word(data).to_a.
|
58
|
+
expect(dumper.each_word(data).to_a).to be == shorts_be
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -67,10 +67,10 @@ describe Hexdump::Dumper do
|
|
67
67
|
lines << [index, hex, print]
|
68
68
|
end
|
69
69
|
|
70
|
-
lines.length.
|
71
|
-
lines[0][0].
|
72
|
-
lines[0][1].
|
73
|
-
lines[0][2].
|
70
|
+
expect(lines.length).to be(1)
|
71
|
+
expect(lines[0][0]).to be == 0
|
72
|
+
expect(lines[0][1]).to be == hex_chars
|
73
|
+
expect(lines[0][2]).to be == print_chars
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should provide the index within the data for each line" do
|
@@ -81,7 +81,7 @@ describe Hexdump::Dumper do
|
|
81
81
|
indices << index
|
82
82
|
end
|
83
83
|
|
84
|
-
indices.
|
84
|
+
expect(indices).to be == [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should allow configuring the width, in bytes, of each line" do
|
@@ -92,7 +92,7 @@ describe Hexdump::Dumper do
|
|
92
92
|
widths << hex.length
|
93
93
|
end
|
94
94
|
|
95
|
-
widths.
|
95
|
+
expect(widths).to be == ([10] * 10)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should hexdump the remaining bytes" do
|
@@ -106,7 +106,7 @@ describe Hexdump::Dumper do
|
|
106
106
|
remainder = print
|
107
107
|
end
|
108
108
|
|
109
|
-
remainder.
|
109
|
+
expect(remainder).to be == chars
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should provide the hexadecimal characters for each line" do
|
@@ -117,7 +117,7 @@ describe Hexdump::Dumper do
|
|
117
117
|
chars += hex
|
118
118
|
end
|
119
119
|
|
120
|
-
chars.
|
120
|
+
expect(chars).to be == (hex_chars * 100)
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should allow printing ASCII characters in place of hex characters" do
|
@@ -128,7 +128,7 @@ describe Hexdump::Dumper do
|
|
128
128
|
chars += hex
|
129
129
|
end
|
130
130
|
|
131
|
-
chars.
|
131
|
+
expect(chars).to be == print_chars
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should provide the print characters for each line" do
|
@@ -139,7 +139,7 @@ describe Hexdump::Dumper do
|
|
139
139
|
chars += print
|
140
140
|
end
|
141
141
|
|
142
|
-
chars.
|
142
|
+
expect(chars).to be == (print_chars * 100)
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should map unprintable characters to '.'" do
|
@@ -150,7 +150,7 @@ describe Hexdump::Dumper do
|
|
150
150
|
chars += print
|
151
151
|
end
|
152
152
|
|
153
|
-
chars.
|
153
|
+
expect(chars).to be == (['.'] * unprintable.length)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should support dumping bytes in decimal format" do
|
@@ -161,7 +161,7 @@ describe Hexdump::Dumper do
|
|
161
161
|
chars += hex
|
162
162
|
end
|
163
163
|
|
164
|
-
chars.
|
164
|
+
expect(chars).to be == decimal_chars
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should support dumping bytes in octal format" do
|
@@ -172,7 +172,7 @@ describe Hexdump::Dumper do
|
|
172
172
|
chars += hex
|
173
173
|
end
|
174
174
|
|
175
|
-
chars.
|
175
|
+
expect(chars).to be == octal_chars
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should support dumping bytes in binary format" do
|
@@ -183,7 +183,7 @@ describe Hexdump::Dumper do
|
|
183
183
|
chars += hex
|
184
184
|
end
|
185
185
|
|
186
|
-
chars.
|
186
|
+
expect(chars).to be == binary_chars
|
187
187
|
end
|
188
188
|
|
189
189
|
context ":word_size" do
|
@@ -202,7 +202,7 @@ describe Hexdump::Dumper do
|
|
202
202
|
words += hex
|
203
203
|
end
|
204
204
|
|
205
|
-
words.
|
205
|
+
expect(words).to be == hex_words
|
206
206
|
end
|
207
207
|
|
208
208
|
it "should dump words in decimal" do
|
@@ -213,7 +213,7 @@ describe Hexdump::Dumper do
|
|
213
213
|
words += dec
|
214
214
|
end
|
215
215
|
|
216
|
-
words.
|
216
|
+
expect(words).to be == decimal_words
|
217
217
|
end
|
218
218
|
|
219
219
|
it "should dump words in octal" do
|
@@ -224,7 +224,7 @@ describe Hexdump::Dumper do
|
|
224
224
|
words += oct
|
225
225
|
end
|
226
226
|
|
227
|
-
words.
|
227
|
+
expect(words).to be == octal_words
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should dump words in binary" do
|
@@ -235,16 +235,16 @@ describe Hexdump::Dumper do
|
|
235
235
|
words += bin
|
236
236
|
end
|
237
237
|
|
238
|
-
words.
|
238
|
+
expect(words).to be == binary_words
|
239
239
|
end
|
240
240
|
end
|
241
241
|
end
|
242
242
|
|
243
243
|
describe "#dump" do
|
244
244
|
it "should check if the :output supports the '#<<' method" do
|
245
|
-
|
245
|
+
expect {
|
246
246
|
subject.dump(data,Object.new)
|
247
|
-
}.
|
247
|
+
}.to raise_error(ArgumentError)
|
248
248
|
end
|
249
249
|
|
250
250
|
it "should append each line of the hexdump to the output" do
|
@@ -252,9 +252,9 @@ describe Hexdump::Dumper do
|
|
252
252
|
|
253
253
|
subject.dump(data,lines)
|
254
254
|
|
255
|
-
lines.length.
|
256
|
-
lines[0].
|
257
|
-
lines[0].
|
255
|
+
expect(lines.length).to be(1)
|
256
|
+
expect(lines[0]).to include(hex_chars.join(' '))
|
257
|
+
expect(lines[0]).to include(print_chars.join)
|
258
258
|
end
|
259
259
|
end
|
260
260
|
end
|
data/spec/extensions_spec.rb
CHANGED
@@ -3,18 +3,18 @@ require 'hexdump/extensions'
|
|
3
3
|
|
4
4
|
describe "Hexdump extensions" do
|
5
5
|
it "should include Hexdump into String" do
|
6
|
-
String.
|
6
|
+
expect(String).to include(Hexdump)
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should include Hexdump into StringIO" do
|
10
|
-
StringIO.
|
10
|
+
expect(StringIO).to include(Hexdump)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should include Hexdump into IO" do
|
14
|
-
IO.
|
14
|
+
expect(IO).to include(Hexdump)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should define File.hexdump" do
|
18
|
-
File.
|
18
|
+
expect(File).to respond_to(:hexdump)
|
19
19
|
end
|
20
20
|
end
|
data/spec/hexdump_spec.rb
CHANGED
@@ -10,8 +10,10 @@ describe Hexdump do
|
|
10
10
|
subject do
|
11
11
|
obj = Object.new.extend(Hexdump)
|
12
12
|
|
13
|
-
|
14
|
-
bytes.each
|
13
|
+
each_byte = expect(obj).to receive(:each_byte)
|
14
|
+
bytes.each do |b|
|
15
|
+
each_byte = each_byte.and_yield(b)
|
16
|
+
end
|
15
17
|
|
16
18
|
obj
|
17
19
|
end
|
@@ -23,7 +25,7 @@ describe Hexdump do
|
|
23
25
|
chars += hex
|
24
26
|
end
|
25
27
|
|
26
|
-
chars.
|
28
|
+
expect(chars).to be == hex_chars
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,64 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexdump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Postmodern
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0
|
19
|
+
version: '2.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
|
-
version: '0
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '2.4'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
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
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.7'
|
54
|
-
type: :development
|
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'
|
26
|
+
version: '2.0'
|
62
27
|
description: Simple and Fast hexdumping for Ruby.
|
63
28
|
email: postmodern.mod3@gmail.com
|
64
29
|
executables: []
|
@@ -68,12 +33,14 @@ extra_rdoc_files:
|
|
68
33
|
- LICENSE.txt
|
69
34
|
- README.md
|
70
35
|
files:
|
71
|
-
- .document
|
72
|
-
- .gemtest
|
73
|
-
- .
|
74
|
-
- .
|
75
|
-
- .
|
36
|
+
- ".document"
|
37
|
+
- ".gemtest"
|
38
|
+
- ".github/workflows/ruby.yml"
|
39
|
+
- ".gitignore"
|
40
|
+
- ".rspec"
|
41
|
+
- ".yardopts"
|
76
42
|
- ChangeLog.md
|
43
|
+
- Gemfile
|
77
44
|
- LICENSE.txt
|
78
45
|
- README.md
|
79
46
|
- Rakefile
|
@@ -96,26 +63,24 @@ files:
|
|
96
63
|
homepage: https://github.com/postmodern/hexdump#readme
|
97
64
|
licenses:
|
98
65
|
- MIT
|
66
|
+
metadata: {}
|
99
67
|
post_install_message:
|
100
68
|
rdoc_options: []
|
101
69
|
require_paths:
|
102
70
|
- lib
|
103
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
72
|
requirements:
|
106
|
-
- -
|
73
|
+
- - ">="
|
107
74
|
- !ruby/object:Gem::Version
|
108
75
|
version: 1.8.7
|
109
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
77
|
requirements:
|
112
|
-
- -
|
78
|
+
- - ">="
|
113
79
|
- !ruby/object:Gem::Version
|
114
80
|
version: '0'
|
115
81
|
requirements: []
|
116
|
-
|
117
|
-
rubygems_version: 1.8.24
|
82
|
+
rubygems_version: 3.1.4
|
118
83
|
signing_key:
|
119
|
-
specification_version:
|
84
|
+
specification_version: 4
|
120
85
|
summary: Hexdump Strings and IO objects.
|
121
86
|
test_files: []
|