cbor-diag-ref 0.0.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 +7 -0
- data/cbor-diag-ref.gemspec +17 -0
- data/lib/cbor-diagnostic-app/ref.rb +38 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 75d3124aa676405410e8cfa01e0ad5b546f59972badf278ef23639a864da80b8
|
4
|
+
data.tar.gz: 0045d24c6491fa71909ec9e073a245cf4e336c74fd3cf9d18dde42184169e091
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c84a79da725de4270b760c3197937bedc435a82cbba078c4b90a2f93314b3b0f033c3663778867aecf4716672975ff382220b98b2981fa807d333cf47eb2f90
|
7
|
+
data.tar.gz: f25e5ec1dfa2a6280be6487f75ac52666f0914037148373ec6e48c44d49aafbc1aac55796a2f5d1cdfa1dc23c0cc3a1bdc0715fa0219a0823a21a4d6c6056fd6
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "cbor-diag-ref"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
|
5
|
+
s.description = %q{cbor-diag-ref implements referencing for CBOR diagnostic notation}
|
6
|
+
s.author = "Carsten Bormann"
|
7
|
+
s.email = "cabo@tzi.org"
|
8
|
+
s.license = "MIT"
|
9
|
+
s.homepage = "http://cbor.io/"
|
10
|
+
s.files = Dir['lib/**/*.rb'] + %w(cbor-diag-ref.gemspec) + Dir['bin/**/*.rb']
|
11
|
+
s.executables = Dir['bin/**/*.rb'].map {|x| File.basename(x)}
|
12
|
+
s.required_ruby_version = '>= 2.3'
|
13
|
+
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
|
16
|
+
s.add_development_dependency 'bundler', '~>1'
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'treetop'
|
2
|
+
require 'cbor-diag-parser'
|
3
|
+
require 'uri'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
class CBOR_DIAG::App_ref
|
7
|
+
def self.trunc_for_error(s, n = 40)
|
8
|
+
if s.size > n
|
9
|
+
s[0...n].inspect << "..."
|
10
|
+
else
|
11
|
+
s.inspect
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.decode(_, s)
|
16
|
+
|
17
|
+
# XXX this fetches a unchecked URL/file based on input -- needs some sanitizing...
|
18
|
+
|
19
|
+
diag = begin
|
20
|
+
URI(s).open.read
|
21
|
+
rescue NoMethodError
|
22
|
+
false # avoid showing URI.open in the backtrace
|
23
|
+
end
|
24
|
+
diag ||= File.read(s)
|
25
|
+
parser = CBOR_DIAGParser.new
|
26
|
+
if result = parser.parse(diag)
|
27
|
+
decoded = result.to_rb
|
28
|
+
if CBOR::Sequence === decoded
|
29
|
+
raise ArgumentError,
|
30
|
+
"*** can't handle CBOR sequence #{trunc_for_error(diag)} as referenced from #{s.inspect}"
|
31
|
+
end
|
32
|
+
decoded
|
33
|
+
else
|
34
|
+
raise ArgumentError,
|
35
|
+
"*** can't parse #{trunc_for_error(diag)} as referenced from #{s.inspect}: #{parser.failure_reason}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cbor-diag-ref
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carsten Bormann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1'
|
27
|
+
description: cbor-diag-ref implements referencing for CBOR diagnostic notation
|
28
|
+
email: cabo@tzi.org
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- cbor-diag-ref.gemspec
|
34
|
+
- lib/cbor-diagnostic-app/ref.rb
|
35
|
+
homepage: http://cbor.io/
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.3'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubygems_version: 3.4.10
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: CBOR (Concise Binary Object Representation) diagnostic notation
|
58
|
+
test_files: []
|