cbor-diag 0.5.8 → 0.5.13

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: f7ce2154bebe9237e19250a539bbd30ef39834545bfd2a6e3300f21b1fab9d96
4
- data.tar.gz: 5986f189ccf5d06fc90fda46890cbbc97768929355b039d823cb6046768c5cca
3
+ metadata.gz: 9b0da5131896552d6bd336a401413b35987ce36a8a007a4f495f6be129bb96b9
4
+ data.tar.gz: a3e51b152b59cadf5b5dda60c1bc2cfc7b8356cccced607ae5b7f5998945b60c
5
5
  SHA512:
6
- metadata.gz: cdc1056ab81a9eb943ddcf1e63025634d51d61a3bd2f06bc98f10aa220b322fb5d0742e1511c8c144df9c0d1ce63be2d810e16395e15e2c48418c6bad9242950
7
- data.tar.gz: 3e9e5ec91bce71170dae957881de0453b3d4841bfe3e5936f6600e8fc299190038cf6be591e3b3cfca186a93bd9170bf0ef15ae0bee4b425b213a9becec32910
6
+ metadata.gz: 9939f8edabf591e7e17bf0294589e6208e44f4656ed59c62cabc562e295fc765b2075391320ff51e0fd499c24f305ae372de450d6461f9b68e8d47d0be8575d6
7
+ data.tar.gz: 57c99ecad423f8c1a556a5e40e24aac0f5fb0fb6efcedb1d3c35ceac94a27a67aabe7215d31f6dc9e57e36633fe69cd81faa903402cb2b78f0030459bcea4d09
data/bin/cbor2diag.rb CHANGED
@@ -1,13 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'cbor-diagnostic'
3
3
 
4
-
5
- if ARGV[0] == "-e"
6
- embcbor = true
4
+ options = ''
5
+ while /\A-([etu]+)\z/ === ARGV[0]
6
+ options << $1
7
7
  ARGV.shift
8
8
  end
9
9
 
10
10
  ARGF.binmode
11
11
  i = ARGF.read
12
12
  o = CBOR.decode(i)
13
- puts o.cbor_diagnostic(try_decode_embedded: !!embcbor)
13
+ puts o.cbor_diagnostic(try_decode_embedded: /e/ === options,
14
+ bytes_as_text: /t/ === options,
15
+ utf8: /u/ === options)
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cbor-diagnostic'
3
+
4
+ options = ''
5
+ while /\A-([etu]+)\z/ === ARGV[0]
6
+ options << $1
7
+ ARGV.shift
8
+ end
9
+
10
+ ARGF.binmode
11
+ i = ARGF.read
12
+ while !i.empty?
13
+ o, i = CBOR.decode_with_rest(i)
14
+ out = o.cbor_diagnostic(try_decode_embedded: /e/ === options,
15
+ bytes_as_text: /t/ === options,
16
+ utf8: /u/ === options)
17
+ if i.empty?
18
+ puts out
19
+ else
20
+ print out << ', '
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cbor-pure'
3
+ require 'cbor-pretty'
4
+
5
+ ARGF.binmode
6
+ i = ARGF.read
7
+ puts CBOR::pretty_seq(i)
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.5.8"
3
+ s.version = "0.5.13"
4
4
  s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
5
5
  s.description = %q{cbor-diag implements diagnostic notation for CBOR, RFC 7049}
6
6
  s.author = "Carsten Bormann"
data/lib/cbor-pretty.rb CHANGED
@@ -17,6 +17,15 @@ module CBOR
17
17
  Buffer.new(s).pretty_item_final(indent, max_target)
18
18
  end
19
19
 
20
+ def self.pretty_seq(s, indent = 0, max_target = 40)
21
+ b = Buffer.new(s)
22
+ res = '' # XXX: not all indented the same
23
+ while !b.empty?
24
+ res << b.pretty_item_final(indent, max_target, true)
25
+ end
26
+ res
27
+ end
28
+
20
29
  class Buffer
21
30
 
22
31
  def take_and_print(n, prefix = '')
@@ -72,11 +81,13 @@ module CBOR
72
81
  nil
73
82
  end
74
83
 
75
- def pretty_item_final(indent = 0, max_target = 40)
84
+ def pretty_item_final(indent = 0, max_target = 40, seq = false)
76
85
  @out = ''
77
86
  @indent = indent
78
87
  pretty_item
79
- raise if @pos != @buffer.size
88
+ unless seq
89
+ raise if @pos != @buffer.size
90
+ end
80
91
  target = [@out.each_line.map {|ln| ln =~ /#/ || 0}.max, max_target].min
81
92
  @out.each_line.map {|ln|
82
93
  col = ln =~ /#/
data/lib/cbor-pure.rb CHANGED
@@ -314,6 +314,10 @@ module CBOR
314
314
  ret
315
315
  end
316
316
 
317
+ def empty?
318
+ @pos == buffer.size
319
+ end
320
+
317
321
 
318
322
  end
319
323
 
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.5.8
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-23 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -74,8 +74,10 @@ executables:
74
74
  - cbor2pretty.rb
75
75
  - cbor2yaml.rb
76
76
  - cborleader2diag.rb
77
+ - cborseq2diag.rb
77
78
  - cborseq2json.rb
78
79
  - cborseq2neatjson.rb
80
+ - cborseq2pretty.rb
79
81
  - cborseq2yaml.rb
80
82
  - diag2cbor.rb
81
83
  - diag2pretty.rb
@@ -92,8 +94,10 @@ files:
92
94
  - bin/cbor2pretty.rb
93
95
  - bin/cbor2yaml.rb
94
96
  - bin/cborleader2diag.rb
97
+ - bin/cborseq2diag.rb
95
98
  - bin/cborseq2json.rb
96
99
  - bin/cborseq2neatjson.rb
100
+ - bin/cborseq2pretty.rb
97
101
  - bin/cborseq2yaml.rb
98
102
  - bin/diag2cbor.rb
99
103
  - bin/diag2pretty.rb
@@ -127,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
131
  - !ruby/object:Gem::Version
128
132
  version: '0'
129
133
  requirements: []
130
- rubygems_version: 3.1.4
134
+ rubygems_version: 3.2.3
131
135
  signing_key:
132
136
  specification_version: 4
133
137
  summary: CBOR (Concise Binary Object Representation) diagnostic notation