cbor-diag 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d46971cb4fe65291d5659c969853e2776bc803a4260d3831107ee5b801c0fc76
4
- data.tar.gz: e54c7b33742851467b3b631220a65558f5493c61eb011a973a5283191d4cbe0c
3
+ metadata.gz: 36101912bb86f641e4c04004a324eba80c29a7cdcee234a2a6f1164e3ea9d516
4
+ data.tar.gz: 6f816256cfdba5cdab63e732e59f42ff8359c7e4d25cb53ca0ce643cd08b44f5
5
5
  SHA512:
6
- metadata.gz: bbc73e462fd6fa8a3e44255d4d85847512a320a2e75d141c657849cd21fd1c975429fcaea9798e257ffb681bebec3c6f19d1f50461cc8f36b04a73592ba61fc8
7
- data.tar.gz: dad9a127145e629293892154b6b7e51dde44151138f7596f006226ed238a6bc74740f291b40818123d435a25b0f6eb739cb67a8c7c74f3c1c49cd4ab207fe386
6
+ metadata.gz: cab76345e0b6622175a9dcafe58c90d870e45cc09fdefa521b5b1c9166090226b3a946d845df086792137002203357b6a35e1aec9e0382345e2b2fe2c4c4b9a7
7
+ data.tar.gz: de0383207189021f25c9e37eeb563872e74d5344b9dd2087d3394dc8162de7a1052c38d60052988208242fb66ab97833ac262c09f4f6c3877c8ae3d041afab83
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.7.0"
3
+ s.version = "0.7.5"
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"
@@ -1101,7 +1101,7 @@ module CBOR_DIAG
1101
1101
  end
1102
1102
 
1103
1103
  module StringPart0
1104
- def partval; text_value end
1104
+ def partval; text_value.b end
1105
1105
  end
1106
1106
 
1107
1107
  module StringPart1
@@ -1545,12 +1545,12 @@ module CBOR_DIAG
1545
1545
  data = s.elements.map(&:partval).join.b
1546
1546
  app = a.text_value
1547
1547
  # Find a better place to put a default initialization
1548
- CBOR_DIAG::APPS ||= Hash.new { |h, k|
1548
+ CBOR_DIAG.const_set(:APPS, Hash.new { |h, k|
1549
1549
  h[k] = begin CBOR_DIAG.const_get("App_#{app}")
1550
1550
  rescue NameError
1551
1551
  raise ArgumentError.new("cbor-diagnostic: Unknown application-oriented extension #{k}")
1552
1552
  end
1553
- }
1553
+ }) unless CBOR_DIAG.const_defined?(:APPS)
1554
1554
  CBOR_DIAG::APPS[app].decode(app, data)
1555
1555
  end
1556
1556
  end
@@ -2,6 +2,7 @@
2
2
  unless defined?(CBOR)
3
3
  require 'cbor-pure'
4
4
  end
5
+ require 'json'
5
6
 
6
7
  class Object
7
8
  def cbor_diagnostic(_=nil)
@@ -55,7 +56,7 @@ class String
55
56
  result << dv
56
57
  end
57
58
  return "<< #{result.map{|x| x.cbor_diagnostic(options)}.join(", ")} >>"
58
- rescue RuntimeError => e
59
+ rescue StandardError => e
59
60
  # that didn't work out, so continue with other options
60
61
  # puts e.backtrace
61
62
  end
@@ -67,9 +68,9 @@ class String
67
68
  end
68
69
  else
69
70
  if options[:utf8]
70
- inspect
71
+ to_json
71
72
  else
72
- inspect.encode(Encoding::UTF_16BE).bytes.each_slice(2).map {
73
+ to_json.encode(Encoding::UTF_16BE).bytes.each_slice(2).map {
73
74
  |c1, c2| c = (c1 << 8)+c2; c < 128 ? c.chr : '\u%04x' % c }.join
74
75
  end
75
76
  end
data/lib/cbor-pretty.rb CHANGED
@@ -4,10 +4,14 @@
4
4
  unless defined?(CBOR)
5
5
  require 'cbor-pure'
6
6
  end
7
+ require 'json'
8
+
9
+ UPPERCASE_HEX = ENV["UPPERCASE_HEX"]
10
+ HEX_FORMAT = UPPERCASE_HEX ? "%02X" : "%02x"
7
11
 
8
12
  class String
9
13
  def hexbytes(sep = '')
10
- bytes.map{|x| "%02x" % x}.join(sep)
14
+ bytes.map{|x| HEX_FORMAT % x}.join(sep)
11
15
  end
12
16
  end
13
17
 
@@ -72,7 +76,7 @@ module CBOR
72
76
  when 2, 3
73
77
  @out << ' ' * (@indent)
74
78
  s = take_and_print(val)
75
- @out << " # #{s.inspect}"
79
+ @out << " # #{s.force_encoding(Encoding::UTF_8).to_json rescue s.inspect}"
76
80
  @out << "\n"
77
81
  when 4; val.times { pretty_item }
78
82
  when 5; val.times { pretty_item; pretty_item}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbor-diag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-04 00:00:00.000000000 Z
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -190,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.2.22
193
+ rubygems_version: 3.2.32
194
194
  signing_key:
195
195
  specification_version: 4
196
196
  summary: CBOR (Concise Binary Object Representation) diagnostic notation