nxxd 1.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68a908962e81a416580c2987b7523f755e85e1963c20908420fb579710b6a865
4
- data.tar.gz: b18d9db546926037e9646a22e6c8394fd6d4ff86ad048b8be22a697d07698a87
3
+ metadata.gz: 685050d033e011d2247f30c73a30f0e2c96b6b25627bc7802a8b55c74b627080
4
+ data.tar.gz: c1036f1b327e53e1df7dd3e02c0667ceb98c17e3ede00e6f3a6a3392df73d5f4
5
5
  SHA512:
6
- metadata.gz: d941c8d1202b8bcbf0b1b0507216665e1c1e81035ff224861e6183d8a82b4354b701a3231e14803c9e7d934dc75cbb1dd8d6210ca46c36f8275c3234d34a25af
7
- data.tar.gz: abd20b6a161993d5ab0d8047623c8d137b7eec56512f72269a942feae25521ecd9549faceec3276e4df654008a84dcdf4c37b1c000ef5e473a74251850307380
6
+ metadata.gz: 72c1a0197350fb05b79154fa96d1b6b3a9081d4c8f644c10e2cfbd7641b76794c457566ceaaa192e8157b98b62912953f61ec21ea34eaf24ab347fcf24fa7830
7
+ data.tar.gz: c268077a3660aa76323673d17fffeb48424c36d31767c55bfd243b68e05dddb0f91550dca12a26f0391ae65f5d585fac92d19aacaa0a0e5edcf0770fe83ddd36
data/README.md CHANGED
@@ -55,7 +55,7 @@ nxxd -i someimage.png
55
55
  Get help.
56
56
 
57
57
  ```bash
58
- nxxd -h
58
+ nxxd -h
59
59
  ```
60
60
 
61
61
 
@@ -147,4 +147,5 @@ highlighting included in this package [xxd.vim](./vim/syntax/xxd.vim).
147
147
 
148
148
  * (C) 2025 Bertram Scharpf <software@bertram-scharpf.de>
149
149
  * License: [BSD-2-Clause+](./LICENSE)
150
+ * Repository: [ruby-nxxd](https://github.com/BertramScharpf/ruby-nxxd)
150
151
 
data/bin/nxxd CHANGED
@@ -18,6 +18,7 @@ module Nxxd
18
18
  "r" => [ :reverse, true, "Reverse operation, pack"],
19
19
  "o" => [ :output, :NAME, "Output file (- = stdout)"],
20
20
  "output" => "o",
21
+ "n" => [ :noclobber, true, "Don't overwrite existing files"],
21
22
  "f" => [ :full, true, "Full output (no squeeze)"],
22
23
  "full" => "f",
23
24
  "a" => [ :full, false, "Abbreviate (squeeze duplicate lines)"],
@@ -148,10 +149,7 @@ module Nxxd
148
149
  def initialize params
149
150
  o = Options.new params
150
151
  @opts, @args = o.opts, o.args
151
- @inputs = []
152
- @inputs.push @args.shift
153
- @output = (@opts.delete :output) || @args.pop
154
- @inputs.push @args.shift until @args.empty?
152
+ @output = (@opts.delete :output) || last_arg_if_not_existing
155
153
  end
156
154
 
157
155
  def run
@@ -179,6 +177,9 @@ module Nxxd
179
177
  rescue Interrupt
180
178
  $stderr.puts "Interrupted."
181
179
  1
180
+ rescue RuntimeError
181
+ $stderr.puts "Runtime Error: #$!"
182
+ 1
182
183
  rescue
183
184
  $stderr.puts "Error: #$! (#{$!.class})"
184
185
  1
@@ -186,9 +187,14 @@ module Nxxd
186
187
 
187
188
  private
188
189
 
190
+ def last_arg_if_not_existing
191
+ return if File.exist? @args.last
192
+ @args.pop
193
+ end
194
+
189
195
  def open_inputs
190
196
  plain = @opts.delete :plain
191
- @inputs.each do |i|
197
+ @args.each do |i|
192
198
  i = nil if i == "-"
193
199
  if i then
194
200
  @opts[ :input] = i unless plain or @opts[ :reverse]
@@ -205,9 +211,12 @@ module Nxxd
205
211
  end
206
212
 
207
213
  def open_output
214
+ nc = @opts.delete :noclobber
208
215
  o = @output unless @output == "-"
209
216
  if o then
210
- File.open o, "w" do |o| yield o end
217
+ mode = "w"
218
+ mode << "x" if nc
219
+ File.open o, mode do |f| yield f end
211
220
  else
212
221
  yield $stdout
213
222
  end
data/lib/nxxd/nvim.rb CHANGED
@@ -140,12 +140,12 @@ module Nxxd
140
140
  public
141
141
 
142
142
  def feed a, range
143
+ $vim.command "#{range.last}"
143
144
  popen a do |ro,re|
145
+ $vim.put [ ""], "l", true, true
144
146
  r = Neovim::Lines.new $vim.get_current_buf, range
145
147
  Nxxd::Dump.reverse r, ro, consecutive: true
146
148
  ro.close_write
147
- $vim.command "#{range.last}"
148
- $vim.put [ ""], "l", true, true
149
149
  ro.each_line { |l|
150
150
  l.chomp!
151
151
  $vim.put [ l], "l", false, true
@@ -154,6 +154,8 @@ module Nxxd
154
154
  l.chomp!
155
155
  $vim.put [ "# #{l}"], "l", false, true
156
156
  }
157
+ rescue
158
+ $vim.put [ "# #{$!.class}: #$!"], "l", false, true
157
159
  end
158
160
  $?.success? or $vim.put [ "### Exit code: #{$?.exitstatus}"], "l", false, true
159
161
  end
data/lib/nxxd/version.rb CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  module Nxxd
6
6
 
7
- VERSION = "1.1".freeze
8
- AUTHOR = "(C) 2025 Bertram Scharpf <software@bertram-scharpf.de>"
7
+ VERSION = "1.3".freeze
8
+ AUTHOR = "(C) 2026 Bertram Scharpf <software@bertram-scharpf.de>"
9
9
  LICENSE = "BSD-2-Clause+"
10
10
 
11
11
  end
data/lib/nxxd.rb CHANGED
@@ -99,7 +99,7 @@ module Nxxd
99
99
  consecutive and
100
100
  raise "Addressless undump doesn't allow repeat specifications."
101
101
  repeat = true
102
- when /^(?:(\h+):)?\s*((?:\h\h ?)*)/ then
102
+ when /^(?:(\h+):)?\s*((?:\h\h ?)*)((?: |\t).*)?$/ then
103
103
  addr, nibs = $~.captures
104
104
  if !consecutive && addr then
105
105
  addr = $1.to_i 0x10
@@ -116,7 +116,7 @@ module Nxxd
116
116
  r = (nibs.scan /\h\h/).map { |x| x.to_i 0x10 }.pack "C*"
117
117
  o.write r
118
118
  else
119
- raise "Uninterpretable hex dump: #{l.chomp}"
119
+ raise "Uninterpretable hex dump: #{l.inspect}"
120
120
  end
121
121
  }
122
122
  output
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nxxd
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: 'Yet another Xxd reimplementation.
13
13
 
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements:
47
47
  - Just Ruby
48
- rubygems_version: 3.6.3
48
+ rubygems_version: 3.7.1
49
49
  specification_version: 4
50
50
  summary: Hex Dump Tool
51
51
  test_files: []