cbor-diag 0.9.9 → 0.10.1

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: 54f6f772655e8d9e5c33d6f51030f4b51076f8ddb9a0dec7f778b679e6e0d13d
4
- data.tar.gz: 45327c30bf0ff893e38243fa511516267a91a9b60c3168a52b73b530e2e6ff52
3
+ metadata.gz: 56baddf10e207846f9ef83665454cf578d5ba570523d62f56a5912138096fded
4
+ data.tar.gz: 19f2e413f8be97389c6663c225d0ba3a5152e1732d600a26beb81a140b9ba346
5
5
  SHA512:
6
- metadata.gz: 47a70a70dbb3cf27f15048ee83f080b359778deada122840a40896f709941b46c8fe7169d333081de947ac94fdefdd415d0493cfceb0f3aa353cd723466cf8cd
7
- data.tar.gz: 160560be71a888c113e761bad1f3835b519221b6ed3075ef8c6565c428c89feb06e6cfdf2ea227de06c7d3c76e610ebdd7e794fdea9dc18c4b89e02ebd36b5fb
6
+ metadata.gz: 94ec9f6276a20a619ccc9e6453e342738ce856ab6d7cba72f9a9d5f16c1b75ce91d7438dbace16ebca9636838e78a5477c764ec65bd0d2ad4f60e2a994d1dee1
7
+ data.tar.gz: 37c410853afacedda5b238d83c4792781a4bf7a7007f5792222cf64a37beb9000b3375b79d9022ec69ff534ec1f8151ea06155f352b435ad2eab5ba8d3ba0945
data/bin/cbor2diag.rb CHANGED
@@ -6,7 +6,7 @@ require 'cbor-canonical'
6
6
 
7
7
 
8
8
  require 'cbor-diagnostic-helper'
9
- options = cbor_diagnostic_process_args("cdetpqun")
9
+ options = cbor_diagnostic_process_args("cdetpqunN")
10
10
 
11
11
  ARGF.binmode
12
12
  i = ARGF.read
@@ -5,7 +5,7 @@ require 'cbor-deterministic'
5
5
  require 'cbor-canonical'
6
6
 
7
7
  require 'cbor-diagnostic-helper'
8
- options = cbor_diagnostic_process_args("cdetpqun")
8
+ options = cbor_diagnostic_process_args("cdetpqunN")
9
9
 
10
10
  ARGF.binmode
11
11
  i = ARGF.read
data/bin/cborseq2diag.rb CHANGED
@@ -5,7 +5,7 @@ require 'cbor-deterministic'
5
5
  require 'cbor-canonical'
6
6
 
7
7
  require 'cbor-diagnostic-helper'
8
- options = cbor_diagnostic_process_args("cdetpqun")
8
+ options = cbor_diagnostic_process_args("cdetpqunN")
9
9
 
10
10
  ARGF.binmode
11
11
  i = ARGF.read
data/bin/diag2diag.rb CHANGED
@@ -9,7 +9,7 @@ require 'cbor-pretty'
9
9
  require 'cbor-diagnostic'
10
10
 
11
11
  require 'cbor-diagnostic-helper'
12
- options = cbor_diagnostic_process_args("cdetpqun")
12
+ options = cbor_diagnostic_process_args("cdetpqunN")
13
13
 
14
14
  parser = CBOR_DIAGParser.new
15
15
 
data/bin/pretty2diag.rb CHANGED
@@ -9,7 +9,7 @@ end
9
9
 
10
10
 
11
11
  require 'cbor-diagnostic-helper'
12
- options = cbor_diagnostic_process_args("cdetpqun")
12
+ options = cbor_diagnostic_process_args("cdetpqunN")
13
13
 
14
14
 
15
15
  i = extractbytes(ARGF)
data/cbor-diag.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cbor-diag"
3
- s.version = "0.9.9"
3
+ s.version = "0.10.1"
4
4
  s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
5
5
  s.description = %q{cbor-diag implements diagnostic notation for CBOR, RFC 8949 and RFC 8742}
6
6
  s.author = "Carsten Bormann"
@@ -1542,7 +1542,7 @@ module CBOR_DIAG
1542
1542
  module Appstring2
1543
1543
  #'
1544
1544
  def to_rb
1545
- data = s.elements.map(&:partval).join.b
1545
+ data = s.elements.map(&:partval).join.force_encoding(Encoding::UTF_8)
1546
1546
  app = a.text_value
1547
1547
  # Find a better place to put a default initialization
1548
1548
  CBOR_DIAG.const_set(:APPS, Hash.new { |h, k|
@@ -0,0 +1,27 @@
1
+ class CBOR_DIAG::App_float
2
+ SIZES = {
3
+ 2 => "\xf9".b.freeze,
4
+ 4 => "\xfa".b.freeze,
5
+ 8 => "\xfb".b.freeze,
6
+ }
7
+
8
+ def self.decode(_, s)
9
+ if CBOR::Sequence === s
10
+ if s.elements.size != 1
11
+ raise ArgumentError.new("cbor-diagnostic: float<< #{s.inspect[1...-1]} >>: Argument Error")
12
+ end
13
+ s = s.first
14
+ end
15
+ unless String === s
16
+ raise ArgumentError.new("cbor-diagnostic: float<< #{s.inspect} >>: Argument Error")
17
+ end
18
+ if s.encoding != Encoding::BINARY
19
+ s = s.gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join
20
+ end
21
+ ssize = SIZES[s.size]
22
+ unless ssize
23
+ raise ArgumentError.new("cbor-diagnostic: float<< #{s.inspect} >> size #{s.size} mismatch: Argument Error")
24
+ end
25
+ CBOR::decode(ssize + s)
26
+ end
27
+ end
@@ -31,5 +31,6 @@ def cbor_diagnostic_output(o, options)
31
31
  o.cbor_diagnostic(try_decode_embedded: /e/ === options,
32
32
  bytes_as_text: /t/ === options,
33
33
  utf8: /u/ === options,
34
- nan: /n/ === options)
34
+ nan: /n/ === options,
35
+ no_nan: /N/ === options)
35
36
  end
@@ -19,9 +19,14 @@ end
19
19
 
20
20
  class Float
21
21
  def cbor_diagnostic(options = {}) # do a little bit of JSON.stringify gaming (ECMA-262, 9.8.1)
22
- if options[:nan] && nan?
23
- pl = cbor_nan_toggle
24
- return "nan'#{('%a' % pl).gsub("+", "")}'"
22
+ if nan?
23
+ if options[:nan]
24
+ pl = cbor_nan_toggle
25
+ return "nan'#{('%a' % pl).gsub("+", "")}'"
26
+ elsif !options[:no_nan]
27
+ hex = to_cbor[1..-1].bytes.map{|x| "%02x" % x}.join
28
+ return "float'#{hex}'" unless hex == "7e00"
29
+ end
25
30
  end
26
31
  a = abs
27
32
  if a < 1 && a >= 1e-6
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbor-diag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-08-04 00:00:00.000000000 Z
10
+ date: 2025-08-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -167,6 +167,7 @@ files:
167
167
  - lib/cbor-diag-parser.rb
168
168
  - lib/cbor-diagnostic-app/0.rb
169
169
  - lib/cbor-diagnostic-app/dt.rb
170
+ - lib/cbor-diagnostic-app/float.rb
170
171
  - lib/cbor-diagnostic-app/hash.rb
171
172
  - lib/cbor-diagnostic-app/nan.rb
172
173
  - lib/cbor-diagnostic-helper.rb