cybrid_api_bank_ruby 0.9.0 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +5 -5
- data/cybrid_api_bank_ruby.gemspec +1 -1
- data/lib/cybrid_api_bank_ruby/api/accounts_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/assets_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/banks_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/customers_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/identity_records_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/prices_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/quotes_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/symbols_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/trades_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/trading_configurations_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api/verification_keys_bank_api.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api_client.rb +1 -1
- data/lib/cybrid_api_bank_ruby/api_error.rb +1 -1
- data/lib/cybrid_api_bank_ruby/configuration.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/account_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/account_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/asset_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/asset_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/attestation_details_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/bank_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/bank_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/customer_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/customer_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/exchange_account_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/exchange_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/fee_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/identity_record_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_account_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_bank_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_customer_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_fee_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_identity_record_attestation_details_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_identity_record_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_quote_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_trade_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_trading_configuration_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/post_verification_key_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/quote_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/quote_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/symbol_price_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/system_account_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/trade_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/trade_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/trading_configuration_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/trading_configuration_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/verification_key_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/models/verification_key_list_bank_model.rb +1 -1
- data/lib/cybrid_api_bank_ruby/version.rb +2 -2
- data/lib/cybrid_api_bank_ruby.rb +1 -1
- data/spec/api/accounts_bank_api_spec.rb +1 -1
- data/spec/api/assets_bank_api_spec.rb +1 -1
- data/spec/api/banks_bank_api_spec.rb +1 -1
- data/spec/api/customers_bank_api_spec.rb +1 -1
- data/spec/api/identity_records_bank_api_spec.rb +1 -1
- data/spec/api/prices_bank_api_spec.rb +1 -1
- data/spec/api/quotes_bank_api_spec.rb +1 -1
- data/spec/api/symbols_bank_api_spec.rb +1 -1
- data/spec/api/trades_bank_api_spec.rb +1 -1
- data/spec/api/trading_configurations_bank_api_spec.rb +1 -1
- data/spec/api/verification_keys_bank_api_spec.rb +1 -1
- data/spec/api_client_spec.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/models/account_bank_model_spec.rb +1 -1
- data/spec/models/account_list_bank_model_spec.rb +1 -1
- data/spec/models/asset_bank_model_spec.rb +1 -1
- data/spec/models/asset_list_bank_model_spec.rb +1 -1
- data/spec/models/attestation_details_bank_model_spec.rb +1 -1
- data/spec/models/bank_bank_model_spec.rb +1 -1
- data/spec/models/bank_list_bank_model_spec.rb +1 -1
- data/spec/models/customer_bank_model_spec.rb +1 -1
- data/spec/models/customer_list_bank_model_spec.rb +1 -1
- data/spec/models/exchange_account_bank_model_spec.rb +1 -1
- data/spec/models/exchange_bank_model_spec.rb +1 -1
- data/spec/models/fee_bank_model_spec.rb +1 -1
- data/spec/models/identity_record_bank_model_spec.rb +1 -1
- data/spec/models/post_account_bank_model_spec.rb +1 -1
- data/spec/models/post_bank_bank_model_spec.rb +1 -1
- data/spec/models/post_customer_bank_model_spec.rb +1 -1
- data/spec/models/post_fee_bank_model_spec.rb +1 -1
- data/spec/models/post_identity_record_attestation_details_bank_model_spec.rb +1 -1
- data/spec/models/post_identity_record_bank_model_spec.rb +1 -1
- data/spec/models/post_quote_bank_model_spec.rb +1 -1
- data/spec/models/post_trade_bank_model_spec.rb +1 -1
- data/spec/models/post_trading_configuration_bank_model_spec.rb +1 -1
- data/spec/models/post_verification_key_bank_model_spec.rb +1 -1
- data/spec/models/quote_bank_model_spec.rb +1 -1
- data/spec/models/quote_list_bank_model_spec.rb +1 -1
- data/spec/models/symbol_price_bank_model_spec.rb +1 -1
- data/spec/models/system_account_bank_model_spec.rb +1 -1
- data/spec/models/trade_bank_model_spec.rb +1 -1
- data/spec/models/trade_list_bank_model_spec.rb +1 -1
- data/spec/models/trading_configuration_bank_model_spec.rb +1 -1
- data/spec/models/trading_configuration_list_bank_model_spec.rb +1 -1
- data/spec/models/verification_key_bank_model_spec.rb +1 -1
- data/spec/models/verification_key_list_bank_model_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/vendor/bundle/ruby/3.1.0/cache/psych-4.0.4.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/byebug-11.1.3/gem_make.out +2 -2
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/ffi-1.15.5/gem_make.out +2 -2
- 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
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/gem.build_complete +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/gem_make.out +27 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/mkmf.log +75 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/psych-4.0.4/psych.so +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0-static/stringio-3.0.2/gem_make.out +2 -2
- data/vendor/bundle/ruby/3.1.0/gems/byebug-11.1.3/ext/byebug/Makefile +2 -2
- data/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/ext/ffi_c/Makefile +2 -2
- data/vendor/bundle/ruby/3.1.0/gems/jaro_winkler-1.5.4/ext/jaro_winkler/Makefile +2 -2
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/.gitignore +16 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/Gemfile +9 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/LICENSE +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/Mavenfile +7 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/README.md +72 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/Rakefile +41 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/bin/console +7 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/bin/setup +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/.sitearchdir.time +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/Makefile +274 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/depend +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/extconf.rb +43 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.c +37 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.h +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_emitter.c +555 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_emitter.h +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_emitter.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_parser.c +579 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_parser.h +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_parser.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_to_ruby.c +39 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_to_ruby.h +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_to_ruby.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_yaml_tree.c +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_yaml_tree.h +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/psych_yaml_tree.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/LICENSE +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/api.c +1393 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/config.h +80 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/dumper.c +394 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/emitter.c +2358 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/loader.c +544 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/parser.c +1375 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/reader.c +469 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/scanner.c +3598 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/writer.c +141 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/yaml.h +1985 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/ext/psych/yaml/yaml_private.h +688 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/class_loader.rb +104 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/coder.rb +95 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/core_ext.rb +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/exception.rb +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/handler.rb +255 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/handlers/document_stream.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/handlers/recorder.rb +40 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/ruby_events.rb +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/stream.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/tree_builder.rb +13 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/json/yaml_events.rb +30 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/alias.rb +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/document.rb +63 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/mapping.rb +59 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/node.rb +75 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/scalar.rb +70 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/sequence.rb +84 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes/stream.rb +40 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/nodes.rb +78 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/omap.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/parser.rb +52 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/scalar_scanner.rb +142 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/set.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/stream.rb +38 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/streaming.rb +28 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/syntax_error.rb +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/tree_builder.rb +137 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/versions.rb +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/depth_first.rb +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/emitter.rb +52 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/json_tree.rb +25 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/to_ruby.rb +434 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/visitor.rb +34 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors/yaml_tree.rb +587 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/visitors.rb +7 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych/y.rb +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych.rb +741 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/lib/psych.so +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/psych-4.0.4/psych.gemspec +69 -0
- data/vendor/bundle/ruby/3.1.0/gems/stringio-3.0.2/ext/stringio/Makefile +2 -2
- data/vendor/bundle/ruby/3.1.0/specifications/psych-4.0.4.gemspec +36 -0
- metadata +86 -1
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Psych
|
3
|
+
module Nodes
|
4
|
+
###
|
5
|
+
# This represents a YAML Document. This node must be a child of
|
6
|
+
# Psych::Nodes::Stream. A Psych::Nodes::Document must have one child,
|
7
|
+
# and that child may be one of the following:
|
8
|
+
#
|
9
|
+
# * Psych::Nodes::Sequence
|
10
|
+
# * Psych::Nodes::Mapping
|
11
|
+
# * Psych::Nodes::Scalar
|
12
|
+
class Document < Psych::Nodes::Node
|
13
|
+
# The version of the YAML document
|
14
|
+
attr_accessor :version
|
15
|
+
|
16
|
+
# A list of tag directives for this document
|
17
|
+
attr_accessor :tag_directives
|
18
|
+
|
19
|
+
# Was this document implicitly created?
|
20
|
+
attr_accessor :implicit
|
21
|
+
|
22
|
+
# Is the end of the document implicit?
|
23
|
+
attr_accessor :implicit_end
|
24
|
+
|
25
|
+
###
|
26
|
+
# Create a new Psych::Nodes::Document object.
|
27
|
+
#
|
28
|
+
# +version+ is a list indicating the YAML version.
|
29
|
+
# +tags_directives+ is a list of tag directive declarations
|
30
|
+
# +implicit+ is a flag indicating whether the document will be implicitly
|
31
|
+
# started.
|
32
|
+
#
|
33
|
+
# == Example:
|
34
|
+
# This creates a YAML document object that represents a YAML 1.1 document
|
35
|
+
# with one tag directive, and has an implicit start:
|
36
|
+
#
|
37
|
+
# Psych::Nodes::Document.new(
|
38
|
+
# [1,1],
|
39
|
+
# [["!", "tag:tenderlovemaking.com,2009:"]],
|
40
|
+
# true
|
41
|
+
# )
|
42
|
+
#
|
43
|
+
# == See Also
|
44
|
+
# See also Psych::Handler#start_document
|
45
|
+
def initialize version = [], tag_directives = [], implicit = false
|
46
|
+
super()
|
47
|
+
@version = version
|
48
|
+
@tag_directives = tag_directives
|
49
|
+
@implicit = implicit
|
50
|
+
@implicit_end = true
|
51
|
+
end
|
52
|
+
|
53
|
+
###
|
54
|
+
# Returns the root node. A Document may only have one root node:
|
55
|
+
# http://yaml.org/spec/1.1/#id898031
|
56
|
+
def root
|
57
|
+
children.first
|
58
|
+
end
|
59
|
+
|
60
|
+
def document?; true; end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Psych
|
3
|
+
module Nodes
|
4
|
+
###
|
5
|
+
# This class represents a {YAML Mapping}[http://yaml.org/spec/1.1/#mapping].
|
6
|
+
#
|
7
|
+
# A Psych::Nodes::Mapping node may have 0 or more children, but must have
|
8
|
+
# an even number of children. Here are the valid children a
|
9
|
+
# Psych::Nodes::Mapping node may have:
|
10
|
+
#
|
11
|
+
# * Psych::Nodes::Sequence
|
12
|
+
# * Psych::Nodes::Mapping
|
13
|
+
# * Psych::Nodes::Scalar
|
14
|
+
# * Psych::Nodes::Alias
|
15
|
+
class Mapping < Psych::Nodes::Node
|
16
|
+
# Any Map Style
|
17
|
+
ANY = 0
|
18
|
+
|
19
|
+
# Block Map Style
|
20
|
+
BLOCK = 1
|
21
|
+
|
22
|
+
# Flow Map Style
|
23
|
+
FLOW = 2
|
24
|
+
|
25
|
+
# The optional anchor for this mapping
|
26
|
+
attr_accessor :anchor
|
27
|
+
|
28
|
+
# The optional tag for this mapping
|
29
|
+
attr_accessor :tag
|
30
|
+
|
31
|
+
# Is this an implicit mapping?
|
32
|
+
attr_accessor :implicit
|
33
|
+
|
34
|
+
# The style of this mapping
|
35
|
+
attr_accessor :style
|
36
|
+
|
37
|
+
###
|
38
|
+
# Create a new Psych::Nodes::Mapping object.
|
39
|
+
#
|
40
|
+
# +anchor+ is the anchor associated with the map or +nil+.
|
41
|
+
# +tag+ is the tag associated with the map or +nil+.
|
42
|
+
# +implicit+ is a boolean indicating whether or not the map was implicitly
|
43
|
+
# started.
|
44
|
+
# +style+ is an integer indicating the mapping style.
|
45
|
+
#
|
46
|
+
# == See Also
|
47
|
+
# See also Psych::Handler#start_mapping
|
48
|
+
def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
|
49
|
+
super()
|
50
|
+
@anchor = anchor
|
51
|
+
@tag = tag
|
52
|
+
@implicit = implicit
|
53
|
+
@style = style
|
54
|
+
end
|
55
|
+
|
56
|
+
def mapping?; true; end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'stringio'
|
3
|
+
require_relative '../class_loader'
|
4
|
+
require_relative '../scalar_scanner'
|
5
|
+
|
6
|
+
module Psych
|
7
|
+
module Nodes
|
8
|
+
###
|
9
|
+
# The base class for any Node in a YAML parse tree. This class should
|
10
|
+
# never be instantiated.
|
11
|
+
class Node
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
# The children of this node
|
15
|
+
attr_reader :children
|
16
|
+
|
17
|
+
# An associated tag
|
18
|
+
attr_reader :tag
|
19
|
+
|
20
|
+
# The line number where this node start
|
21
|
+
attr_accessor :start_line
|
22
|
+
|
23
|
+
# The column number where this node start
|
24
|
+
attr_accessor :start_column
|
25
|
+
|
26
|
+
# The line number where this node ends
|
27
|
+
attr_accessor :end_line
|
28
|
+
|
29
|
+
# The column number where this node ends
|
30
|
+
attr_accessor :end_column
|
31
|
+
|
32
|
+
# Create a new Psych::Nodes::Node
|
33
|
+
def initialize
|
34
|
+
@children = []
|
35
|
+
end
|
36
|
+
|
37
|
+
###
|
38
|
+
# Iterate over each node in the tree. Yields each node to +block+ depth
|
39
|
+
# first.
|
40
|
+
def each &block
|
41
|
+
return enum_for :each unless block_given?
|
42
|
+
Visitors::DepthFirst.new(block).accept self
|
43
|
+
end
|
44
|
+
|
45
|
+
###
|
46
|
+
# Convert this node to Ruby.
|
47
|
+
#
|
48
|
+
# See also Psych::Visitors::ToRuby
|
49
|
+
def to_ruby(symbolize_names: false, freeze: false, strict_integer: false)
|
50
|
+
Visitors::ToRuby.create(symbolize_names: symbolize_names, freeze: freeze, strict_integer: strict_integer).accept(self)
|
51
|
+
end
|
52
|
+
alias :transform :to_ruby
|
53
|
+
|
54
|
+
###
|
55
|
+
# Convert this node to YAML.
|
56
|
+
#
|
57
|
+
# See also Psych::Visitors::Emitter
|
58
|
+
def yaml io = nil, options = {}
|
59
|
+
real_io = io || StringIO.new(''.encode('utf-8'))
|
60
|
+
|
61
|
+
Visitors::Emitter.new(real_io, options).accept self
|
62
|
+
return real_io.string unless io
|
63
|
+
io
|
64
|
+
end
|
65
|
+
alias :to_yaml :yaml
|
66
|
+
|
67
|
+
def alias?; false; end
|
68
|
+
def document?; false; end
|
69
|
+
def mapping?; false; end
|
70
|
+
def scalar?; false; end
|
71
|
+
def sequence?; false; end
|
72
|
+
def stream?; false; end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Psych
|
3
|
+
module Nodes
|
4
|
+
###
|
5
|
+
# This class represents a {YAML Scalar}[http://yaml.org/spec/1.1/#id858081].
|
6
|
+
#
|
7
|
+
# This node type is a terminal node and should not have any children.
|
8
|
+
class Scalar < Psych::Nodes::Node
|
9
|
+
# Any style scalar, the emitter chooses
|
10
|
+
ANY = 0
|
11
|
+
|
12
|
+
# Plain scalar style
|
13
|
+
PLAIN = 1
|
14
|
+
|
15
|
+
# Single quoted style
|
16
|
+
SINGLE_QUOTED = 2
|
17
|
+
|
18
|
+
# Double quoted style
|
19
|
+
DOUBLE_QUOTED = 3
|
20
|
+
|
21
|
+
# Literal style
|
22
|
+
LITERAL = 4
|
23
|
+
|
24
|
+
# Folded style
|
25
|
+
FOLDED = 5
|
26
|
+
|
27
|
+
# The scalar value
|
28
|
+
attr_accessor :value
|
29
|
+
|
30
|
+
# The anchor value (if there is one)
|
31
|
+
attr_accessor :anchor
|
32
|
+
|
33
|
+
# The tag value (if there is one)
|
34
|
+
attr_accessor :tag
|
35
|
+
|
36
|
+
# Is this a plain scalar?
|
37
|
+
attr_accessor :plain
|
38
|
+
|
39
|
+
# Is this scalar quoted?
|
40
|
+
attr_accessor :quoted
|
41
|
+
|
42
|
+
# The style of this scalar
|
43
|
+
attr_accessor :style
|
44
|
+
|
45
|
+
###
|
46
|
+
# Create a new Psych::Nodes::Scalar object.
|
47
|
+
#
|
48
|
+
# +value+ is the string value of the scalar
|
49
|
+
# +anchor+ is an associated anchor or nil
|
50
|
+
# +tag+ is an associated tag or nil
|
51
|
+
# +plain+ is a boolean value
|
52
|
+
# +quoted+ is a boolean value
|
53
|
+
# +style+ is an integer indicating the string style
|
54
|
+
#
|
55
|
+
# == See Also
|
56
|
+
#
|
57
|
+
# See also Psych::Handler#scalar
|
58
|
+
def initialize value, anchor = nil, tag = nil, plain = true, quoted = false, style = ANY
|
59
|
+
@value = value
|
60
|
+
@anchor = anchor
|
61
|
+
@tag = tag
|
62
|
+
@plain = plain
|
63
|
+
@quoted = quoted
|
64
|
+
@style = style
|
65
|
+
end
|
66
|
+
|
67
|
+
def scalar?; true; end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Psych
|
3
|
+
module Nodes
|
4
|
+
###
|
5
|
+
# This class represents a
|
6
|
+
# {YAML sequence}[http://yaml.org/spec/1.1/#sequence/syntax].
|
7
|
+
#
|
8
|
+
# A YAML sequence is basically a list, and looks like this:
|
9
|
+
#
|
10
|
+
# %YAML 1.1
|
11
|
+
# ---
|
12
|
+
# - I am
|
13
|
+
# - a Sequence
|
14
|
+
#
|
15
|
+
# A YAML sequence may have an anchor like this:
|
16
|
+
#
|
17
|
+
# %YAML 1.1
|
18
|
+
# ---
|
19
|
+
# &A [
|
20
|
+
# "This sequence",
|
21
|
+
# "has an anchor"
|
22
|
+
# ]
|
23
|
+
#
|
24
|
+
# A YAML sequence may also have a tag like this:
|
25
|
+
#
|
26
|
+
# %YAML 1.1
|
27
|
+
# ---
|
28
|
+
# !!seq [
|
29
|
+
# "This sequence",
|
30
|
+
# "has a tag"
|
31
|
+
# ]
|
32
|
+
#
|
33
|
+
# This class represents a sequence in a YAML document. A
|
34
|
+
# Psych::Nodes::Sequence node may have 0 or more children. Valid children
|
35
|
+
# for this node are:
|
36
|
+
#
|
37
|
+
# * Psych::Nodes::Sequence
|
38
|
+
# * Psych::Nodes::Mapping
|
39
|
+
# * Psych::Nodes::Scalar
|
40
|
+
# * Psych::Nodes::Alias
|
41
|
+
class Sequence < Psych::Nodes::Node
|
42
|
+
# Any Styles, emitter chooses
|
43
|
+
ANY = 0
|
44
|
+
|
45
|
+
# Block style sequence
|
46
|
+
BLOCK = 1
|
47
|
+
|
48
|
+
# Flow style sequence
|
49
|
+
FLOW = 2
|
50
|
+
|
51
|
+
# The anchor for this sequence (if any)
|
52
|
+
attr_accessor :anchor
|
53
|
+
|
54
|
+
# The tag name for this sequence (if any)
|
55
|
+
attr_accessor :tag
|
56
|
+
|
57
|
+
# Is this sequence started implicitly?
|
58
|
+
attr_accessor :implicit
|
59
|
+
|
60
|
+
# The sequence style used
|
61
|
+
attr_accessor :style
|
62
|
+
|
63
|
+
###
|
64
|
+
# Create a new object representing a YAML sequence.
|
65
|
+
#
|
66
|
+
# +anchor+ is the anchor associated with the sequence or nil.
|
67
|
+
# +tag+ is the tag associated with the sequence or nil.
|
68
|
+
# +implicit+ a boolean indicating whether or not the sequence was
|
69
|
+
# implicitly started.
|
70
|
+
# +style+ is an integer indicating the list style.
|
71
|
+
#
|
72
|
+
# See Psych::Handler#start_sequence
|
73
|
+
def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
|
74
|
+
super()
|
75
|
+
@anchor = anchor
|
76
|
+
@tag = tag
|
77
|
+
@implicit = implicit
|
78
|
+
@style = style
|
79
|
+
end
|
80
|
+
|
81
|
+
def sequence?; true; end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Psych
|
3
|
+
module Nodes
|
4
|
+
###
|
5
|
+
# Represents a YAML stream. This is the root node for any YAML parse
|
6
|
+
# tree. This node must have one or more child nodes. The only valid
|
7
|
+
# child node for a Psych::Nodes::Stream node is Psych::Nodes::Document.
|
8
|
+
class Stream < Psych::Nodes::Node
|
9
|
+
|
10
|
+
# Encodings supported by Psych (and libyaml)
|
11
|
+
|
12
|
+
# Any encoding
|
13
|
+
ANY = Psych::Parser::ANY
|
14
|
+
|
15
|
+
# UTF-8 encoding
|
16
|
+
UTF8 = Psych::Parser::UTF8
|
17
|
+
|
18
|
+
# UTF-16LE encoding
|
19
|
+
UTF16LE = Psych::Parser::UTF16LE
|
20
|
+
|
21
|
+
# UTF-16BE encoding
|
22
|
+
UTF16BE = Psych::Parser::UTF16BE
|
23
|
+
|
24
|
+
# The encoding used for this stream
|
25
|
+
attr_accessor :encoding
|
26
|
+
|
27
|
+
###
|
28
|
+
# Create a new Psych::Nodes::Stream node with an +encoding+ that
|
29
|
+
# defaults to Psych::Nodes::Stream::UTF8.
|
30
|
+
#
|
31
|
+
# See also Psych::Handler#start_stream
|
32
|
+
def initialize encoding = UTF8
|
33
|
+
super()
|
34
|
+
@encoding = encoding
|
35
|
+
end
|
36
|
+
|
37
|
+
def stream?; true; end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative 'nodes/node'
|
3
|
+
require_relative 'nodes/stream'
|
4
|
+
require_relative 'nodes/document'
|
5
|
+
require_relative 'nodes/sequence'
|
6
|
+
require_relative 'nodes/scalar'
|
7
|
+
require_relative 'nodes/mapping'
|
8
|
+
require_relative 'nodes/alias'
|
9
|
+
|
10
|
+
module Psych
|
11
|
+
###
|
12
|
+
# = Overview
|
13
|
+
#
|
14
|
+
# When using Psych.load to deserialize a YAML document, the document is
|
15
|
+
# translated to an intermediary AST. That intermediary AST is then
|
16
|
+
# translated in to a Ruby object graph.
|
17
|
+
#
|
18
|
+
# In the opposite direction, when using Psych.dump, the Ruby object graph is
|
19
|
+
# translated to an intermediary AST which is then converted to a YAML
|
20
|
+
# document.
|
21
|
+
#
|
22
|
+
# Psych::Nodes contains all of the classes that make up the nodes of a YAML
|
23
|
+
# AST. You can manually build an AST and use one of the visitors (see
|
24
|
+
# Psych::Visitors) to convert that AST to either a YAML document or to a
|
25
|
+
# Ruby object graph.
|
26
|
+
#
|
27
|
+
# Here is an example of building an AST that represents a list with one
|
28
|
+
# scalar:
|
29
|
+
#
|
30
|
+
# # Create our nodes
|
31
|
+
# stream = Psych::Nodes::Stream.new
|
32
|
+
# doc = Psych::Nodes::Document.new
|
33
|
+
# seq = Psych::Nodes::Sequence.new
|
34
|
+
# scalar = Psych::Nodes::Scalar.new('foo')
|
35
|
+
#
|
36
|
+
# # Build up our tree
|
37
|
+
# stream.children << doc
|
38
|
+
# doc.children << seq
|
39
|
+
# seq.children << scalar
|
40
|
+
#
|
41
|
+
# The stream is the root of the tree. We can then convert the tree to YAML:
|
42
|
+
#
|
43
|
+
# stream.to_yaml => "---\n- foo\n"
|
44
|
+
#
|
45
|
+
# Or convert it to Ruby:
|
46
|
+
#
|
47
|
+
# stream.to_ruby => [["foo"]]
|
48
|
+
#
|
49
|
+
# == YAML AST Requirements
|
50
|
+
#
|
51
|
+
# A valid YAML AST *must* have one Psych::Nodes::Stream at the root. A
|
52
|
+
# Psych::Nodes::Stream node must have 1 or more Psych::Nodes::Document nodes
|
53
|
+
# as children.
|
54
|
+
#
|
55
|
+
# Psych::Nodes::Document nodes must have one and *only* one child. That child
|
56
|
+
# may be one of:
|
57
|
+
#
|
58
|
+
# * Psych::Nodes::Sequence
|
59
|
+
# * Psych::Nodes::Mapping
|
60
|
+
# * Psych::Nodes::Scalar
|
61
|
+
#
|
62
|
+
# Psych::Nodes::Sequence and Psych::Nodes::Mapping nodes may have many
|
63
|
+
# children, but Psych::Nodes::Mapping nodes should have an even number of
|
64
|
+
# children.
|
65
|
+
#
|
66
|
+
# All of these are valid children for Psych::Nodes::Sequence and
|
67
|
+
# Psych::Nodes::Mapping nodes:
|
68
|
+
#
|
69
|
+
# * Psych::Nodes::Sequence
|
70
|
+
# * Psych::Nodes::Mapping
|
71
|
+
# * Psych::Nodes::Scalar
|
72
|
+
# * Psych::Nodes::Alias
|
73
|
+
#
|
74
|
+
# Psych::Nodes::Scalar and Psych::Nodes::Alias are both terminal nodes and
|
75
|
+
# should not have any children.
|
76
|
+
module Nodes
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Psych
|
3
|
+
###
|
4
|
+
# YAML event parser class. This class parses a YAML document and calls
|
5
|
+
# events on the handler that is passed to the constructor. The events can
|
6
|
+
# be used for things such as constructing a YAML AST or deserializing YAML
|
7
|
+
# documents. It can even be fed back to Psych::Emitter to emit the same
|
8
|
+
# document that was parsed.
|
9
|
+
#
|
10
|
+
# See Psych::Handler for documentation on the events that Psych::Parser emits.
|
11
|
+
#
|
12
|
+
# Here is an example that prints out ever scalar found in a YAML document:
|
13
|
+
#
|
14
|
+
# # Handler for detecting scalar values
|
15
|
+
# class ScalarHandler < Psych::Handler
|
16
|
+
# def scalar value, anchor, tag, plain, quoted, style
|
17
|
+
# puts value
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# parser = Psych::Parser.new(ScalarHandler.new)
|
22
|
+
# parser.parse(yaml_document)
|
23
|
+
#
|
24
|
+
# Here is an example that feeds the parser back in to Psych::Emitter. The
|
25
|
+
# YAML document is read from STDIN and written back out to STDERR:
|
26
|
+
#
|
27
|
+
# parser = Psych::Parser.new(Psych::Emitter.new($stderr))
|
28
|
+
# parser.parse($stdin)
|
29
|
+
#
|
30
|
+
# Psych uses Psych::Parser in combination with Psych::TreeBuilder to
|
31
|
+
# construct an AST of the parsed YAML document.
|
32
|
+
|
33
|
+
class Parser
|
34
|
+
class Mark < Struct.new(:index, :line, :column)
|
35
|
+
end
|
36
|
+
|
37
|
+
# The handler on which events will be called
|
38
|
+
attr_accessor :handler
|
39
|
+
|
40
|
+
# Set the encoding for this parser to +encoding+
|
41
|
+
attr_writer :external_encoding
|
42
|
+
|
43
|
+
###
|
44
|
+
# Creates a new Psych::Parser instance with +handler+. YAML events will
|
45
|
+
# be called on +handler+. See Psych::Parser for more details.
|
46
|
+
|
47
|
+
def initialize handler = Handler.new
|
48
|
+
@handler = handler
|
49
|
+
@external_encoding = ANY
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Psych
|
4
|
+
###
|
5
|
+
# Scan scalars for built in types
|
6
|
+
class ScalarScanner
|
7
|
+
# Taken from http://yaml.org/type/timestamp.html
|
8
|
+
TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
|
9
|
+
|
10
|
+
# Taken from http://yaml.org/type/float.html
|
11
|
+
# Base 60, [-+]inf and NaN are handled separately
|
12
|
+
FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10))$/x
|
13
|
+
|
14
|
+
# Taken from http://yaml.org/type/int.html
|
15
|
+
INTEGER_STRICT = /^(?:[-+]?0b[0-1_]+ (?# base 2)
|
16
|
+
|[-+]?0[0-7_]+ (?# base 8)
|
17
|
+
|[-+]?(0|[1-9][0-9_]*) (?# base 10)
|
18
|
+
|[-+]?0x[0-9a-fA-F_]+ (?# base 16))$/x
|
19
|
+
|
20
|
+
# Same as above, but allows commas.
|
21
|
+
# Not to YML spec, but kept for backwards compatibility
|
22
|
+
INTEGER_LEGACY = /^(?:[-+]?0b[0-1_,]+ (?# base 2)
|
23
|
+
|[-+]?0[0-7_,]+ (?# base 8)
|
24
|
+
|[-+]?(?:0|[1-9](?:[0-9]|,[0-9]|_[0-9])*) (?# base 10)
|
25
|
+
|[-+]?0x[0-9a-fA-F_,]+ (?# base 16))$/x
|
26
|
+
|
27
|
+
attr_reader :class_loader
|
28
|
+
|
29
|
+
# Create a new scanner
|
30
|
+
def initialize class_loader, strict_integer: false
|
31
|
+
@symbol_cache = {}
|
32
|
+
@class_loader = class_loader
|
33
|
+
@strict_integer = strict_integer
|
34
|
+
end
|
35
|
+
|
36
|
+
# Tokenize +string+ returning the Ruby object
|
37
|
+
def tokenize string
|
38
|
+
return nil if string.empty?
|
39
|
+
return @symbol_cache[string] if @symbol_cache.key?(string)
|
40
|
+
integer_regex = @strict_integer ? INTEGER_STRICT : INTEGER_LEGACY
|
41
|
+
# Check for a String type, being careful not to get caught by hash keys, hex values, and
|
42
|
+
# special floats (e.g., -.inf).
|
43
|
+
if string.match?(%r{^[^\d.:-]?[[:alpha:]_\s!@#$%\^&*(){}<>|/\\~;=]+}) || string.match?(/\n/)
|
44
|
+
return string if string.length > 5
|
45
|
+
|
46
|
+
if string.match?(/^[^ytonf~]/i)
|
47
|
+
string
|
48
|
+
elsif string == '~' || string.match?(/^null$/i)
|
49
|
+
nil
|
50
|
+
elsif string.match?(/^(yes|true|on)$/i)
|
51
|
+
true
|
52
|
+
elsif string.match?(/^(no|false|off)$/i)
|
53
|
+
false
|
54
|
+
else
|
55
|
+
string
|
56
|
+
end
|
57
|
+
elsif string.match?(TIME)
|
58
|
+
begin
|
59
|
+
parse_time string
|
60
|
+
rescue ArgumentError
|
61
|
+
string
|
62
|
+
end
|
63
|
+
elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
|
64
|
+
require 'date'
|
65
|
+
begin
|
66
|
+
class_loader.date.strptime(string, '%Y-%m-%d')
|
67
|
+
rescue ArgumentError
|
68
|
+
string
|
69
|
+
end
|
70
|
+
elsif string.match?(/^\+?\.inf$/i)
|
71
|
+
Float::INFINITY
|
72
|
+
elsif string.match?(/^-\.inf$/i)
|
73
|
+
-Float::INFINITY
|
74
|
+
elsif string.match?(/^\.nan$/i)
|
75
|
+
Float::NAN
|
76
|
+
elsif string.match?(/^:./)
|
77
|
+
if string =~ /^:(["'])(.*)\1/
|
78
|
+
@symbol_cache[string] = class_loader.symbolize($2.sub(/^:/, ''))
|
79
|
+
else
|
80
|
+
@symbol_cache[string] = class_loader.symbolize(string.sub(/^:/, ''))
|
81
|
+
end
|
82
|
+
elsif string.match?(/^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}$/)
|
83
|
+
i = 0
|
84
|
+
string.split(':').each_with_index do |n,e|
|
85
|
+
i += (n.to_i * 60 ** (e - 2).abs)
|
86
|
+
end
|
87
|
+
i
|
88
|
+
elsif string.match?(/^[-+]?[0-9][0-9_]*(:[0-5]?[0-9]){1,2}\.[0-9_]*$/)
|
89
|
+
i = 0
|
90
|
+
string.split(':').each_with_index do |n,e|
|
91
|
+
i += (n.to_f * 60 ** (e - 2).abs)
|
92
|
+
end
|
93
|
+
i
|
94
|
+
elsif string.match?(FLOAT)
|
95
|
+
if string.match?(/\A[-+]?\.\Z/)
|
96
|
+
string
|
97
|
+
else
|
98
|
+
Float(string.delete(',_').gsub(/\.([Ee]|$)/, '\1'))
|
99
|
+
end
|
100
|
+
elsif string.match?(integer_regex)
|
101
|
+
parse_int string
|
102
|
+
else
|
103
|
+
string
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
###
|
108
|
+
# Parse and return an int from +string+
|
109
|
+
def parse_int string
|
110
|
+
Integer(string.delete(',_'))
|
111
|
+
end
|
112
|
+
|
113
|
+
###
|
114
|
+
# Parse and return a Time from +string+
|
115
|
+
def parse_time string
|
116
|
+
klass = class_loader.load 'Time'
|
117
|
+
|
118
|
+
date, time = *(string.split(/[ tT]/, 2))
|
119
|
+
(yy, m, dd) = date.match(/^(-?\d{4})-(\d{1,2})-(\d{1,2})/).captures.map { |x| x.to_i }
|
120
|
+
md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)
|
121
|
+
|
122
|
+
(hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
|
123
|
+
us = (md[2] ? Rational("0.#{md[2]}") : 0) * 1000000
|
124
|
+
|
125
|
+
time = klass.utc(yy, m, dd, hh, mm, ss, us)
|
126
|
+
|
127
|
+
return time if 'Z' == md[3]
|
128
|
+
return klass.at(time.to_i, us) unless md[3]
|
129
|
+
|
130
|
+
tz = md[3].match(/^([+\-]?\d{1,2})\:?(\d{1,2})?$/)[1..-1].compact.map { |digit| Integer(digit, 10) }
|
131
|
+
offset = tz.first * 3600
|
132
|
+
|
133
|
+
if offset < 0
|
134
|
+
offset -= ((tz[1] || 0) * 60)
|
135
|
+
else
|
136
|
+
offset += ((tz[1] || 0) * 60)
|
137
|
+
end
|
138
|
+
|
139
|
+
klass.new(yy, m, dd, hh, mm, ss+us/(1_000_000r), offset)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|