es_cli 0.1.0
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/.bundle/config +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/exe/es +8 -0
- data/lib/es_cli/cli.rb +247 -0
- data/lib/es_cli/version.rb +5 -0
- data/lib/es_cli.rb +11 -0
- data/readme.org +78 -0
- data/sig/es_cli.rbs +4 -0
- data/vendor/bundle/ruby/3.1.0/bin/rake +29 -0
- data/vendor/bundle/ruby/3.1.0/bin/thor +29 -0
- data/vendor/bundle/ruby/3.1.0/cache/event_stream_parser-1.0.0.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/faraday-2.12.2.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/faraday-multipart-1.1.0.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/faraday-net_http-3.4.0.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/json-2.9.1.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/logger-1.6.5.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/multipart-post-2.4.1.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/net-http-0.6.0.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/power_assert-2.0.5.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/rake-13.2.1.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/ruby-openai-7.3.1.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/test-unit-3.6.7.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/thor-1.3.2.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/cache/uri-1.0.2.gem +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/gem.build_complete +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/gem_make.out +22 -0
- data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/json/ext/generator.bundle +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/json/ext/parser.bundle +0 -0
- data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/mkmf.log +208 -0
- data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/LICENSE.md +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/README.md +99 -0
- data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/lib/event_stream_parser/version.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/lib/event_stream_parser.rb +222 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/CHANGELOG.md +574 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/README.md +67 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/Rakefile +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/examples/client_spec.rb +119 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/examples/client_test.rb +144 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/adapter/test.rb +311 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/adapter.rb +101 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/adapter_registry.rb +30 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/connection.rb +564 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/encoders/flat_params_encoder.rb +105 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/encoders/nested_params_encoder.rb +183 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/error.rb +165 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/logging/formatter.rb +118 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/methods.rb +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/middleware.rb +72 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/middleware_registry.rb +83 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/connection_options.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/env.rb +204 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/proxy_options.rb +36 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/request_options.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/ssl_options.rb +73 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options.rb +219 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/parameters.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/rack_builder.rb +251 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/authorization.rb +54 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/instrumentation.rb +58 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/json.rb +70 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/url_encoded.rb +60 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request.rb +139 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response/json.rb +74 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response/logger.rb +37 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response/raise_error.rb +83 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response.rb +91 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/utils/headers.rb +150 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/utils/params_hash.rb +61 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/utils.rb +121 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/version.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday.rb +157 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/external_adapters/faraday_specs_setup.rb +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/adapter/test_spec.rb +442 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/adapter_registry_spec.rb +28 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/adapter_spec.rb +55 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/connection_spec.rb +808 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/error_spec.rb +93 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/middleware_registry_spec.rb +31 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/middleware_spec.rb +213 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/env_spec.rb +76 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/options_spec.rb +297 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/proxy_options_spec.rb +52 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/request_options_spec.rb +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/params_encoders/flat_spec.rb +42 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/params_encoders/nested_spec.rb +151 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/rack_builder_spec.rb +317 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/authorization_spec.rb +118 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/instrumentation_spec.rb +74 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/json_spec.rb +199 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/url_encoded_spec.rb +93 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request_spec.rb +110 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response/json_spec.rb +206 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response/logger_spec.rb +278 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response/raise_error_spec.rb +275 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response_spec.rb +77 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/utils/headers_spec.rb +109 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/utils_spec.rb +119 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday_spec.rb +43 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/spec_helper.rb +133 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/disabling_stub.rb +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/fake_safe_buffer.rb +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/faraday_middleware_subclasses.rb +18 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/helper_methods.rb +96 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/shared_examples/adapter.rb +105 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/shared_examples/params_encoder.rb +18 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/shared_examples/request_method.rb +263 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/streaming_response_checker.rb +35 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/CHANGELOG.md +54 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/LICENSE.md +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/README.md +170 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/file_part.rb +130 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/middleware.rb +134 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/param_part.rb +55 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/version.rb +16 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart.rb +26 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/LICENSE.md +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/README.md +57 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/lib/faraday/adapter/net_http.rb +206 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/lib/faraday/net_http/version.rb +7 -0
- data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/lib/faraday/net_http.rb +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/BSDL +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/CHANGES.md +572 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/COPYING +56 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/LEGAL +60 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/README.md +195 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/fbuffer/fbuffer.h +214 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/.sitearchdir.-.json.-.ext.time +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/Makefile +269 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/extconf.rb +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/generator.bundle +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/generator.c +1691 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/generator.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/.sitearchdir.-.json.-.ext.time +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/Makefile +269 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/extconf.rb +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.bundle +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.c +3238 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.o +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.rl +1465 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/json.gemspec +64 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/bigdecimal.rb +58 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/complex.rb +51 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/core.rb +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/date.rb +54 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/date_time.rb +67 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/exception.rb +49 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/ostruct.rb +54 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/range.rb +54 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/rational.rb +49 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/regexp.rb +48 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/set.rb +48 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/struct.rb +52 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/symbol.rb +47 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/time.rb +52 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/common.rb +896 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext/generator/state.rb +116 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext/generator.bundle +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext/parser.bundle +0 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/generic_object.rb +75 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/truffle_ruby/generator.rb +629 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/version.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json.rb +587 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.github/dependabot.yml +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.github/workflows/push_gem.yml +46 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.github/workflows/test.yml +32 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.gitignore +11 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/BSDL +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/COPYING +56 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/Gemfile +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/README.md +104 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/Rakefile +30 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/bin/console +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/bin/setup +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/errors.rb +9 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/formatter.rb +36 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/log_device.rb +241 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/period.rb +47 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/severity.rb +38 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/version.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger.rb +761 -0
- data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/logger.gemspec +28 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/changelog.md +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/composite_io.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/composite_read_io.rb +91 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/multipartable.rb +70 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/parts.rb +148 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/upload_io.rb +64 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/version.rb +11 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post.rb +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart_post.rb +11 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipartable.rb +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/net/http/post/multipart.rb +28 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/parts.rb +25 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/license.md +58 -0
- data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/readme.md +170 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/BSDL +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/COPYING +56 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/Gemfile +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/README.md +93 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/Rakefile +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/bin/console +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/bin/setup +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/doc/net-http/examples.rdoc +31 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/doc/net-http/included_getters.rdoc +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/exceptions.rb +34 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/generic_request.rb +414 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/header.rb +981 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/proxy_delta.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/request.rb +88 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/requests.rb +430 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/response.rb +738 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/responses.rb +1174 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/status.rb +84 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http.rb +2580 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/https.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/net-http.gemspec +39 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/.github/dependabot.yml +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/.github/workflows/ci.yml +46 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/.gitignore +9 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/BSDL +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/COPYING +57 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/Gemfile +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/LEGAL +4 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/README.md +98 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/Rakefile +59 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/colorize.rb +7 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/configuration.rb +46 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/context.rb +233 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/enable_tracepoint_events.rb +62 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/inspector.rb +66 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/parser.rb +251 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/version.rb +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert.rb +93 -0
- data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/power_assert.gemspec +24 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/History.rdoc +2403 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/README.rdoc +155 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/command_line_usage.rdoc +158 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/Rakefile1 +38 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/Rakefile2 +35 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/a.c +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/b.c +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/main.c +11 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/glossary.rdoc +42 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/jamis.rb +592 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/proto_rake.rdoc +127 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/rake.1 +156 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/rakefile.rdoc +622 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/rational.rdoc +151 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/exe/rake +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/application.rb +861 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/backtrace.rb +25 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/clean.rb +78 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/cloneable.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/cpu_counter.rb +107 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/default_loader.rb +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/dsl_definition.rb +196 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/early_time.rb +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/ext/core.rb +26 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/ext/string.rb +176 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_creation_task.rb +25 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_list.rb +435 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_task.rb +58 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_utils.rb +132 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_utils_ext.rb +134 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/invocation_chain.rb +57 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/invocation_exception_mixin.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/late_time.rb +18 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/linked_list.rb +112 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/loaders/makefile.rb +54 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/multi_task.rb +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/name_space.rb +38 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/packagetask.rb +222 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/phony.rb +16 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/private_reader.rb +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/promise.rb +100 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/pseudo_status.rb +30 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/rake_module.rb +67 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/scope.rb +43 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task.rb +434 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task_argument_error.rb +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task_arguments.rb +109 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task_manager.rb +331 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/tasklib.rb +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/testtask.rb +189 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/thread_history_display.rb +49 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/thread_pool.rb +163 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/trace_output.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/version.rb +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/win32.rb +51 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake.rb +70 -0
- data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/rake.gemspec +101 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.circleci/config.yml +46 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.devcontainer/Dockerfile +16 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.devcontainer/devcontainer.json +36 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.devcontainer/docker-compose.yml +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/FUNDING.yml +13 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/dependabot.yml +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.gitignore +69 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.rspec +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.rubocop.yml +31 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/CHANGELOG.md +467 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/CODE_OF_CONDUCT.md +74 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/CONTRIBUTING.md +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/Gemfile +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/Gemfile.lock +92 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/LICENSE.txt +21 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/README.md +1381 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/Rakefile +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/bin/console +14 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/bin/setup +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/assistants.rb +29 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/audio.rb +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/batches.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/client.rb +122 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/compatibility.rb +10 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/files.rb +75 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/finetunes.rb +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/http.rb +134 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/http_headers.rb +36 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/images.rb +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/messages.rb +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/models.rb +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/run_steps.rb +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/runs.rb +37 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/threads.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/vector_store_file_batches.rb +29 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/vector_store_files.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/vector_stores.rb +27 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/version.rb +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai.rb +92 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/ruby/openai.rb +2 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/pull_request_template.md +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/ruby-openai.gemspec +32 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/BSDL +24 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/COPYING +64 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/PSFL +271 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/README.md +108 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/Rakefile +74 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/doc/text/getting-started.md +246 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/doc/text/how-to.md +90 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/doc/text/news.md +1853 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/assertion-failed-error.rb +60 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/assertions.rb +2541 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/attribute-matcher.rb +26 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/attribute.rb +228 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/auto-runner-loader.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/autorunner.rb +629 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/code-snippet-fetcher.rb +58 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/descendant.rb +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/dir.rb +110 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/load.rb +201 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/objectspace.rb +35 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/xml.rb +249 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector.rb +104 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/color-scheme.rb +225 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/color.rb +134 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/data-sets.rb +127 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/data.rb +371 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/diff.rb +745 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/error.rb +158 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/exception-handler.rb +82 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/failure.rb +169 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/fault-location-detector.rb +104 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/fixture.rb +304 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/notification.rb +138 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/omission.rb +198 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/pending.rb +155 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/priority.rb +194 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/runner/console.rb +86 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/runner/emacs.rb +8 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/runner/xml.rb +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/sub-test-result.rb +59 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/test-suite-creator.rb +103 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/test-suite-runner.rb +128 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/test-suite-thread-runner.rb +69 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/testcase.rb +963 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/testresult.rb +132 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/testsuite.rb +108 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/console/outputlevel.rb +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/console/testrunner.rb +891 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/testrunner.rb +53 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/testrunnermediator.rb +119 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/xml/testrunner.rb +224 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/backtracefilter.rb +59 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/memory-usage.rb +47 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/observable.rb +86 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/output.rb +32 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/procwrapper.rb +48 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/version.rb +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/warning.rb +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit.rb +521 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test-unit.rb +19 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/adder.rb +13 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/subtracter.rb +12 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/test_adder.rb +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/test_subtracter.rb +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/test_user.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/.document +5 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/CONTRIBUTING.md +15 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/README.md +45 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/bin/thor +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/create_file.rb +105 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/create_link.rb +61 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/directory.rb +108 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/empty_directory.rb +143 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb +371 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/inject_into_file.rb +130 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions.rb +340 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/base.rb +825 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/command.rb +151 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/core_ext/hash_with_indifferent_access.rb +107 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/error.rb +106 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/group.rb +292 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/invocation.rb +178 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/line_editor/basic.rb +37 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/line_editor/readline.rb +88 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/line_editor.rb +17 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/nested_context.rb +29 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/argument.rb +86 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/arguments.rb +195 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/option.rb +178 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/options.rb +294 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser.rb +4 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/rake_compat.rb +72 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/runner.rb +335 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/basic.rb +388 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/color.rb +115 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/column_printer.rb +29 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/html.rb +84 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/lcs_diff.rb +49 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/table_printer.rb +118 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/terminal.rb +42 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/wrapped_printer.rb +38 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell.rb +81 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/util.rb +285 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/version.rb +3 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor.rb +674 -0
- data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/thor.gemspec +33 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/BSDL +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/COPYING +56 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/README.md +55 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/common.rb +876 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/file.rb +100 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ftp.rb +267 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/generic.rb +1578 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/http.rb +125 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/https.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ldap.rb +261 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ldaps.rb +22 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/mailto.rb +293 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/rfc2396_parser.rb +546 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/rfc3986_parser.rb +206 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/version.rb +6 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ws.rb +83 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/wss.rb +23 -0
- data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri.rb +104 -0
- data/vendor/bundle/ruby/3.1.0/specifications/event_stream_parser-1.0.0.gemspec +23 -0
- data/vendor/bundle/ruby/3.1.0/specifications/faraday-2.12.2.gemspec +0 -0
- data/vendor/bundle/ruby/3.1.0/specifications/faraday-multipart-1.1.0.gemspec +32 -0
- data/vendor/bundle/ruby/3.1.0/specifications/faraday-net_http-3.4.0.gemspec +32 -0
- data/vendor/bundle/ruby/3.1.0/specifications/json-2.9.1.gemspec +0 -0
- data/vendor/bundle/ruby/3.1.0/specifications/logger-1.6.5.gemspec +22 -0
- data/vendor/bundle/ruby/3.1.0/specifications/multipart-post-2.4.1.gemspec +21 -0
- data/vendor/bundle/ruby/3.1.0/specifications/net-http-0.6.0.gemspec +33 -0
- data/vendor/bundle/ruby/3.1.0/specifications/power_assert-2.0.5.gemspec +24 -0
- data/vendor/bundle/ruby/3.1.0/specifications/rake-13.2.1.gemspec +26 -0
- data/vendor/bundle/ruby/3.1.0/specifications/ruby-openai-7.3.1.gemspec +36 -0
- data/vendor/bundle/ruby/3.1.0/specifications/test-unit-3.6.7.gemspec +31 -0
- data/vendor/bundle/ruby/3.1.0/specifications/thor-1.3.2.gemspec +34 -0
- data/vendor/bundle/ruby/3.1.0/specifications/uri-1.0.2.gemspec +23 -0
- metadata +560 -0
@@ -0,0 +1,896 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json/version'
|
4
|
+
|
5
|
+
module JSON
|
6
|
+
autoload :GenericObject, 'json/generic_object'
|
7
|
+
|
8
|
+
NOT_SET = Object.new.freeze
|
9
|
+
private_constant :NOT_SET
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# :call-seq:
|
13
|
+
# JSON[object] -> new_array or new_string
|
14
|
+
#
|
15
|
+
# If +object+ is a \String,
|
16
|
+
# calls JSON.parse with +object+ and +opts+ (see method #parse):
|
17
|
+
# json = '[0, 1, null]'
|
18
|
+
# JSON[json]# => [0, 1, nil]
|
19
|
+
#
|
20
|
+
# Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
|
21
|
+
# ruby = [0, 1, nil]
|
22
|
+
# JSON[ruby] # => '[0,1,null]'
|
23
|
+
def [](object, opts = {})
|
24
|
+
if object.is_a?(String)
|
25
|
+
return JSON.parse(object, opts)
|
26
|
+
elsif object.respond_to?(:to_str)
|
27
|
+
str = object.to_str
|
28
|
+
if str.is_a?(String)
|
29
|
+
return JSON.parse(str, opts)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
JSON.generate(object, opts)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the JSON parser class that is used by JSON.
|
37
|
+
attr_reader :parser
|
38
|
+
|
39
|
+
# Set the JSON parser class _parser_ to be used by JSON.
|
40
|
+
def parser=(parser) # :nodoc:
|
41
|
+
@parser = parser
|
42
|
+
remove_const :Parser if const_defined?(:Parser, false)
|
43
|
+
const_set :Parser, parser
|
44
|
+
end
|
45
|
+
|
46
|
+
# Return the constant located at _path_. The format of _path_ has to be
|
47
|
+
# either ::A::B::C or A::B::C. In any case, A has to be located at the top
|
48
|
+
# level (absolute namespace path?). If there doesn't exist a constant at
|
49
|
+
# the given path, an ArgumentError is raised.
|
50
|
+
def deep_const_get(path) # :nodoc:
|
51
|
+
Object.const_get(path)
|
52
|
+
rescue NameError => e
|
53
|
+
raise ArgumentError, "can't get const #{path}: #{e}"
|
54
|
+
end
|
55
|
+
|
56
|
+
# Set the module _generator_ to be used by JSON.
|
57
|
+
def generator=(generator) # :nodoc:
|
58
|
+
old, $VERBOSE = $VERBOSE, nil
|
59
|
+
@generator = generator
|
60
|
+
generator_methods = generator::GeneratorMethods
|
61
|
+
for const in generator_methods.constants
|
62
|
+
klass = const_get(const)
|
63
|
+
modul = generator_methods.const_get(const)
|
64
|
+
klass.class_eval do
|
65
|
+
instance_methods(false).each do |m|
|
66
|
+
m.to_s == 'to_json' and remove_method m
|
67
|
+
end
|
68
|
+
include modul
|
69
|
+
end
|
70
|
+
end
|
71
|
+
self.state = generator::State
|
72
|
+
const_set :State, self.state
|
73
|
+
const_set :SAFE_STATE_PROTOTYPE, State.new # for JRuby
|
74
|
+
const_set :FAST_STATE_PROTOTYPE, create_fast_state
|
75
|
+
const_set :PRETTY_STATE_PROTOTYPE, create_pretty_state
|
76
|
+
ensure
|
77
|
+
$VERBOSE = old
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_fast_state
|
81
|
+
State.new(
|
82
|
+
:indent => '',
|
83
|
+
:space => '',
|
84
|
+
:object_nl => "",
|
85
|
+
:array_nl => "",
|
86
|
+
:max_nesting => false
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_pretty_state
|
91
|
+
State.new(
|
92
|
+
:indent => ' ',
|
93
|
+
:space => ' ',
|
94
|
+
:object_nl => "\n",
|
95
|
+
:array_nl => "\n"
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns the JSON generator module that is used by JSON.
|
100
|
+
attr_reader :generator
|
101
|
+
|
102
|
+
# Sets or Returns the JSON generator state class that is used by JSON.
|
103
|
+
attr_accessor :state
|
104
|
+
end
|
105
|
+
|
106
|
+
# Sets create identifier, which is used to decide if the _json_create_
|
107
|
+
# hook of a class should be called; initial value is +json_class+:
|
108
|
+
# JSON.create_id # => 'json_class'
|
109
|
+
def self.create_id=(new_value)
|
110
|
+
Thread.current[:"JSON.create_id"] = new_value.dup.freeze
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns the current create identifier.
|
114
|
+
# See also JSON.create_id=.
|
115
|
+
def self.create_id
|
116
|
+
Thread.current[:"JSON.create_id"] || 'json_class'
|
117
|
+
end
|
118
|
+
|
119
|
+
NaN = 0.0/0
|
120
|
+
|
121
|
+
Infinity = 1.0/0
|
122
|
+
|
123
|
+
MinusInfinity = -Infinity
|
124
|
+
|
125
|
+
# The base exception for JSON errors.
|
126
|
+
class JSONError < StandardError
|
127
|
+
def self.wrap(exception)
|
128
|
+
obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
|
129
|
+
obj.set_backtrace exception.backtrace
|
130
|
+
obj
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# This exception is raised if a parser error occurs.
|
135
|
+
class ParserError < JSONError; end
|
136
|
+
|
137
|
+
# This exception is raised if the nesting of parsed data structures is too
|
138
|
+
# deep.
|
139
|
+
class NestingError < ParserError; end
|
140
|
+
|
141
|
+
# :stopdoc:
|
142
|
+
class CircularDatastructure < NestingError; end
|
143
|
+
# :startdoc:
|
144
|
+
|
145
|
+
# This exception is raised if a generator or unparser error occurs.
|
146
|
+
class GeneratorError < JSONError
|
147
|
+
attr_reader :invalid_object
|
148
|
+
|
149
|
+
def initialize(message, invalid_object = nil)
|
150
|
+
super(message)
|
151
|
+
@invalid_object = invalid_object
|
152
|
+
end
|
153
|
+
|
154
|
+
def detailed_message(...)
|
155
|
+
if @invalid_object.nil?
|
156
|
+
super
|
157
|
+
else
|
158
|
+
"#{super}\nInvalid object: #{@invalid_object.inspect}"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# For backwards compatibility
|
164
|
+
UnparserError = GeneratorError # :nodoc:
|
165
|
+
|
166
|
+
# This exception is raised if the required unicode support is missing on the
|
167
|
+
# system. Usually this means that the iconv library is not installed.
|
168
|
+
class MissingUnicodeSupport < JSONError; end
|
169
|
+
|
170
|
+
module_function
|
171
|
+
|
172
|
+
# :call-seq:
|
173
|
+
# JSON.parse(source, opts) -> object
|
174
|
+
#
|
175
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
176
|
+
#
|
177
|
+
# Argument +source+ contains the \String to be parsed.
|
178
|
+
#
|
179
|
+
# Argument +opts+, if given, contains a \Hash of options for the parsing.
|
180
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
181
|
+
#
|
182
|
+
# ---
|
183
|
+
#
|
184
|
+
# When +source+ is a \JSON array, returns a Ruby \Array:
|
185
|
+
# source = '["foo", 1.0, true, false, null]'
|
186
|
+
# ruby = JSON.parse(source)
|
187
|
+
# ruby # => ["foo", 1.0, true, false, nil]
|
188
|
+
# ruby.class # => Array
|
189
|
+
#
|
190
|
+
# When +source+ is a \JSON object, returns a Ruby \Hash:
|
191
|
+
# source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}'
|
192
|
+
# ruby = JSON.parse(source)
|
193
|
+
# ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
|
194
|
+
# ruby.class # => Hash
|
195
|
+
#
|
196
|
+
# For examples of parsing for all \JSON data types, see
|
197
|
+
# {Parsing \JSON}[#module-JSON-label-Parsing+JSON].
|
198
|
+
#
|
199
|
+
# Parses nested JSON objects:
|
200
|
+
# source = <<~JSON
|
201
|
+
# {
|
202
|
+
# "name": "Dave",
|
203
|
+
# "age" :40,
|
204
|
+
# "hats": [
|
205
|
+
# "Cattleman's",
|
206
|
+
# "Panama",
|
207
|
+
# "Tophat"
|
208
|
+
# ]
|
209
|
+
# }
|
210
|
+
# JSON
|
211
|
+
# ruby = JSON.parse(source)
|
212
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
213
|
+
#
|
214
|
+
# ---
|
215
|
+
#
|
216
|
+
# Raises an exception if +source+ is not valid JSON:
|
217
|
+
# # Raises JSON::ParserError (783: unexpected token at ''):
|
218
|
+
# JSON.parse('')
|
219
|
+
#
|
220
|
+
def parse(source, opts = nil)
|
221
|
+
Parser.parse(source, opts)
|
222
|
+
end
|
223
|
+
|
224
|
+
# :call-seq:
|
225
|
+
# JSON.parse!(source, opts) -> object
|
226
|
+
#
|
227
|
+
# Calls
|
228
|
+
# parse(source, opts)
|
229
|
+
# with +source+ and possibly modified +opts+.
|
230
|
+
#
|
231
|
+
# Differences from JSON.parse:
|
232
|
+
# - Option +max_nesting+, if not provided, defaults to +false+,
|
233
|
+
# which disables checking for nesting depth.
|
234
|
+
# - Option +allow_nan+, if not provided, defaults to +true+.
|
235
|
+
def parse!(source, opts = {})
|
236
|
+
opts = {
|
237
|
+
:max_nesting => false,
|
238
|
+
:allow_nan => true
|
239
|
+
}.merge(opts)
|
240
|
+
Parser.new(source, **(opts||{})).parse
|
241
|
+
end
|
242
|
+
|
243
|
+
# :call-seq:
|
244
|
+
# JSON.load_file(path, opts={}) -> object
|
245
|
+
#
|
246
|
+
# Calls:
|
247
|
+
# parse(File.read(path), opts)
|
248
|
+
#
|
249
|
+
# See method #parse.
|
250
|
+
def load_file(filespec, opts = nil)
|
251
|
+
parse(File.read(filespec, encoding: Encoding::UTF_8), opts)
|
252
|
+
end
|
253
|
+
|
254
|
+
# :call-seq:
|
255
|
+
# JSON.load_file!(path, opts = {})
|
256
|
+
#
|
257
|
+
# Calls:
|
258
|
+
# JSON.parse!(File.read(path, opts))
|
259
|
+
#
|
260
|
+
# See method #parse!
|
261
|
+
def load_file!(filespec, opts = {})
|
262
|
+
parse!(File.read(filespec, encoding: Encoding::UTF_8), opts)
|
263
|
+
end
|
264
|
+
|
265
|
+
# :call-seq:
|
266
|
+
# JSON.generate(obj, opts = nil) -> new_string
|
267
|
+
#
|
268
|
+
# Returns a \String containing the generated \JSON data.
|
269
|
+
#
|
270
|
+
# See also JSON.fast_generate, JSON.pretty_generate.
|
271
|
+
#
|
272
|
+
# Argument +obj+ is the Ruby object to be converted to \JSON.
|
273
|
+
#
|
274
|
+
# Argument +opts+, if given, contains a \Hash of options for the generation.
|
275
|
+
# See {Generating Options}[#module-JSON-label-Generating+Options].
|
276
|
+
#
|
277
|
+
# ---
|
278
|
+
#
|
279
|
+
# When +obj+ is an \Array, returns a \String containing a \JSON array:
|
280
|
+
# obj = ["foo", 1.0, true, false, nil]
|
281
|
+
# json = JSON.generate(obj)
|
282
|
+
# json # => '["foo",1.0,true,false,null]'
|
283
|
+
#
|
284
|
+
# When +obj+ is a \Hash, returns a \String containing a \JSON object:
|
285
|
+
# obj = {foo: 0, bar: 's', baz: :bat}
|
286
|
+
# json = JSON.generate(obj)
|
287
|
+
# json # => '{"foo":0,"bar":"s","baz":"bat"}'
|
288
|
+
#
|
289
|
+
# For examples of generating from other Ruby objects, see
|
290
|
+
# {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects].
|
291
|
+
#
|
292
|
+
# ---
|
293
|
+
#
|
294
|
+
# Raises an exception if any formatting option is not a \String.
|
295
|
+
#
|
296
|
+
# Raises an exception if +obj+ contains circular references:
|
297
|
+
# a = []; b = []; a.push(b); b.push(a)
|
298
|
+
# # Raises JSON::NestingError (nesting of 100 is too deep):
|
299
|
+
# JSON.generate(a)
|
300
|
+
#
|
301
|
+
def generate(obj, opts = nil)
|
302
|
+
if State === opts
|
303
|
+
opts.generate(obj)
|
304
|
+
else
|
305
|
+
State.generate(obj, opts, nil)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
# :stopdoc:
|
310
|
+
# I want to deprecate these later, so I'll first be silent about them, and
|
311
|
+
# later delete them.
|
312
|
+
alias unparse generate
|
313
|
+
module_function :unparse
|
314
|
+
# :startdoc:
|
315
|
+
|
316
|
+
# :call-seq:
|
317
|
+
# JSON.fast_generate(obj, opts) -> new_string
|
318
|
+
#
|
319
|
+
# Arguments +obj+ and +opts+ here are the same as
|
320
|
+
# arguments +obj+ and +opts+ in JSON.generate.
|
321
|
+
#
|
322
|
+
# By default, generates \JSON data without checking
|
323
|
+
# for circular references in +obj+ (option +max_nesting+ set to +false+, disabled).
|
324
|
+
#
|
325
|
+
# Raises an exception if +obj+ contains circular references:
|
326
|
+
# a = []; b = []; a.push(b); b.push(a)
|
327
|
+
# # Raises SystemStackError (stack level too deep):
|
328
|
+
# JSON.fast_generate(a)
|
329
|
+
def fast_generate(obj, opts = nil)
|
330
|
+
if State === opts
|
331
|
+
state = opts
|
332
|
+
else
|
333
|
+
state = JSON.create_fast_state.configure(opts)
|
334
|
+
end
|
335
|
+
state.generate(obj)
|
336
|
+
end
|
337
|
+
|
338
|
+
# :stopdoc:
|
339
|
+
# I want to deprecate these later, so I'll first be silent about them, and later delete them.
|
340
|
+
alias fast_unparse fast_generate
|
341
|
+
module_function :fast_unparse
|
342
|
+
# :startdoc:
|
343
|
+
|
344
|
+
# :call-seq:
|
345
|
+
# JSON.pretty_generate(obj, opts = nil) -> new_string
|
346
|
+
#
|
347
|
+
# Arguments +obj+ and +opts+ here are the same as
|
348
|
+
# arguments +obj+ and +opts+ in JSON.generate.
|
349
|
+
#
|
350
|
+
# Default options are:
|
351
|
+
# {
|
352
|
+
# indent: ' ', # Two spaces
|
353
|
+
# space: ' ', # One space
|
354
|
+
# array_nl: "\n", # Newline
|
355
|
+
# object_nl: "\n" # Newline
|
356
|
+
# }
|
357
|
+
#
|
358
|
+
# Example:
|
359
|
+
# obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}}
|
360
|
+
# json = JSON.pretty_generate(obj)
|
361
|
+
# puts json
|
362
|
+
# Output:
|
363
|
+
# {
|
364
|
+
# "foo": [
|
365
|
+
# "bar",
|
366
|
+
# "baz"
|
367
|
+
# ],
|
368
|
+
# "bat": {
|
369
|
+
# "bam": 0,
|
370
|
+
# "bad": 1
|
371
|
+
# }
|
372
|
+
# }
|
373
|
+
#
|
374
|
+
def pretty_generate(obj, opts = nil)
|
375
|
+
if State === opts
|
376
|
+
state, opts = opts, nil
|
377
|
+
else
|
378
|
+
state = JSON.create_pretty_state
|
379
|
+
end
|
380
|
+
if opts
|
381
|
+
if opts.respond_to? :to_hash
|
382
|
+
opts = opts.to_hash
|
383
|
+
elsif opts.respond_to? :to_h
|
384
|
+
opts = opts.to_h
|
385
|
+
else
|
386
|
+
raise TypeError, "can't convert #{opts.class} into Hash"
|
387
|
+
end
|
388
|
+
state.configure(opts)
|
389
|
+
end
|
390
|
+
state.generate(obj)
|
391
|
+
end
|
392
|
+
|
393
|
+
# :stopdoc:
|
394
|
+
# I want to deprecate these later, so I'll first be silent about them, and later delete them.
|
395
|
+
alias pretty_unparse pretty_generate
|
396
|
+
module_function :pretty_unparse
|
397
|
+
# :startdoc:
|
398
|
+
|
399
|
+
class << self
|
400
|
+
# Sets or returns default options for the JSON.unsafe_load method.
|
401
|
+
# Initially:
|
402
|
+
# opts = JSON.load_default_options
|
403
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
404
|
+
attr_accessor :unsafe_load_default_options
|
405
|
+
end
|
406
|
+
self.unsafe_load_default_options = {
|
407
|
+
:max_nesting => false,
|
408
|
+
:allow_nan => true,
|
409
|
+
:allow_blank => true,
|
410
|
+
:create_additions => true,
|
411
|
+
}
|
412
|
+
|
413
|
+
class << self
|
414
|
+
# Sets or returns default options for the JSON.load method.
|
415
|
+
# Initially:
|
416
|
+
# opts = JSON.load_default_options
|
417
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
|
418
|
+
attr_accessor :load_default_options
|
419
|
+
end
|
420
|
+
self.load_default_options = {
|
421
|
+
:allow_nan => true,
|
422
|
+
:allow_blank => true,
|
423
|
+
:create_additions => nil,
|
424
|
+
}
|
425
|
+
# :call-seq:
|
426
|
+
# JSON.unsafe_load(source, proc = nil, options = {}) -> object
|
427
|
+
#
|
428
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
429
|
+
#
|
430
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
431
|
+
# like from your own database server or clients under your control, it could
|
432
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
433
|
+
#
|
434
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
435
|
+
# - If +source+ responds to instance method +to_str+,
|
436
|
+
# <tt>source.to_str</tt> becomes the source.
|
437
|
+
# - If +source+ responds to instance method +to_io+,
|
438
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
439
|
+
# - If +source+ responds to instance method +read+,
|
440
|
+
# <tt>source.read</tt> becomes the source.
|
441
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
442
|
+
# - Option +allow_blank+ specifies a truthy value.
|
443
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
444
|
+
# - Otherwise, +source+ remains the source.
|
445
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
446
|
+
# It will be called recursively with each result (depth-first order).
|
447
|
+
# See details below.
|
448
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
449
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
450
|
+
# The default options can be changed via method JSON.unsafe_load_default_options=.
|
451
|
+
#
|
452
|
+
# ---
|
453
|
+
#
|
454
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
455
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
456
|
+
#
|
457
|
+
# Source for following examples:
|
458
|
+
# source = <<~JSON
|
459
|
+
# {
|
460
|
+
# "name": "Dave",
|
461
|
+
# "age" :40,
|
462
|
+
# "hats": [
|
463
|
+
# "Cattleman's",
|
464
|
+
# "Panama",
|
465
|
+
# "Tophat"
|
466
|
+
# ]
|
467
|
+
# }
|
468
|
+
# JSON
|
469
|
+
#
|
470
|
+
# Load a \String:
|
471
|
+
# ruby = JSON.unsafe_load(source)
|
472
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
473
|
+
#
|
474
|
+
# Load an \IO object:
|
475
|
+
# require 'stringio'
|
476
|
+
# object = JSON.unsafe_load(StringIO.new(source))
|
477
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
478
|
+
#
|
479
|
+
# Load a \File object:
|
480
|
+
# path = 't.json'
|
481
|
+
# File.write(path, source)
|
482
|
+
# File.open(path) do |file|
|
483
|
+
# JSON.unsafe_load(file)
|
484
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
485
|
+
#
|
486
|
+
# ---
|
487
|
+
#
|
488
|
+
# When +proc+ is given:
|
489
|
+
# - Modifies +source+ as above.
|
490
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
491
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
492
|
+
# - Returns the final result.
|
493
|
+
#
|
494
|
+
# Example:
|
495
|
+
# require 'json'
|
496
|
+
#
|
497
|
+
# # Some classes for the example.
|
498
|
+
# class Base
|
499
|
+
# def initialize(attributes)
|
500
|
+
# @attributes = attributes
|
501
|
+
# end
|
502
|
+
# end
|
503
|
+
# class User < Base; end
|
504
|
+
# class Account < Base; end
|
505
|
+
# class Admin < Base; end
|
506
|
+
# # The JSON source.
|
507
|
+
# json = <<-EOF
|
508
|
+
# {
|
509
|
+
# "users": [
|
510
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
511
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
512
|
+
# ],
|
513
|
+
# "accounts": [
|
514
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
515
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
516
|
+
# ],
|
517
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
518
|
+
# }
|
519
|
+
# EOF
|
520
|
+
# # Deserializer method.
|
521
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
522
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
523
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
524
|
+
# end
|
525
|
+
# # Call to JSON.unsafe_load
|
526
|
+
# ruby = JSON.unsafe_load(json, proc {|obj|
|
527
|
+
# case obj
|
528
|
+
# when Hash
|
529
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
530
|
+
# when Array
|
531
|
+
# obj.map! {|v| deserialize_obj v }
|
532
|
+
# end
|
533
|
+
# })
|
534
|
+
# pp ruby
|
535
|
+
# Output:
|
536
|
+
# {"users"=>
|
537
|
+
# [#<User:0x00000000064c4c98
|
538
|
+
# @attributes=
|
539
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
540
|
+
# #<User:0x00000000064c4bd0
|
541
|
+
# @attributes=
|
542
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
543
|
+
# "accounts"=>
|
544
|
+
# [{"account"=>
|
545
|
+
# #<Account:0x00000000064c4928
|
546
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
547
|
+
# {"account"=>
|
548
|
+
# #<Account:0x00000000064c4680
|
549
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
550
|
+
# "admins"=>
|
551
|
+
# #<Admin:0x00000000064c41f8
|
552
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
553
|
+
#
|
554
|
+
def unsafe_load(source, proc = nil, options = nil)
|
555
|
+
opts = if options.nil?
|
556
|
+
unsafe_load_default_options
|
557
|
+
else
|
558
|
+
unsafe_load_default_options.merge(options)
|
559
|
+
end
|
560
|
+
|
561
|
+
unless source.is_a?(String)
|
562
|
+
if source.respond_to? :to_str
|
563
|
+
source = source.to_str
|
564
|
+
elsif source.respond_to? :to_io
|
565
|
+
source = source.to_io.read
|
566
|
+
elsif source.respond_to?(:read)
|
567
|
+
source = source.read
|
568
|
+
end
|
569
|
+
end
|
570
|
+
|
571
|
+
if opts[:allow_blank] && (source.nil? || source.empty?)
|
572
|
+
source = 'null'
|
573
|
+
end
|
574
|
+
result = parse(source, opts)
|
575
|
+
recurse_proc(result, &proc) if proc
|
576
|
+
result
|
577
|
+
end
|
578
|
+
|
579
|
+
# :call-seq:
|
580
|
+
# JSON.load(source, proc = nil, options = {}) -> object
|
581
|
+
#
|
582
|
+
# Returns the Ruby objects created by parsing the given +source+.
|
583
|
+
#
|
584
|
+
# BEWARE: This method is meant to serialise data from trusted user input,
|
585
|
+
# like from your own database server or clients under your control, it could
|
586
|
+
# be dangerous to allow untrusted users to pass JSON sources into it.
|
587
|
+
# If you must use it, use JSON.unsafe_load instead to make it clear.
|
588
|
+
#
|
589
|
+
# Since JSON version 2.8.0, `load` emits a deprecation warning when a
|
590
|
+
# non native type is deserialized, without `create_additions` being explicitly
|
591
|
+
# enabled, and in JSON version 3.0, `load` will have `create_additions` disabled
|
592
|
+
# by default.
|
593
|
+
#
|
594
|
+
# - Argument +source+ must be, or be convertible to, a \String:
|
595
|
+
# - If +source+ responds to instance method +to_str+,
|
596
|
+
# <tt>source.to_str</tt> becomes the source.
|
597
|
+
# - If +source+ responds to instance method +to_io+,
|
598
|
+
# <tt>source.to_io.read</tt> becomes the source.
|
599
|
+
# - If +source+ responds to instance method +read+,
|
600
|
+
# <tt>source.read</tt> becomes the source.
|
601
|
+
# - If both of the following are true, source becomes the \String <tt>'null'</tt>:
|
602
|
+
# - Option +allow_blank+ specifies a truthy value.
|
603
|
+
# - The source, as defined above, is +nil+ or the empty \String <tt>''</tt>.
|
604
|
+
# - Otherwise, +source+ remains the source.
|
605
|
+
# - Argument +proc+, if given, must be a \Proc that accepts one argument.
|
606
|
+
# It will be called recursively with each result (depth-first order).
|
607
|
+
# See details below.
|
608
|
+
# - Argument +opts+, if given, contains a \Hash of options for the parsing.
|
609
|
+
# See {Parsing Options}[#module-JSON-label-Parsing+Options].
|
610
|
+
# The default options can be changed via method JSON.load_default_options=.
|
611
|
+
#
|
612
|
+
# ---
|
613
|
+
#
|
614
|
+
# When no +proc+ is given, modifies +source+ as above and returns the result of
|
615
|
+
# <tt>parse(source, opts)</tt>; see #parse.
|
616
|
+
#
|
617
|
+
# Source for following examples:
|
618
|
+
# source = <<~JSON
|
619
|
+
# {
|
620
|
+
# "name": "Dave",
|
621
|
+
# "age" :40,
|
622
|
+
# "hats": [
|
623
|
+
# "Cattleman's",
|
624
|
+
# "Panama",
|
625
|
+
# "Tophat"
|
626
|
+
# ]
|
627
|
+
# }
|
628
|
+
# JSON
|
629
|
+
#
|
630
|
+
# Load a \String:
|
631
|
+
# ruby = JSON.load(source)
|
632
|
+
# ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
633
|
+
#
|
634
|
+
# Load an \IO object:
|
635
|
+
# require 'stringio'
|
636
|
+
# object = JSON.load(StringIO.new(source))
|
637
|
+
# object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
638
|
+
#
|
639
|
+
# Load a \File object:
|
640
|
+
# path = 't.json'
|
641
|
+
# File.write(path, source)
|
642
|
+
# File.open(path) do |file|
|
643
|
+
# JSON.load(file)
|
644
|
+
# end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]}
|
645
|
+
#
|
646
|
+
# ---
|
647
|
+
#
|
648
|
+
# When +proc+ is given:
|
649
|
+
# - Modifies +source+ as above.
|
650
|
+
# - Gets the +result+ from calling <tt>parse(source, opts)</tt>.
|
651
|
+
# - Recursively calls <tt>proc(result)</tt>.
|
652
|
+
# - Returns the final result.
|
653
|
+
#
|
654
|
+
# Example:
|
655
|
+
# require 'json'
|
656
|
+
#
|
657
|
+
# # Some classes for the example.
|
658
|
+
# class Base
|
659
|
+
# def initialize(attributes)
|
660
|
+
# @attributes = attributes
|
661
|
+
# end
|
662
|
+
# end
|
663
|
+
# class User < Base; end
|
664
|
+
# class Account < Base; end
|
665
|
+
# class Admin < Base; end
|
666
|
+
# # The JSON source.
|
667
|
+
# json = <<-EOF
|
668
|
+
# {
|
669
|
+
# "users": [
|
670
|
+
# {"type": "User", "username": "jane", "email": "jane@example.com"},
|
671
|
+
# {"type": "User", "username": "john", "email": "john@example.com"}
|
672
|
+
# ],
|
673
|
+
# "accounts": [
|
674
|
+
# {"account": {"type": "Account", "paid": true, "account_id": "1234"}},
|
675
|
+
# {"account": {"type": "Account", "paid": false, "account_id": "1235"}}
|
676
|
+
# ],
|
677
|
+
# "admins": {"type": "Admin", "password": "0wn3d"}
|
678
|
+
# }
|
679
|
+
# EOF
|
680
|
+
# # Deserializer method.
|
681
|
+
# def deserialize_obj(obj, safe_types = %w(User Account Admin))
|
682
|
+
# type = obj.is_a?(Hash) && obj["type"]
|
683
|
+
# safe_types.include?(type) ? Object.const_get(type).new(obj) : obj
|
684
|
+
# end
|
685
|
+
# # Call to JSON.load
|
686
|
+
# ruby = JSON.load(json, proc {|obj|
|
687
|
+
# case obj
|
688
|
+
# when Hash
|
689
|
+
# obj.each {|k, v| obj[k] = deserialize_obj v }
|
690
|
+
# when Array
|
691
|
+
# obj.map! {|v| deserialize_obj v }
|
692
|
+
# end
|
693
|
+
# })
|
694
|
+
# pp ruby
|
695
|
+
# Output:
|
696
|
+
# {"users"=>
|
697
|
+
# [#<User:0x00000000064c4c98
|
698
|
+
# @attributes=
|
699
|
+
# {"type"=>"User", "username"=>"jane", "email"=>"jane@example.com"}>,
|
700
|
+
# #<User:0x00000000064c4bd0
|
701
|
+
# @attributes=
|
702
|
+
# {"type"=>"User", "username"=>"john", "email"=>"john@example.com"}>],
|
703
|
+
# "accounts"=>
|
704
|
+
# [{"account"=>
|
705
|
+
# #<Account:0x00000000064c4928
|
706
|
+
# @attributes={"type"=>"Account", "paid"=>true, "account_id"=>"1234"}>},
|
707
|
+
# {"account"=>
|
708
|
+
# #<Account:0x00000000064c4680
|
709
|
+
# @attributes={"type"=>"Account", "paid"=>false, "account_id"=>"1235"}>}],
|
710
|
+
# "admins"=>
|
711
|
+
# #<Admin:0x00000000064c41f8
|
712
|
+
# @attributes={"type"=>"Admin", "password"=>"0wn3d"}>}
|
713
|
+
#
|
714
|
+
def load(source, proc = nil, options = nil)
|
715
|
+
opts = if options.nil?
|
716
|
+
load_default_options
|
717
|
+
else
|
718
|
+
load_default_options.merge(options)
|
719
|
+
end
|
720
|
+
|
721
|
+
unless source.is_a?(String)
|
722
|
+
if source.respond_to? :to_str
|
723
|
+
source = source.to_str
|
724
|
+
elsif source.respond_to? :to_io
|
725
|
+
source = source.to_io.read
|
726
|
+
elsif source.respond_to?(:read)
|
727
|
+
source = source.read
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
731
|
+
if opts[:allow_blank] && (source.nil? || source.empty?)
|
732
|
+
source = 'null'
|
733
|
+
end
|
734
|
+
result = parse(source, opts)
|
735
|
+
recurse_proc(result, &proc) if proc
|
736
|
+
result
|
737
|
+
end
|
738
|
+
|
739
|
+
# Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
|
740
|
+
def recurse_proc(result, &proc) # :nodoc:
|
741
|
+
case result
|
742
|
+
when Array
|
743
|
+
result.each { |x| recurse_proc x, &proc }
|
744
|
+
proc.call result
|
745
|
+
when Hash
|
746
|
+
result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
|
747
|
+
proc.call result
|
748
|
+
else
|
749
|
+
proc.call result
|
750
|
+
end
|
751
|
+
end
|
752
|
+
|
753
|
+
alias restore load
|
754
|
+
module_function :restore
|
755
|
+
|
756
|
+
class << self
|
757
|
+
# Sets or returns the default options for the JSON.dump method.
|
758
|
+
# Initially:
|
759
|
+
# opts = JSON.dump_default_options
|
760
|
+
# opts # => {:max_nesting=>false, :allow_nan=>true}
|
761
|
+
attr_accessor :dump_default_options
|
762
|
+
end
|
763
|
+
self.dump_default_options = {
|
764
|
+
:max_nesting => false,
|
765
|
+
:allow_nan => true,
|
766
|
+
}
|
767
|
+
|
768
|
+
# :call-seq:
|
769
|
+
# JSON.dump(obj, io = nil, limit = nil)
|
770
|
+
#
|
771
|
+
# Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
|
772
|
+
#
|
773
|
+
# The default options can be changed via method JSON.dump_default_options.
|
774
|
+
#
|
775
|
+
# - Argument +io+, if given, should respond to method +write+;
|
776
|
+
# the \JSON \String is written to +io+, and +io+ is returned.
|
777
|
+
# If +io+ is not given, the \JSON \String is returned.
|
778
|
+
# - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+.
|
779
|
+
#
|
780
|
+
# ---
|
781
|
+
#
|
782
|
+
# When argument +io+ is not given, returns the \JSON \String generated from +obj+:
|
783
|
+
# obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad}
|
784
|
+
# json = JSON.dump(obj)
|
785
|
+
# json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}"
|
786
|
+
#
|
787
|
+
# When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+:
|
788
|
+
# path = 't.json'
|
789
|
+
# File.open(path, 'w') do |file|
|
790
|
+
# JSON.dump(obj, file)
|
791
|
+
# end # => #<File:t.json (closed)>
|
792
|
+
# puts File.read(path)
|
793
|
+
# Output:
|
794
|
+
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
795
|
+
def dump(obj, anIO = nil, limit = nil, kwargs = nil)
|
796
|
+
if kwargs.nil?
|
797
|
+
if limit.nil?
|
798
|
+
if anIO.is_a?(Hash)
|
799
|
+
kwargs = anIO
|
800
|
+
anIO = nil
|
801
|
+
end
|
802
|
+
elsif limit.is_a?(Hash)
|
803
|
+
kwargs = limit
|
804
|
+
limit = nil
|
805
|
+
end
|
806
|
+
end
|
807
|
+
|
808
|
+
unless anIO.nil?
|
809
|
+
if anIO.respond_to?(:to_io)
|
810
|
+
anIO = anIO.to_io
|
811
|
+
elsif limit.nil? && !anIO.respond_to?(:write)
|
812
|
+
anIO, limit = nil, anIO
|
813
|
+
end
|
814
|
+
end
|
815
|
+
|
816
|
+
opts = JSON.dump_default_options
|
817
|
+
opts = opts.merge(:max_nesting => limit) if limit
|
818
|
+
opts = merge_dump_options(opts, **kwargs) if kwargs
|
819
|
+
|
820
|
+
begin
|
821
|
+
if State === opts
|
822
|
+
opts.generate(obj, anIO)
|
823
|
+
else
|
824
|
+
State.generate(obj, opts, anIO)
|
825
|
+
end
|
826
|
+
rescue JSON::NestingError
|
827
|
+
raise ArgumentError, "exceed depth limit"
|
828
|
+
end
|
829
|
+
end
|
830
|
+
|
831
|
+
# Encodes string using String.encode.
|
832
|
+
def self.iconv(to, from, string)
|
833
|
+
string.encode(to, from)
|
834
|
+
end
|
835
|
+
|
836
|
+
def merge_dump_options(opts, strict: NOT_SET)
|
837
|
+
opts = opts.merge(strict: strict) if NOT_SET != strict
|
838
|
+
opts
|
839
|
+
end
|
840
|
+
|
841
|
+
class << self
|
842
|
+
private :merge_dump_options
|
843
|
+
end
|
844
|
+
end
|
845
|
+
|
846
|
+
module ::Kernel
|
847
|
+
private
|
848
|
+
|
849
|
+
# Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
|
850
|
+
# one line.
|
851
|
+
def j(*objs)
|
852
|
+
objs.each do |obj|
|
853
|
+
puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
|
854
|
+
end
|
855
|
+
nil
|
856
|
+
end
|
857
|
+
|
858
|
+
# Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
|
859
|
+
# indentation and over many lines.
|
860
|
+
def jj(*objs)
|
861
|
+
objs.each do |obj|
|
862
|
+
puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
|
863
|
+
end
|
864
|
+
nil
|
865
|
+
end
|
866
|
+
|
867
|
+
# If _object_ is string-like, parse the string and return the parsed result as
|
868
|
+
# a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
|
869
|
+
# structure object and return it.
|
870
|
+
#
|
871
|
+
# The _opts_ argument is passed through to generate/parse respectively. See
|
872
|
+
# generate and parse for their documentation.
|
873
|
+
def JSON(object, *args)
|
874
|
+
if object.is_a?(String)
|
875
|
+
return JSON.parse(object, args.first)
|
876
|
+
elsif object.respond_to?(:to_str)
|
877
|
+
str = object.to_str
|
878
|
+
if str.is_a?(String)
|
879
|
+
return JSON.parse(object.to_str, args.first)
|
880
|
+
end
|
881
|
+
end
|
882
|
+
|
883
|
+
JSON.generate(object, args.first)
|
884
|
+
end
|
885
|
+
end
|
886
|
+
|
887
|
+
# Extends any Class to include _json_creatable?_ method.
|
888
|
+
class ::Class
|
889
|
+
# Returns true if this class can be used to create an instance
|
890
|
+
# from a serialised JSON string. The class has to implement a class
|
891
|
+
# method _json_create_ that expects a hash as first parameter. The hash
|
892
|
+
# should include the required data.
|
893
|
+
def json_creatable?
|
894
|
+
respond_to?(:json_create)
|
895
|
+
end
|
896
|
+
end
|