logstash-output-scalyr 0.1.8 → 0.1.13
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 +4 -4
- data/CHANGELOG.md +27 -0
- data/Gemfile +5 -0
- data/README.md +3 -2
- data/lib/logstash/outputs/scalyr.rb +226 -138
- data/lib/scalyr/common/client.rb +76 -50
- data/lib/scalyr/common/util.rb +7 -0
- data/lib/scalyr/constants.rb +2 -0
- data/logstash-output-scalyr.gemspec +1 -1
- data/spec/logstash/outputs/scalyr_integration_spec.rb +148 -8
- data/spec/logstash/outputs/scalyr_spec.rb +12 -6
- data/vendor/bundle/jruby/2.5.0/bin/htmldiff +1 -1
- data/vendor/bundle/jruby/2.5.0/bin/ldiff +1 -1
- data/vendor/bundle/jruby/2.5.0/cache/addressable-2.7.0.gem +0 -0
- data/vendor/bundle/jruby/2.5.0/cache/crack-0.4.5.gem +0 -0
- data/vendor/bundle/jruby/2.5.0/cache/hashdiff-1.0.1.gem +0 -0
- data/vendor/bundle/jruby/2.5.0/cache/public_suffix-4.0.6.gem +0 -0
- data/vendor/bundle/jruby/2.5.0/cache/rexml-3.2.5.gem +0 -0
- data/vendor/bundle/jruby/2.5.0/cache/webmock-3.13.0.gem +0 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/CHANGELOG.md +235 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/Gemfile +32 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/LICENSE.txt +202 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/README.md +121 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/Rakefile +34 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/data/unicode.data +0 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable.rb +4 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable/idna.rb +27 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable/idna/native.rb +61 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable/idna/pure.rb +676 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable/template.rb +1045 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable/uri.rb +2529 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/lib/addressable/version.rb +32 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/addressable/idna_spec.rb +300 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/addressable/net_http_compat_spec.rb +30 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/addressable/rack_mount_compat_spec.rb +106 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/addressable/security_spec.rb +59 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/addressable/template_spec.rb +1451 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/addressable/uri_spec.rb +6603 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/spec/spec_helper.rb +24 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/tasks/clobber.rake +4 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/tasks/gem.rake +93 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/tasks/git.rake +47 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/tasks/metrics.rake +24 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/tasks/rspec.rake +23 -0
- data/vendor/bundle/jruby/2.5.0/gems/addressable-2.7.0/tasks/yard.rake +29 -0
- data/vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack.rb +7 -0
- data/vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/json.rb +98 -0
- data/vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/util.rb +17 -0
- data/vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/version.rb +3 -0
- data/vendor/bundle/jruby/2.5.0/gems/crack-0.4.5/lib/crack/xml.rb +238 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/Gemfile +8 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/LICENSE +19 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/README.md +276 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/Rakefile +18 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/changelog.md +100 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/hashdiff.gemspec +39 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff.rb +10 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/compare_hashes.rb +69 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/diff.rb +177 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs.rb +66 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/lcs_compare_arrays.rb +32 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/linear_compare_array.rb +159 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/patch.rb +88 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/util.rb +155 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/lib/hashdiff/version.rb +5 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/best_diff_spec.rb +75 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/diff_array_spec.rb +60 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/diff_spec.rb +360 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/lcs_spec.rb +76 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/linear_compare_array_spec.rb +50 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/patch_spec.rb +185 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/readme_spec.rb +15 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/hashdiff/util_spec.rb +116 -0
- data/vendor/bundle/jruby/2.5.0/gems/hashdiff-1.0.1/spec/spec_helper.rb +15 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/2.0-Upgrade.md +52 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/CHANGELOG.md +406 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/Gemfile +15 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/LICENSE.txt +22 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/README.md +207 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/Rakefile +51 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/SECURITY.md +104 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/bin/console +15 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/codecov.yml +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/data/list.txt +13380 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/lib/public_suffix.rb +179 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/lib/public_suffix/domain.rb +235 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/lib/public_suffix/errors.rb +41 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/lib/public_suffix/list.rb +247 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/lib/public_suffix/rule.rb +350 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/lib/public_suffix/version.rb +13 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/public_suffix.gemspec +29 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/acceptance_test.rb +131 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/benchmarks/bm_find.rb +66 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/benchmarks/bm_find_all.rb +102 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/benchmarks/bm_names.rb +91 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/benchmarks/bm_select.rb +26 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/benchmarks/bm_select_incremental.rb +25 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/benchmarks/bm_valid.rb +101 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/profilers/domain_profiler.rb +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/profilers/find_profiler.rb +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/profilers/find_profiler_jp.rb +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/profilers/initialization_profiler.rb +11 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/profilers/list_profsize.rb +11 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/profilers/object_binsize.rb +57 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/psl_test.rb +52 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/test_helper.rb +18 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/tests.txt +98 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/unit/domain_test.rb +106 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/unit/errors_test.rb +25 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/unit/list_test.rb +241 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/unit/public_suffix_test.rb +188 -0
- data/vendor/bundle/jruby/2.5.0/gems/public_suffix-4.0.6/test/unit/rule_test.rb +222 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/LICENSE.txt +22 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/NEWS.md +178 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/README.md +48 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/context.rdoc +143 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/rdoc/child.rdoc +87 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/rdoc/document.rdoc +276 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/rdoc/element.rdoc +602 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/rdoc/node.rdoc +97 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/rdoc/parent.rdoc +267 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/tocs/child_toc.rdoc +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/tocs/document_toc.rdoc +30 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/tocs/element_toc.rdoc +55 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/tocs/master_toc.rdoc +135 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/tocs/node_toc.rdoc +16 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/doc/rexml/tasks/tocs/parent_toc.rdoc +25 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml.rb +3 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/attlistdecl.rb +63 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/attribute.rb +205 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/cdata.rb +68 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/child.rb +97 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/comment.rb +80 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/doctype.rb +311 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/document.rb +451 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/dtd/attlistdecl.rb +11 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/dtd/dtd.rb +47 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/dtd/elementdecl.rb +18 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/dtd/entitydecl.rb +57 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/dtd/notationdecl.rb +40 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/element.rb +2599 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/encoding.rb +51 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/entity.rb +171 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/formatters/default.rb +116 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/formatters/pretty.rb +142 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/formatters/transitive.rb +58 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/functions.rb +447 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/instruction.rb +79 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/light/node.rb +188 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/namespace.rb +59 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/node.rb +76 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/output.rb +30 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parent.rb +166 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parseexception.rb +52 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb +694 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/lightparser.rb +59 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb +197 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb +273 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/streamparser.rb +61 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/treeparser.rb +101 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/ultralightparser.rb +57 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/parsers/xpathparser.rb +689 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/quickpath.rb +266 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/rexml.rb +37 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/sax2listener.rb +98 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/security.rb +28 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/source.rb +298 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/streamlistener.rb +93 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/text.rb +424 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/undefinednamespaceexception.rb +9 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/validation/relaxng.rb +539 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/validation/validation.rb +144 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/validation/validationexception.rb +10 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/xmldecl.rb +130 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/xmltokens.rb +85 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/xpath.rb +81 -0
- data/vendor/bundle/jruby/2.5.0/gems/rexml-3.2.5/lib/rexml/xpath_parser.rb +974 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/CHANGELOG.md +1894 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/Gemfile +9 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/LICENSE +20 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/README.md +1176 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/Rakefile +38 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock.rb +59 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/api.rb +109 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/assertion_failure.rb +11 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/callback_registry.rb +35 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/config.rb +18 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/cucumber.rb +10 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/deprecation.rb +9 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/errors.rb +17 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/async_http_client_adapter.rb +216 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/curb_adapter.rb +351 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/em_http_request_adapter.rb +231 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/excon_adapter.rb +165 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_lib_adapter.rb +7 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_lib_adapter_registry.rb +19 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_rb/client.rb +17 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_rb/request.rb +16 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_rb/response.rb +64 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_rb/streamer.rb +29 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_rb/webmock.rb +68 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/http_rb_adapter.rb +37 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/httpclient_adapter.rb +259 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/manticore_adapter.rb +145 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/net_http.rb +385 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/net_http_response.rb +34 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/patron_adapter.rb +130 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb +174 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/matchers/any_arg_matcher.rb +13 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/matchers/hash_argument_matcher.rb +21 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/matchers/hash_excluding_matcher.rb +15 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/matchers/hash_including_matcher.rb +17 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/minitest.rb +41 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/rack_response.rb +69 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_body_diff.rb +64 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_execution_verifier.rb +77 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_pattern.rb +405 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_registry.rb +35 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_signature.rb +54 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_signature_snippet.rb +61 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/request_stub.rb +100 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/response.rb +159 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/responses_sequence.rb +40 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/rspec.rb +42 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/rspec/matchers.rb +27 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/rspec/matchers/request_pattern_matcher.rb +78 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/rspec/matchers/webmock_matcher.rb +67 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/stub_registry.rb +82 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/stub_request_snippet.rb +38 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/test_unit.rb +20 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/hash_counter.rb +39 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/hash_keys_stringifier.rb +25 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/hash_validator.rb +17 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/headers.rb +64 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/json.rb +67 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/query_mapper.rb +281 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/uri.rb +111 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/values_stringifier.rb +20 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/util/version_checker.rb +111 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/version.rb +3 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/lib/webmock/webmock.rb +163 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/minitest/test_helper.rb +34 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/minitest/test_webmock.rb +9 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/minitest/webmock_spec.rb +60 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/async_http_client/async_http_client_spec.rb +375 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +73 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/curb/curb_spec.rb +499 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/curb/curb_spec_helper.rb +147 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/em_http_request/em_http_request_spec.rb +462 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/em_http_request/em_http_request_spec_helper.rb +77 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/excon/excon_spec.rb +77 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/excon/excon_spec_helper.rb +52 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/http_rb/http_rb_spec.rb +93 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/http_rb/http_rb_spec_helper.rb +54 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/httpclient/httpclient_spec.rb +217 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/httpclient/httpclient_spec_helper.rb +57 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/manticore/manticore_spec.rb +107 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/manticore/manticore_spec_helper.rb +35 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/net_http/net_http_shared.rb +153 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/net_http/net_http_spec.rb +369 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/net_http/net_http_spec_helper.rb +64 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/net_http/real_net_http_spec.rb +20 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/patron/patron_spec.rb +125 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/patron/patron_spec_helper.rb +54 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/allowing_and_disabling_net_connect.rb +313 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/callbacks.rb +148 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/complex_cross_concern_behaviors.rb +36 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/enabling_and_disabling_webmock.rb +95 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/precedence_of_stubs.rb +15 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/request_expectations.rb +930 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/returning_declared_responses.rb +409 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/shared/stubbing_requests.rb +678 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/typhoeus/typhoeus_hydra_spec.rb +135 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/typhoeus/typhoeus_hydra_spec_helper.rb +60 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/acceptance/webmock_shared.rb +41 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/fixtures/test.txt +1 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/quality_spec.rb +84 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/spec_helper.rb +48 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/support/example_curl_output.txt +22 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/support/failures.rb +9 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/support/my_rack_app.rb +53 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/support/network_connection.rb +19 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/support/webmock_server.rb +70 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/api_spec.rb +175 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/errors_spec.rb +129 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/http_lib_adapters/http_lib_adapter_registry_spec.rb +17 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/http_lib_adapters/http_lib_adapter_spec.rb +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/matchers/hash_excluding_matcher_spec.rb +61 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/matchers/hash_including_matcher_spec.rb +87 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/rack_response_spec.rb +112 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_body_diff_spec.rb +90 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_execution_verifier_spec.rb +208 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_pattern_spec.rb +736 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_registry_spec.rb +95 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_signature_snippet_spec.rb +89 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_signature_spec.rb +155 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/request_stub_spec.rb +199 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/response_spec.rb +286 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/stub_registry_spec.rb +103 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/stub_request_snippet_spec.rb +115 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/hash_counter_spec.rb +39 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/hash_keys_stringifier_spec.rb +27 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/headers_spec.rb +28 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/json_spec.rb +33 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/query_mapper_spec.rb +157 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/uri_spec.rb +371 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/util/version_checker_spec.rb +65 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/spec/unit/webmock_spec.rb +60 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/http_request.rb +24 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/shared_test.rb +108 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/test_helper.rb +23 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/test/test_webmock.rb +12 -0
- data/vendor/bundle/jruby/2.5.0/gems/webmock-3.13.0/webmock.gemspec +54 -0
- data/vendor/bundle/jruby/2.5.0/specifications/addressable-2.7.0.gemspec +39 -0
- data/vendor/bundle/jruby/2.5.0/specifications/crack-0.4.5.gemspec +32 -0
- data/vendor/bundle/jruby/2.5.0/specifications/hashdiff-1.0.1.gemspec +46 -0
- data/vendor/bundle/jruby/2.5.0/specifications/public_suffix-4.0.6.gemspec +24 -0
- data/vendor/bundle/jruby/2.5.0/specifications/rexml-3.2.5.gemspec +42 -0
- data/vendor/bundle/jruby/2.5.0/specifications/webmock-3.13.0.gemspec +85 -0
- metadata +309 -2
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module WebMock
|
4
|
+
|
5
|
+
module Util
|
6
|
+
|
7
|
+
class Headers
|
8
|
+
|
9
|
+
def self.normalize_headers(headers)
|
10
|
+
return nil unless headers
|
11
|
+
array = headers.map { |name, value|
|
12
|
+
[name.to_s.split(/_|-/).map { |segment| segment.capitalize }.join("-"),
|
13
|
+
case value
|
14
|
+
when Regexp then value
|
15
|
+
when Array then (value.size == 1) ? value.first.to_s : value.map {|v| v.to_s}.sort
|
16
|
+
else value.to_s
|
17
|
+
end
|
18
|
+
]
|
19
|
+
}
|
20
|
+
Hash[*array.inject([]) {|r,x| r + x}]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.sorted_headers_string(headers)
|
24
|
+
headers = WebMock::Util::Headers.normalize_headers(headers)
|
25
|
+
str = '{'.dup
|
26
|
+
str << headers.map do |k,v|
|
27
|
+
v = case v
|
28
|
+
when Regexp then v.inspect
|
29
|
+
when Array then "["+v.map{|w| "'#{w.to_s}'"}.join(", ")+"]"
|
30
|
+
else "'#{v.to_s}'"
|
31
|
+
end
|
32
|
+
"'#{k}'=>#{v}"
|
33
|
+
end.sort.join(", ")
|
34
|
+
str << '}'
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.pp_headers_string(headers)
|
38
|
+
headers = WebMock::Util::Headers.normalize_headers(headers)
|
39
|
+
seperator = "\n\t "
|
40
|
+
str = "{#{seperator} ".dup
|
41
|
+
str << headers.map do |k,v|
|
42
|
+
v = case v
|
43
|
+
when Regexp then v.inspect
|
44
|
+
when Array then "["+v.map{|w| "'#{w.to_s}'"}.join(", ")+"]"
|
45
|
+
else "'#{v.to_s}'"
|
46
|
+
end
|
47
|
+
"'#{k}'=>#{v}"
|
48
|
+
end.sort.join(",#{seperator} ")
|
49
|
+
str << "\n }"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.decode_userinfo_from_header(header)
|
53
|
+
header.sub(/^Basic /, "").unpack("m").first
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.basic_auth_header(*credentials)
|
57
|
+
"Basic #{Base64.strict_encode64(credentials.join(':')).chomp}"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# This is a copy of https://github.com/jnunemaker/crack/blob/master/lib/crack/json.rb
|
2
|
+
# with date parsing removed
|
3
|
+
# Copyright (c) 2004-2008 David Heinemeier Hansson
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
7
|
+
|
8
|
+
module WebMock
|
9
|
+
module Util
|
10
|
+
class JSON
|
11
|
+
class ParseError < StandardError; end
|
12
|
+
|
13
|
+
def self.parse(json)
|
14
|
+
yaml = unescape(convert_json_to_yaml(json))
|
15
|
+
YAML.load(yaml)
|
16
|
+
rescue ArgumentError => e
|
17
|
+
raise ParseError, "Invalid JSON string: #{yaml}, Error: #{e.inspect}"
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
def self.unescape(str)
|
22
|
+
str.gsub(/\\u([0-9a-f]{4})/) { [$1.hex].pack("U") }
|
23
|
+
end
|
24
|
+
|
25
|
+
# Ensure that ":" and "," are always followed by a space
|
26
|
+
def self.convert_json_to_yaml(json) #:nodoc:
|
27
|
+
scanner, quoting, marks, times = StringScanner.new(json), false, [], []
|
28
|
+
while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/)
|
29
|
+
case char = scanner[1]
|
30
|
+
when '"', "'"
|
31
|
+
if !quoting
|
32
|
+
quoting = char
|
33
|
+
elsif quoting == char
|
34
|
+
quoting = false
|
35
|
+
end
|
36
|
+
when ":",","
|
37
|
+
marks << scanner.pos - 1 unless quoting
|
38
|
+
when "\\"
|
39
|
+
scanner.skip(/\\/)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if marks.empty?
|
44
|
+
json.gsub(/\\\//, '/')
|
45
|
+
else
|
46
|
+
left_pos = [-1].push(*marks)
|
47
|
+
right_pos = marks << json.bytesize
|
48
|
+
output = []
|
49
|
+
|
50
|
+
left_pos.each_with_index do |left, i|
|
51
|
+
if json.respond_to?(:byteslice)
|
52
|
+
output << json.byteslice(left.succ..right_pos[i])
|
53
|
+
else
|
54
|
+
output << json[left.succ..right_pos[i]]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
output = output * " "
|
59
|
+
|
60
|
+
times.each { |i| output[i-1] = ' ' }
|
61
|
+
output.gsub!(/\\\//, '/')
|
62
|
+
output
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,281 @@
|
|
1
|
+
module WebMock::Util
|
2
|
+
class QueryMapper
|
3
|
+
class << self
|
4
|
+
#This class is based on Addressable::URI pre 2.3.0
|
5
|
+
|
6
|
+
##
|
7
|
+
# Converts the query component to a Hash value.
|
8
|
+
#
|
9
|
+
# @option [Symbol] notation
|
10
|
+
# May be one of <code>:flat</code>, <code>:dot</code>, or
|
11
|
+
# <code>:subscript</code>. The <code>:dot</code> notation is not
|
12
|
+
# supported for assignment. Default value is <code>:subscript</code>.
|
13
|
+
#
|
14
|
+
# @return [Hash, Array] The query string parsed as a Hash or Array object.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# WebMock::Util::QueryMapper.query_to_values("?one=1&two=2&three=3")
|
18
|
+
# #=> {"one" => "1", "two" => "2", "three" => "3"}
|
19
|
+
# WebMock::Util::QueryMapper("?one[two][three]=four").query_values
|
20
|
+
# #=> {"one" => {"two" => {"three" => "four"}}}
|
21
|
+
# WebMock::Util::QueryMapper.query_to_values("?one.two.three=four",
|
22
|
+
# :notation => :dot
|
23
|
+
# )
|
24
|
+
# #=> {"one" => {"two" => {"three" => "four"}}}
|
25
|
+
# WebMock::Util::QueryMapper.query_to_values("?one[two][three]=four",
|
26
|
+
# :notation => :flat
|
27
|
+
# )
|
28
|
+
# #=> {"one[two][three]" => "four"}
|
29
|
+
# WebMock::Util::QueryMapper.query_to_values("?one.two.three=four",
|
30
|
+
# :notation => :flat
|
31
|
+
# )
|
32
|
+
# #=> {"one.two.three" => "four"}
|
33
|
+
# WebMock::Util::QueryMapper(
|
34
|
+
# "?one[two][three][]=four&one[two][three][]=five"
|
35
|
+
# )
|
36
|
+
# #=> {"one" => {"two" => {"three" => ["four", "five"]}}}
|
37
|
+
# WebMock::Util::QueryMapper.query_to_values(
|
38
|
+
# "?one=two&one=three").query_values(:notation => :flat_array)
|
39
|
+
# #=> [['one', 'two'], ['one', 'three']]
|
40
|
+
def query_to_values(query, options={})
|
41
|
+
return nil if query.nil?
|
42
|
+
query = query.dup.force_encoding('utf-8') if query.respond_to?(:force_encoding)
|
43
|
+
|
44
|
+
options[:notation] ||= :subscript
|
45
|
+
|
46
|
+
if ![:flat, :dot, :subscript, :flat_array].include?(options[:notation])
|
47
|
+
raise ArgumentError,
|
48
|
+
'Invalid notation. Must be one of: ' +
|
49
|
+
'[:flat, :dot, :subscript, :flat_array].'
|
50
|
+
end
|
51
|
+
|
52
|
+
empty_accumulator = :flat_array == options[:notation] ? [] : {}
|
53
|
+
|
54
|
+
query_array = collect_query_parts(query)
|
55
|
+
|
56
|
+
query_hash = collect_query_hash(query_array, empty_accumulator, options)
|
57
|
+
|
58
|
+
normalize_query_hash(query_hash, empty_accumulator, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def normalize_query_hash(query_hash, empty_accumulator, options)
|
62
|
+
query_hash.inject(empty_accumulator.dup) do |accumulator, (key, value)|
|
63
|
+
if options[:notation] == :flat_array
|
64
|
+
accumulator << [key, value]
|
65
|
+
else
|
66
|
+
accumulator[key] = value.kind_of?(Hash) ? dehash(value) : value
|
67
|
+
end
|
68
|
+
accumulator
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def collect_query_parts(query)
|
73
|
+
query_parts = query.split('&').map do |pair|
|
74
|
+
pair.split('=', 2) if pair && !pair.empty?
|
75
|
+
end
|
76
|
+
query_parts.compact
|
77
|
+
end
|
78
|
+
|
79
|
+
def collect_query_hash(query_array, empty_accumulator, options)
|
80
|
+
query_array.compact.inject(empty_accumulator.dup) do |accumulator, (key, value)|
|
81
|
+
value = if value.nil?
|
82
|
+
nil
|
83
|
+
else
|
84
|
+
::Addressable::URI.unencode_component(value.tr('+', ' '))
|
85
|
+
end
|
86
|
+
key = Addressable::URI.unencode_component(key)
|
87
|
+
key = key.dup.force_encoding(Encoding::ASCII_8BIT) if key.respond_to?(:force_encoding)
|
88
|
+
self.__send__("fill_accumulator_for_#{options[:notation]}", accumulator, key, value)
|
89
|
+
accumulator
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def fill_accumulator_for_flat(accumulator, key, value)
|
94
|
+
if accumulator[key]
|
95
|
+
raise ArgumentError, "Key was repeated: #{key.inspect}"
|
96
|
+
end
|
97
|
+
accumulator[key] = value
|
98
|
+
end
|
99
|
+
|
100
|
+
def fill_accumulator_for_flat_array(accumulator, key, value)
|
101
|
+
accumulator << [key, value]
|
102
|
+
end
|
103
|
+
|
104
|
+
def fill_accumulator_for_dot(accumulator, key, value)
|
105
|
+
array_value = false
|
106
|
+
subkeys = key.split(".")
|
107
|
+
current_hash = accumulator
|
108
|
+
subkeys[0..-2].each do |subkey|
|
109
|
+
current_hash[subkey] = {} unless current_hash[subkey]
|
110
|
+
current_hash = current_hash[subkey]
|
111
|
+
end
|
112
|
+
if array_value
|
113
|
+
if current_hash[subkeys.last] && !current_hash[subkeys.last].is_a?(Array)
|
114
|
+
current_hash[subkeys.last] = [current_hash[subkeys.last]]
|
115
|
+
end
|
116
|
+
current_hash[subkeys.last] = [] unless current_hash[subkeys.last]
|
117
|
+
current_hash[subkeys.last] << value
|
118
|
+
else
|
119
|
+
current_hash[subkeys.last] = value
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def fill_accumulator_for_subscript(accumulator, key, value)
|
124
|
+
current_node = accumulator
|
125
|
+
subkeys = key.split(/(?=\[[^\[\]]+)/)
|
126
|
+
subkeys[0..-2].each do |subkey|
|
127
|
+
node = subkey =~ /\[\]\z/ ? [] : {}
|
128
|
+
subkey = subkey.gsub(/[\[\]]/, '')
|
129
|
+
if current_node.is_a? Array
|
130
|
+
container = current_node.find { |n| n.is_a?(Hash) && n.has_key?(subkey) }
|
131
|
+
if container
|
132
|
+
current_node = container[subkey]
|
133
|
+
else
|
134
|
+
current_node << {subkey => node}
|
135
|
+
current_node = node
|
136
|
+
end
|
137
|
+
else
|
138
|
+
current_node[subkey] = node unless current_node[subkey]
|
139
|
+
current_node = current_node[subkey]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
last_key = subkeys.last
|
143
|
+
array_value = !!(last_key =~ /\[\]$/)
|
144
|
+
last_key = last_key.gsub(/[\[\]]/, '')
|
145
|
+
if current_node.is_a? Array
|
146
|
+
last_container = current_node.select { |n| n.is_a?(Hash) }.last
|
147
|
+
if last_container && !last_container.has_key?(last_key)
|
148
|
+
if array_value
|
149
|
+
last_container[last_key] ||= []
|
150
|
+
last_container[last_key] << value
|
151
|
+
else
|
152
|
+
last_container[last_key] = value
|
153
|
+
end
|
154
|
+
else
|
155
|
+
if array_value
|
156
|
+
current_node << {last_key => [value]}
|
157
|
+
else
|
158
|
+
current_node << {last_key => value}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else
|
162
|
+
if array_value
|
163
|
+
current_node[last_key] ||= []
|
164
|
+
current_node[last_key] << value unless value.nil?
|
165
|
+
else
|
166
|
+
current_node[last_key] = value
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Sets the query component for this URI from a Hash object.
|
173
|
+
# This method produces a query string using the :subscript notation.
|
174
|
+
# An empty Hash will result in a nil query.
|
175
|
+
#
|
176
|
+
# @param [Hash, #to_hash, Array] new_query_values The new query values.
|
177
|
+
def values_to_query(new_query_values, options = {})
|
178
|
+
options[:notation] ||= :subscript
|
179
|
+
return if new_query_values.nil?
|
180
|
+
|
181
|
+
unless new_query_values.is_a?(Array)
|
182
|
+
unless new_query_values.respond_to?(:to_hash)
|
183
|
+
raise TypeError,
|
184
|
+
"Can't convert #{new_query_values.class} into Hash."
|
185
|
+
end
|
186
|
+
new_query_values = new_query_values.to_hash
|
187
|
+
new_query_values = new_query_values.inject([]) do |object, (key, value)|
|
188
|
+
key = key.to_s if key.is_a?(::Symbol) || key.nil?
|
189
|
+
if value.is_a?(Array) && value.empty?
|
190
|
+
object << [key.to_s + '[]']
|
191
|
+
elsif value.is_a?(Array)
|
192
|
+
value.each { |v| object << [key.to_s + '[]', v] }
|
193
|
+
elsif value.is_a?(Hash)
|
194
|
+
value.each { |k, v| object << ["#{key.to_s}[#{k}]", v]}
|
195
|
+
else
|
196
|
+
object << [key.to_s, value]
|
197
|
+
end
|
198
|
+
object
|
199
|
+
end
|
200
|
+
# Useful default for OAuth and caching.
|
201
|
+
# Only to be used for non-Array inputs. Arrays should preserve order.
|
202
|
+
begin
|
203
|
+
new_query_values.sort! # may raise for non-comparable values
|
204
|
+
rescue NoMethodError, ArgumentError
|
205
|
+
# ignore
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
buffer = ''.dup
|
210
|
+
new_query_values.each do |parent, value|
|
211
|
+
encoded_parent = ::Addressable::URI.encode_component(
|
212
|
+
parent.dup, ::Addressable::URI::CharacterClasses::UNRESERVED
|
213
|
+
)
|
214
|
+
buffer << "#{to_query(encoded_parent, value, options)}&"
|
215
|
+
end
|
216
|
+
buffer.chop
|
217
|
+
end
|
218
|
+
|
219
|
+
def dehash(hash)
|
220
|
+
hash.each do |(key, value)|
|
221
|
+
if value.is_a?(::Hash)
|
222
|
+
hash[key] = self.dehash(value)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
if hash != {} && hash.keys.all? { |key| key =~ /^\d+$/ }
|
226
|
+
hash.sort.inject([]) do |accu, (_, value)|
|
227
|
+
accu << value; accu
|
228
|
+
end
|
229
|
+
else
|
230
|
+
hash
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
##
|
235
|
+
# Joins and converts parent and value into a properly encoded and
|
236
|
+
# ordered URL query.
|
237
|
+
#
|
238
|
+
# @private
|
239
|
+
# @param [String] parent an URI encoded component.
|
240
|
+
# @param [Array, Hash, Symbol, #to_str] value
|
241
|
+
#
|
242
|
+
# @return [String] a properly escaped and ordered URL query.
|
243
|
+
|
244
|
+
# new_query_values have form [['key1', 'value1'], ['key2', 'value2']]
|
245
|
+
def to_query(parent, value, options = {})
|
246
|
+
options[:notation] ||= :subscript
|
247
|
+
case value
|
248
|
+
when ::Hash
|
249
|
+
value = value.map do |key, val|
|
250
|
+
[
|
251
|
+
::Addressable::URI.encode_component(key.to_s.dup, ::Addressable::URI::CharacterClasses::UNRESERVED),
|
252
|
+
val
|
253
|
+
]
|
254
|
+
end
|
255
|
+
value.sort!
|
256
|
+
buffer = ''.dup
|
257
|
+
value.each do |key, val|
|
258
|
+
new_parent = options[:notation] != :flat_array ? "#{parent}[#{key}]" : parent
|
259
|
+
buffer << "#{to_query(new_parent, val, options)}&"
|
260
|
+
end
|
261
|
+
buffer.chop
|
262
|
+
when ::Array
|
263
|
+
buffer = ''.dup
|
264
|
+
value.each_with_index do |val, i|
|
265
|
+
new_parent = options[:notation] != :flat_array ? "#{parent}[#{i}]" : parent
|
266
|
+
buffer << "#{to_query(new_parent, val, options)}&"
|
267
|
+
end
|
268
|
+
buffer.chop
|
269
|
+
when NilClass
|
270
|
+
parent
|
271
|
+
else
|
272
|
+
encoded_value = Addressable::URI.encode_component(
|
273
|
+
value.to_s.dup, Addressable::URI::CharacterClasses::UNRESERVED
|
274
|
+
)
|
275
|
+
"#{parent}=#{encoded_value}"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module WebMock
|
2
|
+
|
3
|
+
module Util
|
4
|
+
|
5
|
+
class URI
|
6
|
+
module CharacterClasses
|
7
|
+
USERINFO = Addressable::URI::CharacterClasses::UNRESERVED + Addressable::URI::CharacterClasses::SUB_DELIMS + "\\:"
|
8
|
+
end
|
9
|
+
|
10
|
+
ADDRESSABLE_URIS = Hash.new do |hash, key|
|
11
|
+
hash[key] = Addressable::URI.heuristic_parse(key)
|
12
|
+
end
|
13
|
+
|
14
|
+
NORMALIZED_URIS = Hash.new do |hash, uri|
|
15
|
+
normalized_uri = WebMock::Util::URI.heuristic_parse(uri)
|
16
|
+
if normalized_uri.query_values
|
17
|
+
sorted_query_values = sort_query_values(WebMock::Util::QueryMapper.query_to_values(normalized_uri.query, notation: Config.instance.query_values_notation) || {})
|
18
|
+
normalized_uri.query = WebMock::Util::QueryMapper.values_to_query(sorted_query_values, notation: WebMock::Config.instance.query_values_notation)
|
19
|
+
end
|
20
|
+
normalized_uri = normalized_uri.normalize #normalize! is slower
|
21
|
+
normalized_uri.query = normalized_uri.query.gsub("+", "%2B") if normalized_uri.query
|
22
|
+
normalized_uri.port = normalized_uri.inferred_port unless normalized_uri.port
|
23
|
+
hash[uri] = normalized_uri
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.heuristic_parse(uri)
|
27
|
+
ADDRESSABLE_URIS[uri].dup
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.normalize_uri(uri)
|
31
|
+
return uri if uri.is_a?(Regexp)
|
32
|
+
uri = 'http://' + uri unless uri.match('^https?://') if uri.is_a?(String)
|
33
|
+
NORMALIZED_URIS[uri].dup
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.variations_of_uri_as_strings(uri_object, only_with_scheme: false)
|
37
|
+
normalized_uri = normalize_uri(uri_object.dup).freeze
|
38
|
+
uris = [ normalized_uri ]
|
39
|
+
|
40
|
+
if normalized_uri.path == '/'
|
41
|
+
uris = uris_with_trailing_slash_and_without(uris)
|
42
|
+
end
|
43
|
+
|
44
|
+
if normalized_uri.port == Addressable::URI.port_mapping[normalized_uri.scheme]
|
45
|
+
uris = uris_with_inferred_port_and_without(uris)
|
46
|
+
end
|
47
|
+
|
48
|
+
uris = uris_encoded_and_unencoded(uris)
|
49
|
+
|
50
|
+
if normalized_uri.scheme == "http" && !only_with_scheme
|
51
|
+
uris = uris_with_scheme_and_without(uris)
|
52
|
+
end
|
53
|
+
|
54
|
+
uris.map {|uri| uri.to_s.gsub(/^\/\//,'') }.uniq
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.strip_default_port_from_uri_string(uri_string)
|
58
|
+
case uri_string
|
59
|
+
when %r{^http://} then uri_string.sub(%r{:80(/|$)}, '\1')
|
60
|
+
when %r{^https://} then uri_string.sub(%r{:443(/|$)}, '\1')
|
61
|
+
else uri_string
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.encode_unsafe_chars_in_userinfo(userinfo)
|
66
|
+
Addressable::URI.encode_component(userinfo, WebMock::Util::URI::CharacterClasses::USERINFO)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.is_uri_localhost?(uri)
|
70
|
+
uri.is_a?(Addressable::URI) &&
|
71
|
+
%w(localhost 127.0.0.1 0.0.0.0).include?(uri.host)
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def self.sort_query_values(query_values)
|
77
|
+
sorted_query_values = query_values.sort
|
78
|
+
query_values.is_a?(Hash) ? Hash[*sorted_query_values.inject([]) { |values, pair| values + pair}] : sorted_query_values
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.uris_with_inferred_port_and_without(uris)
|
82
|
+
uris.map { |uri|
|
83
|
+
[ uri, uri.omit(:port)]
|
84
|
+
}.flatten
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.uris_encoded_and_unencoded(uris)
|
88
|
+
uris.map do |uri|
|
89
|
+
[
|
90
|
+
uri.to_s.force_encoding(Encoding::ASCII_8BIT),
|
91
|
+
Addressable::URI.unencode(uri, String).force_encoding(Encoding::ASCII_8BIT).freeze
|
92
|
+
]
|
93
|
+
end.flatten
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.uris_with_scheme_and_without(uris)
|
97
|
+
uris.map { |uri|
|
98
|
+
[ uri, uri.gsub(%r{^https?://},"").freeze ]
|
99
|
+
}.flatten
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.uris_with_trailing_slash_and_without(uris)
|
103
|
+
uris.map { |uri|
|
104
|
+
[ uri, uri.omit(:path).freeze ]
|
105
|
+
}.flatten
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|