hexdump 0.3.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +5 -6
  3. data/.gitignore +1 -0
  4. data/.yardopts +1 -1
  5. data/ChangeLog.md +79 -6
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +500 -137
  9. data/benchmark.rb +29 -22
  10. data/gemspec.yml +2 -1
  11. data/hexdump.gemspec +1 -4
  12. data/lib/hexdump/chars.rb +46 -0
  13. data/lib/hexdump/core_ext/file.rb +68 -6
  14. data/lib/hexdump/core_ext/io.rb +2 -2
  15. data/lib/hexdump/core_ext/kernel.rb +5 -0
  16. data/lib/hexdump/core_ext/string.rb +2 -2
  17. data/lib/hexdump/core_ext/string_io.rb +2 -2
  18. data/lib/hexdump/core_ext.rb +5 -4
  19. data/lib/hexdump/format_string.rb +43 -0
  20. data/lib/hexdump/hexdump.rb +766 -75
  21. data/lib/hexdump/mixin.rb +192 -0
  22. data/lib/hexdump/module_methods.rb +132 -0
  23. data/lib/hexdump/numeric/binary.rb +55 -0
  24. data/lib/hexdump/numeric/char_or_int.rb +95 -0
  25. data/lib/hexdump/numeric/decimal.rb +56 -0
  26. data/lib/hexdump/numeric/exceptions.rb +11 -0
  27. data/lib/hexdump/numeric/hexadecimal.rb +59 -0
  28. data/lib/hexdump/numeric/octal.rb +55 -0
  29. data/lib/hexdump/numeric.rb +5 -0
  30. data/lib/hexdump/reader.rb +313 -0
  31. data/lib/hexdump/theme/ansi.rb +82 -0
  32. data/lib/hexdump/theme/rule.rb +159 -0
  33. data/lib/hexdump/theme.rb +61 -0
  34. data/lib/hexdump/type.rb +233 -0
  35. data/lib/hexdump/types.rb +108 -0
  36. data/lib/hexdump/version.rb +1 -1
  37. data/lib/hexdump.rb +14 -3
  38. data/spec/chars_spec.rb +76 -0
  39. data/spec/core_ext_spec.rb +10 -6
  40. data/spec/format_string_spec.rb +22 -0
  41. data/spec/hexdump_class_spec.rb +1708 -0
  42. data/spec/hexdump_module_spec.rb +23 -0
  43. data/spec/mixin_spec.rb +37 -0
  44. data/spec/numeric/binary_spec.rb +239 -0
  45. data/spec/numeric/char_or_int_spec.rb +210 -0
  46. data/spec/numeric/decimal_spec.rb +317 -0
  47. data/spec/numeric/hexadecimal_spec.rb +320 -0
  48. data/spec/numeric/octal_spec.rb +239 -0
  49. data/spec/reader_spec.rb +866 -0
  50. data/spec/spec_helper.rb +2 -0
  51. data/spec/theme/ansi_spec.rb +242 -0
  52. data/spec/theme/rule_spec.rb +199 -0
  53. data/spec/theme_spec.rb +94 -0
  54. data/spec/type_spec.rb +317 -0
  55. data/spec/types_spec.rb +904 -0
  56. metadata +42 -12
  57. data/.gemtest +0 -0
  58. data/lib/hexdump/dumper.rb +0 -419
  59. data/lib/hexdump/extensions.rb +0 -2
  60. data/spec/dumper_spec.rb +0 -329
  61. data/spec/hexdump_spec.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc17566453285686c384ffb48945dfa526b3d4ea24a3edec8b193540ec40fead
4
- data.tar.gz: cfd9d433a9d11d85b43cd98a46e4b8c1aa67dcc572bd0ebfd7771469bbc315ed
3
+ metadata.gz: 7f797d519e67c6284088b0052bc49a75b7fb7b7588d1cdc8b01d017039272c77
4
+ data.tar.gz: d1920db1ac10b3b2d07bcc3a5423f0764751eb6d2ac64e2e5ddb09ed14cf6e4d
5
5
  SHA512:
6
- metadata.gz: bcc397a847ff0d4b9cfef884d6c8c97ed344cbded5242cfeccd2e6e61dc755a4dfb3ac20ddfc65d66f1428dce3ba36ab46858c9c2fdb2e43905b73c4f39e0c10
7
- data.tar.gz: 3917cbf496621c7ddd8e9aec840be04b1836145f082fa0eefe016438cba570cda39013becd7a07fefdb8e4a0c1e9a13b17690f238da468ed528792c043e1c1f4
6
+ metadata.gz: a2e74dcd20c447a3ce959a7af67b65bcaa95a1805c56d9ea205b106d6a04547ff8dd642ae94b5c09213c5356222d7818782805dd38ad7d4b37b6254c9047c218
7
+ data.tar.gz: b70d82e23d3eeab44dcec8e617198fad89cec5052a37d421d8bdc9ffaf128af6a03a0babca98105c9a8ac1c92406fe956c01426c292be56524a9ad41b79417cd
@@ -9,16 +9,15 @@ jobs:
9
9
  fail-fast: false
10
10
  matrix:
11
11
  ruby:
12
- - 2.4
13
- - 2.5
14
- - 2.6
15
- - 2.7
16
- - 3.0
12
+ - '3.0'
13
+ - '3.1'
14
+ - '3.2'
15
+ - '3.3'
17
16
  - jruby
18
17
  - truffleruby
19
18
  name: Ruby ${{ matrix.ruby }}
20
19
  steps:
21
- - uses: actions/checkout@v2
20
+ - uses: actions/checkout@v4
22
21
  - name: Set up Ruby
23
22
  uses: ruby/setup-ruby@v1
24
23
  with:
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /Gemfile.lock
2
+ /coverage
2
3
  /doc/
3
4
  /pkg/
4
5
  /vendor/bundle/
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --markup markdown --title "hexdump Documentation" --protected --quiet
1
+ --markup markdown --title "hexdump Documentation" --protected
data/ChangeLog.md CHANGED
@@ -1,11 +1,84 @@
1
+ ### 1.0.1 / 2024-01-23
2
+
3
+ * Switched to using `require_relative` to improve load-times.
4
+ * Correctly alias `:long`/`:ulong` to `:int32`/`:uint32`.
5
+ * Disable ANSI styling in {Hexdump#hexdump} if the output is not a TTY.
6
+ * Removed the old `hexdump/extensions` file in favor of `hexdump/core_ext`.
7
+
8
+ ### 1.0.0 / 2021-08-31
9
+
10
+ * Added the ability to hexdump typed data. Available `type:`s are :
11
+ * `:char` - signed 8bit ASCII character
12
+ * `:uchar` - unsigned 8bit ASCII character
13
+ * `:int8` - signed 8bit integer
14
+ * `:uin8` / `:byte` - unsigned 8bit integer (default)
15
+ * `:int16` / `:short` - signed 16bit integer
16
+ * `:int16_le` / `:short_le` - signed 16bit integer (little endian)
17
+ * `:int16_be` / `:short_be` - signed 16bit integer (big endian)
18
+ * `:int16_ne` / `:short_ne` - signed 16bit integer (network endian)
19
+ * `:uint16` / `:ushort` - unsigned 16bit integer
20
+ * `:uint16_le` / `:ushort_le` - unsigned 16bit integer (little endian)
21
+ * `:uint16_be` / `:ushort_be` - unsigned 16bit integer (big endian)
22
+ * `:uint16_ne` / `:ushort_ne` - unsigned 16bit integer (network endian)
23
+ * `:int32` / `:int` / `:long` - signed 32bit integer
24
+ * `:int32_le` / `:int_le` / `:long_le` - signed 32bit integer (little endian)
25
+ * `:int32_be` / `:int_be` / `:long_be` - signed 32bit integer (big endian)
26
+ * `:int32_ne` / `:int_ne` / `:long_ne` - signed 32bit integer (network endian)
27
+ * `:uint32` / `:uint` / `:ulong` - unsigned 32bit integer
28
+ * `:uint32_le` / `:uint_le` / `:ulong_le` - unsigned 32bit integer (little endian)
29
+ * `:uint32_be` / `:uint_be` / `:ulong_be` - unsigned 32bit integer (big endian)
30
+ * `:uint32_ne` / `:uint_ne` / `:ulong_ne` - unsigned 32bit integer (network endian)
31
+ * `:int64` / `:long_long` - signed 64bit integer
32
+ * `:int64_le` / `:long_long_le` - signed 64bit integer (little endian)
33
+ * `:int64_be` / `:long_long_be` - signed 64bit integer (big endian)
34
+ * `:int64_ne` / `:long_long_ne` - signed 64bit integer (network endian)
35
+ * `:uint64` / `:ulong_long` - unsigned 64bit integer
36
+ * `:uint64_le` / `:ulong_long_le` - unsigned 64bit integer (little endian)
37
+ * `:uint64_be` / `:ulong_long_be` - unsigned 64bit integer (big endian)
38
+ * `:uint64_ne` / `ulong_long_ne` - unsigned 64bit integer (network endian)
39
+ * `:float` - single precision 32bit floating-point number
40
+ * `:float_le` - single precision 32bit floating-point number (little endian)
41
+ * `:float_be` - single precision 32bit floating-point number (big endian)
42
+ * `:float_ne` - single precision 32bit floating-point number (network endian)
43
+ * `:double` - double precision 64bit floating-point number
44
+ * `:double_le` - double precision 64bit floating-point number (little endian)
45
+ * `:double_be` - double precision 64bit floating-point number (big endian)
46
+ * `:double_ne` - double precision 64bit floating-point number (network endian)
47
+ * Added support for optionally skipping N bytes or reading at most N bytes of
48
+ data (ex: `offset: 10` and `length: 100`).
49
+ * Added support for optional zero-padding of the data so it aligns with the type
50
+ size (ex: `zero_pad: true`).
51
+ * Added support for displaying the index in a separate numeric base than the
52
+ numeric columns (ex: `index_base: 10, base: 2`). Defaults to base 16.
53
+ * Added support for omitting repeating rows with a `*` (ex: `repeating: true` or
54
+ `repeating: false` to disable).
55
+ * Added support for grouping columns together like GNU `hexdump -C` (ex:
56
+ `group_columns: 4`).
57
+ * Added support for grouping characters together (ex: `group_chars: 4`).
58
+ * Added support for grouping characters together to align with the type's size
59
+ (ex: `group_chars: :type`).
60
+ * Added support for displaying UTF-8 characters or other character encodings.
61
+ * Added support for disabling the characters column entirely
62
+ (ex: `chars_column: false`).
63
+ * Added support for ANSI styling and highlighting (ex: `style: {...}` and
64
+ `highlights: {...}`).
65
+ * Added {Hexdump::ModuleMethods} to provide a top-level
66
+ {Hexdump::ModuleMethods#hexdump hexdump} method.
67
+ * Include {Hexdump::ModuleMethods} into {Kernel} by default.
68
+ * Added preliminary truffleruby support.
69
+ * Only issue was https://github.com/oracle/truffleruby/issues/2426
70
+ * `hexdump` methods now accept a block for configuring the hexdump instance.
71
+ * Renamed `Hexdump::Dumper` to {Hexdump::Hexdump}.
72
+ * Renamed the `:width` option to `:columns`.
73
+
1
74
  ### 0.3.0 / 2021-04-10
2
75
 
3
76
  * Require Ruby >= 2.0.0.
4
77
  * Added support for Ruby 3.0.
5
- * {Hexdump.dump}, {Hexdump#dump}, and {Hexdump::Dumper#initialize} now accept
78
+ * {Hexdump.dump}, {Hexdump#dump}, and `Hexdump::Dumper#initialize` now accept
6
79
  keyword arguments.
7
- * {Hexdump::Dumper#each} now returns the total number of bytes read.
8
- * {Hexdump::Dumper#dump} now prints the final number of bytes read on the last
80
+ * `Hexdump::Dumper#each` now returns the total number of bytes read.
81
+ * `Hexdump::Dumper#dump` now prints the final number of bytes read on the last
9
82
  line.
10
83
  * Micro-optimizations to improve performance on JRuby and TruffleRuby.
11
84
 
@@ -22,7 +95,7 @@
22
95
  ### 0.2.2 / 2012-05-27
23
96
 
24
97
  * Added {Hexdump::VERSION}.
25
- * Rescue `RangeError`s in {Hexdump::Dumper#format_printable}.
98
+ * Rescue `RangeError`s in `Hexdump::Dumper#format_printable`.
26
99
  * Fixed a typo in `benchmarks/hexdump.rb` (thanks ColMcp).
27
100
  * Fixed a typo in Source URL, in the README (thanks Lawrence Woodman).
28
101
  * Documented the `:endian` option for {Hexdump.dump}.
@@ -31,12 +104,12 @@
31
104
 
32
105
  ### 0.2.1 / 2011-06-11
33
106
 
34
- * Fixed a major bug in {Hexdump::Dumper#dump}, where the line buffers
107
+ * Fixed a major bug in `Hexdump::Dumper#dump`, where the line buffers
35
108
  were not being cleared.
36
109
 
37
110
  ### 0.2.0 / 2011-06-11
38
111
 
39
- * Added {Hexdump::Dumper}.
112
+ * Added `Hexdump::Dumper`.
40
113
  * Added support for hexdumping 1, 2, 4, 8 byte words.
41
114
  * Added support for hexdumping Little and Big Endian words.
42
115
  * Optimized the hexdump algorithm to not use Arrays, use a lookup table
data/Gemfile CHANGED
@@ -6,6 +6,9 @@ group :development do
6
6
  gem 'rake'
7
7
  gem 'rubygems-tasks', '~> 0.2'
8
8
  gem 'rspec', '~> 3.0'
9
+ gem 'simplecov', '~> 0.20'
9
10
  gem 'kramdown'
11
+ gem 'redcarpet', platform: :mri
10
12
  gem 'yard', '~> 0.9'
13
+ gem 'yard-spellcheck', require: false
11
14
  end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2021 Hal Brodigan
1
+ Copyright (c) 2011-2024 Hal Brodigan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the