cbor-diag 0.2.2 → 0.2.4

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
  SHA1:
3
- metadata.gz: 07d189c84e8268cba0d305a69be2be6171fb6fe5
4
- data.tar.gz: 71145361b05c19d21bd26320fae09d34720ba60c
3
+ metadata.gz: 878d675b3f7f6e5f8f352fa4f6add752bba8dd0b
4
+ data.tar.gz: 7cb35a91b219b057abcab0b06c21a44a82ad8c25
5
5
  SHA512:
6
- metadata.gz: ce77f679d0fcc80d9c1e60567548dbe3eb6d50af296b4e5d9f04fea10105cc1346b829fb4d41b2ef79359f946f501688b2f1ba6e051d4cb362faf676ba267eb1
7
- data.tar.gz: 6b5b719f66a3add0320e6638ffb0f77e7f10edbc5e65491f626fcf4e7b89c631edd11a3f0a702041b80bd9e7ff330cb21ca924b779bd5cfe9fec477b0a5082c9
6
+ metadata.gz: b7e7cac5754327ee644345d61b31f6a187c1ec990d04b21292bcd5f6bffc698c6c956749875bbe37c734bd83e49e06bf377316939fc16427178110bc542b08bc
7
+ data.tar.gz: bdabdc08e7e9922033b445e10e7d64ec3bf3d7979aeadd35406aa20219a4b189823c09835ef8570fc6a600c1b466206690a1fc9b77d55538d40201f86f1563d3
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cbor-pure'
3
+ require 'cbor-pretty'
4
+
5
+
6
+ def extractbytes(s)
7
+ s.each_line.map {|ln| ln.sub(/#.*/, '')}.join.scan(/[0-9a-fA-F][0-9a-fA-F]/).map {|b| b.to_i(16).chr(Encoding::BINARY)}.join
8
+ end
9
+
10
+ print(extractbytes(ARGF))
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require 'psych.rb' # WTF
3
+ require 'yaml'
4
+ require 'cbor-pure'
5
+
6
+ if ARGV[0] == "-v"
7
+ verbose = true
8
+ ARGV.shift
9
+ end
10
+
11
+ $stdout.binmode
12
+ i = ARGF.read
13
+ o = CBOR.encode(YAML.load(i))
14
+ print o
15
+ warn "YAML size: #{i.size} bytes, CBOR size: #{o.size} bytes." if verbose
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cbor-diag"
3
- s.version = "0.2.2"
3
+ s.version = "0.2.4"
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"
@@ -182,6 +182,11 @@ class CBOR
182
182
  self
183
183
  end
184
184
 
185
+ def atleast(n)
186
+ left = @buffer.bytesize - @pos
187
+ raise OutOfBytesError.new(n - left) if n > left
188
+ end
189
+
185
190
  def take(n)
186
191
  opos = @pos
187
192
  @pos += n
@@ -257,8 +262,8 @@ class CBOR
257
262
  end
258
263
  when 2; take(val).force_encoding(Encoding::BINARY)
259
264
  when 3; take(val).force_encoding(Encoding::UTF_8)
260
- when 4; Array.new(val) { decode_item }
261
- when 5; Hash[Array.new(val) {[decode_item, decode_item]}]
265
+ when 4; atleast(val); Array.new(val) { decode_item }
266
+ when 5; atleast(val<<1); Hash[Array.new(val) {[decode_item, decode_item]}]
262
267
  end
263
268
  end
264
269
 
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.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-18 00:00:00.000000000 Z
11
+ date: 2016-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,8 @@ executables:
63
63
  - diag2pretty.rb
64
64
  - json2cbor.rb
65
65
  - json2pretty.rb
66
+ - pretty2cbor.rb
67
+ - yaml2cbor.rb
66
68
  extensions: []
67
69
  extra_rdoc_files: []
68
70
  files:
@@ -74,6 +76,8 @@ files:
74
76
  - bin/diag2pretty.rb
75
77
  - bin/json2cbor.rb
76
78
  - bin/json2pretty.rb
79
+ - bin/pretty2cbor.rb
80
+ - bin/yaml2cbor.rb
77
81
  - cbor-diag.gemspec
78
82
  - lib/cbor-diag-parser.rb
79
83
  - lib/cbor-diagnostic.rb
@@ -100,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
104
  version: '0'
101
105
  requirements: []
102
106
  rubyforge_project:
103
- rubygems_version: 2.5.1
107
+ rubygems_version: 2.6.7
104
108
  signing_key:
105
109
  specification_version: 4
106
110
  summary: CBOR (Concise Binary Object Representation) diagnostic notation