cybrid_api_id_ruby 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +5 -5
  4. data/cybrid_api_id_ruby.gemspec +1 -1
  5. data/lib/cybrid_api_id_ruby/api/bank_applications_idp_api.rb +1 -1
  6. data/lib/cybrid_api_id_ruby/api/organization_applications_idp_api.rb +1 -1
  7. data/lib/cybrid_api_id_ruby/api_client.rb +1 -1
  8. data/lib/cybrid_api_id_ruby/api_error.rb +1 -1
  9. data/lib/cybrid_api_id_ruby/configuration.rb +1 -1
  10. data/lib/cybrid_api_id_ruby/models/application_idp_model.rb +1 -1
  11. data/lib/cybrid_api_id_ruby/models/application_list_idp_model.rb +1 -1
  12. data/lib/cybrid_api_id_ruby/models/application_with_secret_all_of_idp_model.rb +1 -1
  13. data/lib/cybrid_api_id_ruby/models/application_with_secret_idp_model.rb +1 -1
  14. data/lib/cybrid_api_id_ruby/models/post_bank_application_idp_model.rb +1 -1
  15. data/lib/cybrid_api_id_ruby/models/post_organization_application_idp_model.rb +1 -1
  16. data/lib/cybrid_api_id_ruby/version.rb +2 -2
  17. data/lib/cybrid_api_id_ruby.rb +1 -1
  18. data/spec/api/bank_applications_idp_api_spec.rb +1 -1
  19. data/spec/api/organization_applications_idp_api_spec.rb +1 -1
  20. data/spec/api_client_spec.rb +1 -1
  21. data/spec/configuration_spec.rb +1 -1
  22. data/spec/models/application_idp_model_spec.rb +1 -1
  23. data/spec/models/application_list_idp_model_spec.rb +1 -1
  24. data/spec/models/application_with_secret_all_of_idp_model_spec.rb +1 -1
  25. data/spec/models/application_with_secret_idp_model_spec.rb +1 -1
  26. data/spec/models/post_bank_application_idp_model_spec.rb +1 -1
  27. data/spec/models/post_organization_application_idp_model_spec.rb +1 -1
  28. data/spec/spec_helper.rb +1 -1
  29. data/vendor/bundle/ruby/3.1.0/cache/psych-4.0.4.gem +0 -0
  30. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/byebug-11.1.3/gem_make.out +2 -2
  31. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/ffi-1.15.5/gem_make.out +2 -2
  32. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/jaro_winkler-1.5.4/gem_make.out +2 -2
  33. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/gem.build_complete +0 -0
  34. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/gem_make.out +27 -0
  35. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/mkmf.log +75 -0
  36. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/psych.so +0 -0
  37. data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/stringio-3.0.2/gem_make.out +2 -2
  38. data/vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/ext/byebug/Makefile +2 -2
  39. data/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/ext/ffi_c/Makefile +2 -2
  40. data/vendor/bundle/ruby/3.1.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler/Makefile +2 -2
  41. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/.gitignore +16 -0
  42. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/Gemfile +9 -0
  43. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/LICENSE +21 -0
  44. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/Mavenfile +7 -0
  45. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/README.md +72 -0
  46. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/Rakefile +41 -0
  47. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/bin/console +7 -0
  48. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/bin/setup +6 -0
  49. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/.sitearchdir.time +0 -0
  50. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/Makefile +274 -0
  51. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/depend +5 -0
  52. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/extconf.rb +43 -0
  53. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.c +37 -0
  54. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.h +17 -0
  55. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.o +0 -0
  56. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.so +0 -0
  57. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_emitter.c +555 -0
  58. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_emitter.h +8 -0
  59. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_emitter.o +0 -0
  60. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_parser.c +579 -0
  61. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_parser.h +6 -0
  62. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_parser.o +0 -0
  63. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_to_ruby.c +39 -0
  64. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_to_ruby.h +8 -0
  65. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_to_ruby.o +0 -0
  66. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_yaml_tree.c +12 -0
  67. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_yaml_tree.h +8 -0
  68. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_yaml_tree.o +0 -0
  69. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/LICENSE +19 -0
  70. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/api.c +1393 -0
  71. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/config.h +80 -0
  72. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/dumper.c +394 -0
  73. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/emitter.c +2358 -0
  74. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/loader.c +544 -0
  75. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/parser.c +1375 -0
  76. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/reader.c +469 -0
  77. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/scanner.c +3598 -0
  78. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/writer.c +141 -0
  79. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/yaml.h +1985 -0
  80. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/yaml_private.h +688 -0
  81. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/class_loader.rb +104 -0
  82. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/coder.rb +95 -0
  83. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/core_ext.rb +19 -0
  84. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/exception.rb +14 -0
  85. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/handler.rb +255 -0
  86. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/handlers/document_stream.rb +23 -0
  87. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/handlers/recorder.rb +40 -0
  88. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/ruby_events.rb +20 -0
  89. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/stream.rb +17 -0
  90. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/tree_builder.rb +13 -0
  91. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/yaml_events.rb +30 -0
  92. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/alias.rb +21 -0
  93. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/document.rb +63 -0
  94. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/mapping.rb +59 -0
  95. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/node.rb +75 -0
  96. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/scalar.rb +70 -0
  97. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/sequence.rb +84 -0
  98. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/stream.rb +40 -0
  99. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes.rb +78 -0
  100. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/omap.rb +5 -0
  101. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/parser.rb +52 -0
  102. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/scalar_scanner.rb +142 -0
  103. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/set.rb +5 -0
  104. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/stream.rb +38 -0
  105. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/streaming.rb +28 -0
  106. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/syntax_error.rb +22 -0
  107. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/tree_builder.rb +137 -0
  108. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/versions.rb +10 -0
  109. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/depth_first.rb +27 -0
  110. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/emitter.rb +52 -0
  111. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/json_tree.rb +25 -0
  112. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/to_ruby.rb +434 -0
  113. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/visitor.rb +34 -0
  114. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/yaml_tree.rb +587 -0
  115. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors.rb +7 -0
  116. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/y.rb +10 -0
  117. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych.rb +741 -0
  118. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych.so +0 -0
  119. data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/psych.gemspec +69 -0
  120. data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.2/ext/stringio/Makefile +2 -2
  121. data/vendor/bundle/ruby/3.1.0/specifications/psych-4.0.4.gemspec +36 -0
  122. metadata +86 -1
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'omap'
3
+ require_relative 'set'
4
+
5
+ module Psych
6
+ class ClassLoader # :nodoc:
7
+ BIG_DECIMAL = 'BigDecimal'
8
+ COMPLEX = 'Complex'
9
+ DATE = 'Date'
10
+ DATE_TIME = 'DateTime'
11
+ EXCEPTION = 'Exception'
12
+ OBJECT = 'Object'
13
+ PSYCH_OMAP = 'Psych::Omap'
14
+ PSYCH_SET = 'Psych::Set'
15
+ RANGE = 'Range'
16
+ RATIONAL = 'Rational'
17
+ REGEXP = 'Regexp'
18
+ STRUCT = 'Struct'
19
+ SYMBOL = 'Symbol'
20
+
21
+ def initialize
22
+ @cache = CACHE.dup
23
+ end
24
+
25
+ def load klassname
26
+ return nil if !klassname || klassname.empty?
27
+
28
+ find klassname
29
+ end
30
+
31
+ def symbolize sym
32
+ symbol
33
+ sym.to_sym
34
+ end
35
+
36
+ constants.each do |const|
37
+ konst = const_get const
38
+ class_eval <<~RUBY
39
+ def #{const.to_s.downcase}
40
+ load #{konst.inspect}
41
+ end
42
+ RUBY
43
+ end
44
+
45
+ private
46
+
47
+ def find klassname
48
+ @cache[klassname] ||= resolve(klassname)
49
+ end
50
+
51
+ def resolve klassname
52
+ name = klassname
53
+ retried = false
54
+
55
+ begin
56
+ path2class(name)
57
+ rescue ArgumentError, NameError => ex
58
+ unless retried
59
+ name = "Struct::#{name}"
60
+ retried = ex
61
+ retry
62
+ end
63
+ raise retried
64
+ end
65
+ end
66
+
67
+ CACHE = Hash[constants.map { |const|
68
+ val = const_get const
69
+ begin
70
+ [val, ::Object.const_get(val)]
71
+ rescue
72
+ nil
73
+ end
74
+ }.compact].freeze
75
+
76
+ class Restricted < ClassLoader
77
+ def initialize classes, symbols
78
+ @classes = classes
79
+ @symbols = symbols
80
+ super()
81
+ end
82
+
83
+ def symbolize sym
84
+ return super if @symbols.empty?
85
+
86
+ if @symbols.include? sym
87
+ super
88
+ else
89
+ raise DisallowedClass.new('load', 'Symbol')
90
+ end
91
+ end
92
+
93
+ private
94
+
95
+ def find klassname
96
+ if @classes.include? klassname
97
+ super
98
+ else
99
+ raise DisallowedClass.new('load', klassname)
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+ module Psych
3
+ ###
4
+ # If an object defines +encode_with+, then an instance of Psych::Coder will
5
+ # be passed to the method when the object is being serialized. The Coder
6
+ # automatically assumes a Psych::Nodes::Mapping is being emitted. Other
7
+ # objects like Sequence and Scalar may be emitted if +seq=+ or +scalar=+ are
8
+ # called, respectively.
9
+ class Coder
10
+ attr_accessor :tag, :style, :implicit, :object
11
+ attr_reader :type, :seq
12
+
13
+ def initialize tag
14
+ @map = {}
15
+ @seq = []
16
+ @implicit = false
17
+ @type = :map
18
+ @tag = tag
19
+ @style = Psych::Nodes::Mapping::BLOCK
20
+ @scalar = nil
21
+ @object = nil
22
+ end
23
+
24
+ def scalar *args
25
+ if args.length > 0
26
+ warn "#{caller[0]}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE
27
+ @tag, @scalar, _ = args
28
+ @type = :scalar
29
+ end
30
+ @scalar
31
+ end
32
+
33
+ # Emit a map. The coder will be yielded to the block.
34
+ def map tag = @tag, style = @style
35
+ @tag = tag
36
+ @style = style
37
+ yield self if block_given?
38
+ @map
39
+ end
40
+
41
+ # Emit a scalar with +value+ and +tag+
42
+ def represent_scalar tag, value
43
+ self.tag = tag
44
+ self.scalar = value
45
+ end
46
+
47
+ # Emit a sequence with +list+ and +tag+
48
+ def represent_seq tag, list
49
+ @tag = tag
50
+ self.seq = list
51
+ end
52
+
53
+ # Emit a sequence with +map+ and +tag+
54
+ def represent_map tag, map
55
+ @tag = tag
56
+ self.map = map
57
+ end
58
+
59
+ # Emit an arbitrary object +obj+ and +tag+
60
+ def represent_object tag, obj
61
+ @tag = tag
62
+ @type = :object
63
+ @object = obj
64
+ end
65
+
66
+ # Emit a scalar with +value+
67
+ def scalar= value
68
+ @type = :scalar
69
+ @scalar = value
70
+ end
71
+
72
+ # Emit a map with +value+
73
+ def map= map
74
+ @type = :map
75
+ @map = map
76
+ end
77
+
78
+ def []= k, v
79
+ @type = :map
80
+ @map[k] = v
81
+ end
82
+ alias :add :[]=
83
+
84
+ def [] k
85
+ @type = :map
86
+ @map[k]
87
+ end
88
+
89
+ # Emit a sequence of +list+
90
+ def seq= list
91
+ @type = :seq
92
+ @seq = list
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ class Object
3
+ def self.yaml_tag url
4
+ Psych.add_tag(url, self)
5
+ end
6
+
7
+ ###
8
+ # call-seq: to_yaml(options = {})
9
+ #
10
+ # Convert an object to YAML. See Psych.dump for more information on the
11
+ # available +options+.
12
+ def to_yaml options = {}
13
+ Psych.dump self, options
14
+ end
15
+ end
16
+
17
+ if defined?(::IRB)
18
+ require_relative 'y'
19
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module Psych
3
+ class Exception < RuntimeError
4
+ end
5
+
6
+ class BadAlias < Exception
7
+ end
8
+
9
+ class DisallowedClass < Exception
10
+ def initialize action, klass_name
11
+ super "Tried to #{action} unspecified class: #{klass_name}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,255 @@
1
+ # frozen_string_literal: true
2
+ module Psych
3
+ ###
4
+ # Psych::Handler is an abstract base class that defines the events used
5
+ # when dealing with Psych::Parser. Clients who want to use Psych::Parser
6
+ # should implement a class that inherits from Psych::Handler and define
7
+ # events that they can handle.
8
+ #
9
+ # Psych::Handler defines all events that Psych::Parser can possibly send to
10
+ # event handlers.
11
+ #
12
+ # See Psych::Parser for more details
13
+ class Handler
14
+ ###
15
+ # Configuration options for dumping YAML.
16
+ class DumperOptions
17
+ attr_accessor :line_width, :indentation, :canonical
18
+
19
+ def initialize
20
+ @line_width = 0
21
+ @indentation = 2
22
+ @canonical = false
23
+ end
24
+ end
25
+
26
+ # Default dumping options
27
+ OPTIONS = DumperOptions.new
28
+
29
+ # Events that a Handler should respond to.
30
+ EVENTS = [ :alias,
31
+ :empty,
32
+ :end_document,
33
+ :end_mapping,
34
+ :end_sequence,
35
+ :end_stream,
36
+ :scalar,
37
+ :start_document,
38
+ :start_mapping,
39
+ :start_sequence,
40
+ :start_stream ]
41
+
42
+ ###
43
+ # Called with +encoding+ when the YAML stream starts. This method is
44
+ # called once per stream. A stream may contain multiple documents.
45
+ #
46
+ # See the constants in Psych::Parser for the possible values of +encoding+.
47
+ def start_stream encoding
48
+ end
49
+
50
+ ###
51
+ # Called when the document starts with the declared +version+,
52
+ # +tag_directives+, if the document is +implicit+.
53
+ #
54
+ # +version+ will be an array of integers indicating the YAML version being
55
+ # dealt with, +tag_directives+ is a list of tuples indicating the prefix
56
+ # and suffix of each tag, and +implicit+ is a boolean indicating whether
57
+ # the document is started implicitly.
58
+ #
59
+ # === Example
60
+ #
61
+ # Given the following YAML:
62
+ #
63
+ # %YAML 1.1
64
+ # %TAG ! tag:tenderlovemaking.com,2009:
65
+ # --- !squee
66
+ #
67
+ # The parameters for start_document must be this:
68
+ #
69
+ # version # => [1, 1]
70
+ # tag_directives # => [["!", "tag:tenderlovemaking.com,2009:"]]
71
+ # implicit # => false
72
+ def start_document version, tag_directives, implicit
73
+ end
74
+
75
+ ###
76
+ # Called with the document ends. +implicit+ is a boolean value indicating
77
+ # whether or not the document has an implicit ending.
78
+ #
79
+ # === Example
80
+ #
81
+ # Given the following YAML:
82
+ #
83
+ # ---
84
+ # hello world
85
+ #
86
+ # +implicit+ will be true. Given this YAML:
87
+ #
88
+ # ---
89
+ # hello world
90
+ # ...
91
+ #
92
+ # +implicit+ will be false.
93
+ def end_document implicit
94
+ end
95
+
96
+ ###
97
+ # Called when an alias is found to +anchor+. +anchor+ will be the name
98
+ # of the anchor found.
99
+ #
100
+ # === Example
101
+ #
102
+ # Here we have an example of an array that references itself in YAML:
103
+ #
104
+ # --- &ponies
105
+ # - first element
106
+ # - *ponies
107
+ #
108
+ # &ponies is the anchor, *ponies is the alias. In this case, alias is
109
+ # called with "ponies".
110
+ def alias anchor
111
+ end
112
+
113
+ ###
114
+ # Called when a scalar +value+ is found. The scalar may have an
115
+ # +anchor+, a +tag+, be implicitly +plain+ or implicitly +quoted+
116
+ #
117
+ # +value+ is the string value of the scalar
118
+ # +anchor+ is an associated anchor or nil
119
+ # +tag+ is an associated tag or nil
120
+ # +plain+ is a boolean value
121
+ # +quoted+ is a boolean value
122
+ # +style+ is an integer indicating the string style
123
+ #
124
+ # See the constants in Psych::Nodes::Scalar for the possible values of
125
+ # +style+
126
+ #
127
+ # === Example
128
+ #
129
+ # Here is a YAML document that exercises most of the possible ways this
130
+ # method can be called:
131
+ #
132
+ # ---
133
+ # - !str "foo"
134
+ # - &anchor fun
135
+ # - many
136
+ # lines
137
+ # - |
138
+ # many
139
+ # newlines
140
+ #
141
+ # The above YAML document contains a list with four strings. Here are
142
+ # the parameters sent to this method in the same order:
143
+ #
144
+ # # value anchor tag plain quoted style
145
+ # ["foo", nil, "!str", false, false, 3 ]
146
+ # ["fun", "anchor", nil, true, false, 1 ]
147
+ # ["many lines", nil, nil, true, false, 1 ]
148
+ # ["many\nnewlines\n", nil, nil, false, true, 4 ]
149
+ #
150
+ def scalar value, anchor, tag, plain, quoted, style
151
+ end
152
+
153
+ ###
154
+ # Called when a sequence is started.
155
+ #
156
+ # +anchor+ is the anchor associated with the sequence or nil.
157
+ # +tag+ is the tag associated with the sequence or nil.
158
+ # +implicit+ a boolean indicating whether or not the sequence was implicitly
159
+ # started.
160
+ # +style+ is an integer indicating the list style.
161
+ #
162
+ # See the constants in Psych::Nodes::Sequence for the possible values of
163
+ # +style+.
164
+ #
165
+ # === Example
166
+ #
167
+ # Here is a YAML document that exercises most of the possible ways this
168
+ # method can be called:
169
+ #
170
+ # ---
171
+ # - !!seq [
172
+ # a
173
+ # ]
174
+ # - &pewpew
175
+ # - b
176
+ #
177
+ # The above YAML document consists of three lists, an outer list that
178
+ # contains two inner lists. Here is a matrix of the parameters sent
179
+ # to represent these lists:
180
+ #
181
+ # # anchor tag implicit style
182
+ # [nil, nil, true, 1 ]
183
+ # [nil, "tag:yaml.org,2002:seq", false, 2 ]
184
+ # ["pewpew", nil, true, 1 ]
185
+
186
+ def start_sequence anchor, tag, implicit, style
187
+ end
188
+
189
+ ###
190
+ # Called when a sequence ends.
191
+ def end_sequence
192
+ end
193
+
194
+ ###
195
+ # Called when a map starts.
196
+ #
197
+ # +anchor+ is the anchor associated with the map or +nil+.
198
+ # +tag+ is the tag associated with the map or +nil+.
199
+ # +implicit+ is a boolean indicating whether or not the map was implicitly
200
+ # started.
201
+ # +style+ is an integer indicating the mapping style.
202
+ #
203
+ # See the constants in Psych::Nodes::Mapping for the possible values of
204
+ # +style+.
205
+ #
206
+ # === Example
207
+ #
208
+ # Here is a YAML document that exercises most of the possible ways this
209
+ # method can be called:
210
+ #
211
+ # ---
212
+ # k: !!map { hello: world }
213
+ # v: &pewpew
214
+ # hello: world
215
+ #
216
+ # The above YAML document consists of three maps, an outer map that contains
217
+ # two inner maps. Below is a matrix of the parameters sent in order to
218
+ # represent these three maps:
219
+ #
220
+ # # anchor tag implicit style
221
+ # [nil, nil, true, 1 ]
222
+ # [nil, "tag:yaml.org,2002:map", false, 2 ]
223
+ # ["pewpew", nil, true, 1 ]
224
+
225
+ def start_mapping anchor, tag, implicit, style
226
+ end
227
+
228
+ ###
229
+ # Called when a map ends
230
+ def end_mapping
231
+ end
232
+
233
+ ###
234
+ # Called when an empty event happens. (Which, as far as I can tell, is
235
+ # never).
236
+ def empty
237
+ end
238
+
239
+ ###
240
+ # Called when the YAML stream ends
241
+ def end_stream
242
+ end
243
+
244
+ ###
245
+ # Called before each event with line/column information.
246
+ def event_location(start_line, start_column, end_line, end_column)
247
+ end
248
+
249
+ ###
250
+ # Is this handler a streaming handler?
251
+ def streaming?
252
+ false
253
+ end
254
+ end
255
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../tree_builder'
3
+
4
+ module Psych
5
+ module Handlers
6
+ class DocumentStream < Psych::TreeBuilder # :nodoc:
7
+ def initialize &block
8
+ super
9
+ @block = block
10
+ end
11
+
12
+ def start_document version, tag_directives, implicit
13
+ n = Nodes::Document.new version, tag_directives, implicit
14
+ push n
15
+ end
16
+
17
+ def end_document implicit_end = !streaming?
18
+ @last.implicit_end = implicit_end
19
+ @block.call pop
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../handler'
3
+
4
+ module Psych
5
+ module Handlers
6
+ ###
7
+ # This handler will capture an event and record the event. Recorder events
8
+ # are available vial Psych::Handlers::Recorder#events.
9
+ #
10
+ # For example:
11
+ #
12
+ # recorder = Psych::Handlers::Recorder.new
13
+ # parser = Psych::Parser.new recorder
14
+ # parser.parse '--- foo'
15
+ #
16
+ # recorder.events # => [list of events]
17
+ #
18
+ # # Replay the events
19
+ #
20
+ # emitter = Psych::Emitter.new $stdout
21
+ # recorder.events.each do |m, args|
22
+ # emitter.send m, *args
23
+ # end
24
+
25
+ class Recorder < Psych::Handler
26
+ attr_reader :events
27
+
28
+ def initialize
29
+ @events = []
30
+ super
31
+ end
32
+
33
+ EVENTS.each do |event|
34
+ define_method event do |*args|
35
+ @events << [event, args]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module Psych
3
+ module JSON
4
+ module RubyEvents # :nodoc:
5
+ def visit_Time o
6
+ formatted = format_time o
7
+ @emitter.scalar formatted, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
8
+ end
9
+
10
+ def visit_DateTime o
11
+ visit_Time o.to_time
12
+ end
13
+
14
+ def visit_String o
15
+ @emitter.scalar o.to_s, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
16
+ end
17
+ alias :visit_Symbol :visit_String
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'ruby_events'
3
+ require_relative 'yaml_events'
4
+
5
+ module Psych
6
+ module JSON
7
+ class Stream < Psych::Visitors::JSONTree
8
+ include Psych::JSON::RubyEvents
9
+ include Psych::Streaming
10
+ extend Psych::Streaming::ClassMethods
11
+
12
+ class Emitter < Psych::Stream::Emitter # :nodoc:
13
+ include Psych::JSON::YAMLEvents
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require_relative 'yaml_events'
3
+
4
+ module Psych
5
+ module JSON
6
+ ###
7
+ # Psych::JSON::TreeBuilder is an event based AST builder. Events are sent
8
+ # to an instance of Psych::JSON::TreeBuilder and a JSON AST is constructed.
9
+ class TreeBuilder < Psych::TreeBuilder
10
+ include Psych::JSON::YAMLEvents
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module Psych
3
+ module JSON
4
+ module YAMLEvents # :nodoc:
5
+ def start_document version, tag_directives, implicit
6
+ super(version, tag_directives, !streaming?)
7
+ end
8
+
9
+ def end_document implicit_end = !streaming?
10
+ super(implicit_end)
11
+ end
12
+
13
+ def start_mapping anchor, tag, implicit, style
14
+ super(anchor, nil, true, Nodes::Mapping::FLOW)
15
+ end
16
+
17
+ def start_sequence anchor, tag, implicit, style
18
+ super(anchor, nil, true, Nodes::Sequence::FLOW)
19
+ end
20
+
21
+ def scalar value, anchor, tag, plain, quoted, style
22
+ if "tag:yaml.org,2002:null" == tag
23
+ super('null', nil, nil, true, false, Nodes::Scalar::PLAIN)
24
+ else
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ module Psych
3
+ module Nodes
4
+ ###
5
+ # This class represents a {YAML Alias}[http://yaml.org/spec/1.1/#alias].
6
+ # It points to an +anchor+.
7
+ #
8
+ # A Psych::Nodes::Alias is a terminal node and may have no children.
9
+ class Alias < Psych::Nodes::Node
10
+ # The anchor this alias links to
11
+ attr_accessor :anchor
12
+
13
+ # Create a new Alias that points to an +anchor+
14
+ def initialize anchor
15
+ @anchor = anchor
16
+ end
17
+
18
+ def alias?; true; end
19
+ end
20
+ end
21
+ end