Top Level Namespace

Defined Under Namespace

Modules: CBOR, CBOR_DIAG, Half Classes: Array, CBOR_DIAGParser, Float, Hash, NilClass, Object, String

Constant Summary collapse

UPPERCASE_HEX =
ENV["UPPERCASE_HEX"]
HEX_FORMAT =
UPPERCASE_HEX ? "%02X" : "%02x"

Instance Method Summary collapse

Instance Method Details

#cbor_diagnostic_item_processing(o, options) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/cbor-diagnostic-helper.rb', line 21

def cbor_diagnostic_item_processing(o, options)
  o = o.to_packed_cbor if /p/ === options
  o = o.to_unpacked_cbor if /q/ === options
  o = o.cbor_pre_canonicalize if /c/ === options
  o = o.cbor_prepare_deterministic if /d/ === options
  o
end

#cbor_diagnostic_output(o, options) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/cbor-diagnostic-helper.rb', line 29

def cbor_diagnostic_output(o, options)
  o = cbor_diagnostic_item_processing(o, options)
  o.cbor_diagnostic(try_decode_embedded: /e/ === options,
                    bytes_as_text: /t/ === options,
                    utf8: /u/ === options,
                    nan: /n/ === options)
end

#cbor_diagnostic_process_args(chars) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cbor-diagnostic-helper.rb', line 5

def cbor_diagnostic_process_args(chars)
  options = ''
  while /\A-(?:([#{chars}]+)|([#{chars}]*)a(.*))\z/ === ARGV[0]
    ARGV.shift
    options << $1 if $1
    options << $2 if $2
    if s = $3
      s = ARGV.shift if s == ""
      s.split(",").each do |a|
        require "cbor-diagnostic-app/#{a}"
      end
    end
  end
  options
end