logstash-output-scalyr 0.1.10.beta → 0.1.11.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/README.md +2 -2
- data/lib/logstash/outputs/scalyr.rb +94 -73
- data/lib/scalyr/common/client.rb +3 -1
- data/lib/scalyr/constants.rb +2 -0
- data/logstash-output-scalyr.gemspec +1 -1
- data/spec/logstash/outputs/scalyr_integration_spec.rb +119 -8
- data/spec/logstash/outputs/scalyr_spec.rb +9 -6
- 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,121 @@
|
|
1
|
+
# Addressable
|
2
|
+
|
3
|
+
<dl>
|
4
|
+
<dt>Homepage</dt><dd><a href="https://github.com/sporkmonger/addressable">github.com/sporkmonger/addressable</a></dd>
|
5
|
+
<dt>Author</dt><dd><a href="mailto:bob@sporkmonger.com">Bob Aman</a></dd>
|
6
|
+
<dt>Copyright</dt><dd>Copyright © Bob Aman</dd>
|
7
|
+
<dt>License</dt><dd>Apache 2.0</dd>
|
8
|
+
</dl>
|
9
|
+
|
10
|
+
[![Gem Version](http://img.shields.io/gem/dt/addressable.svg)][gem]
|
11
|
+
[![Build Status](https://secure.travis-ci.org/sporkmonger/addressable.svg?branch=master)][travis]
|
12
|
+
[![Test Coverage Status](https://img.shields.io/coveralls/sporkmonger/addressable.svg)][coveralls]
|
13
|
+
[![Documentation Coverage Status](http://inch-ci.org/github/sporkmonger/addressable.svg?branch=master)][inch]
|
14
|
+
|
15
|
+
[gem]: https://rubygems.org/gems/addressable
|
16
|
+
[travis]: http://travis-ci.org/sporkmonger/addressable
|
17
|
+
[coveralls]: https://coveralls.io/r/sporkmonger/addressable
|
18
|
+
[inch]: http://inch-ci.org/github/sporkmonger/addressable
|
19
|
+
|
20
|
+
# Description
|
21
|
+
|
22
|
+
Addressable is an alternative implementation to the URI implementation
|
23
|
+
that is part of Ruby's standard library. It is flexible, offers heuristic
|
24
|
+
parsing, and additionally provides extensive support for IRIs and URI templates.
|
25
|
+
|
26
|
+
Addressable closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4).
|
27
|
+
|
28
|
+
# Reference
|
29
|
+
|
30
|
+
- {Addressable::URI}
|
31
|
+
- {Addressable::Template}
|
32
|
+
|
33
|
+
# Example usage
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require "addressable/uri"
|
37
|
+
|
38
|
+
uri = Addressable::URI.parse("http://example.com/path/to/resource/")
|
39
|
+
uri.scheme
|
40
|
+
#=> "http"
|
41
|
+
uri.host
|
42
|
+
#=> "example.com"
|
43
|
+
uri.path
|
44
|
+
#=> "/path/to/resource/"
|
45
|
+
|
46
|
+
uri = Addressable::URI.parse("http://www.詹姆斯.com/")
|
47
|
+
uri.normalize
|
48
|
+
#=> #<Addressable::URI:0xc9a4c8 URI:http://www.xn--8ws00zhy3a.com/>
|
49
|
+
```
|
50
|
+
|
51
|
+
|
52
|
+
# URI Templates
|
53
|
+
|
54
|
+
For more details, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.txt).
|
55
|
+
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
|
59
|
+
require "addressable/template"
|
60
|
+
|
61
|
+
template = Addressable::Template.new("http://example.com/{?query*}")
|
62
|
+
template.expand({
|
63
|
+
"query" => {
|
64
|
+
'foo' => 'bar',
|
65
|
+
'color' => 'red'
|
66
|
+
}
|
67
|
+
})
|
68
|
+
#=> #<Addressable::URI:0xc9d95c URI:http://example.com/?foo=bar&color=red>
|
69
|
+
|
70
|
+
template = Addressable::Template.new("http://example.com/{?one,two,three}")
|
71
|
+
template.partial_expand({"one" => "1", "three" => 3}).pattern
|
72
|
+
#=> "http://example.com/?one=1{&two}&three=3"
|
73
|
+
|
74
|
+
template = Addressable::Template.new(
|
75
|
+
"http://{host}{/segments*}/{?one,two,bogus}{#fragment}"
|
76
|
+
)
|
77
|
+
uri = Addressable::URI.parse(
|
78
|
+
"http://example.com/a/b/c/?one=1&two=2#foo"
|
79
|
+
)
|
80
|
+
template.extract(uri)
|
81
|
+
#=>
|
82
|
+
# {
|
83
|
+
# "host" => "example.com",
|
84
|
+
# "segments" => ["a", "b", "c"],
|
85
|
+
# "one" => "1",
|
86
|
+
# "two" => "2",
|
87
|
+
# "fragment" => "foo"
|
88
|
+
# }
|
89
|
+
```
|
90
|
+
|
91
|
+
# Install
|
92
|
+
|
93
|
+
```console
|
94
|
+
$ gem install addressable
|
95
|
+
```
|
96
|
+
|
97
|
+
You may optionally turn on native IDN support by installing libidn and the
|
98
|
+
idn gem:
|
99
|
+
|
100
|
+
```console
|
101
|
+
$ sudo apt-get install idn # Debian/Ubuntu
|
102
|
+
$ brew install libidn # OS X
|
103
|
+
$ gem install idn-ruby
|
104
|
+
```
|
105
|
+
|
106
|
+
# Semantic Versioning
|
107
|
+
|
108
|
+
This project uses [Semantic Versioning](https://semver.org/). You can (and should) specify your
|
109
|
+
dependency using a pessimistic version constraint covering the major and minor
|
110
|
+
values:
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
spec.add_dependency 'addressable', '~> 2.5'
|
114
|
+
```
|
115
|
+
|
116
|
+
If you need a specific bug fix, you can also specify minimum tiny versions
|
117
|
+
without preventing updates to the latest minor release:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
spec.add_dependency 'addressable', '~> 2.3', '>= 2.3.7'
|
121
|
+
```
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), 'lib', 'addressable', 'version')
|
7
|
+
|
8
|
+
PKG_DISPLAY_NAME = 'Addressable'
|
9
|
+
PKG_NAME = PKG_DISPLAY_NAME.downcase
|
10
|
+
PKG_VERSION = Addressable::VERSION::STRING
|
11
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
12
|
+
|
13
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
14
|
+
|
15
|
+
PKG_SUMMARY = "URI Implementation"
|
16
|
+
PKG_DESCRIPTION = <<-TEXT
|
17
|
+
Addressable is an alternative implementation to the URI implementation that is
|
18
|
+
part of Ruby's standard library. It is flexible, offers heuristic parsing, and
|
19
|
+
additionally provides extensive support for IRIs and URI templates.
|
20
|
+
TEXT
|
21
|
+
|
22
|
+
PKG_FILES = FileList[
|
23
|
+
"lib/**/*", "spec/**/*", "vendor/**/*", "data/**/*",
|
24
|
+
"tasks/**/*",
|
25
|
+
"[A-Z]*", "Rakefile"
|
26
|
+
].exclude(/pkg/).exclude(/database\.yml/).
|
27
|
+
exclude(/Gemfile\.lock/).exclude(/[_\.]git$/)
|
28
|
+
|
29
|
+
task :default => "spec"
|
30
|
+
|
31
|
+
WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
|
32
|
+
SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
|
33
|
+
|
34
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
Binary file
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# encoding:utf-8
|
4
|
+
#--
|
5
|
+
# Copyright (C) Bob Aman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
|
21
|
+
begin
|
22
|
+
require "addressable/idna/native"
|
23
|
+
rescue LoadError
|
24
|
+
# libidn or the idn gem was not available, fall back on a pure-Ruby
|
25
|
+
# implementation...
|
26
|
+
require "addressable/idna/pure"
|
27
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# encoding:utf-8
|
4
|
+
#--
|
5
|
+
# Copyright (C) Bob Aman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
|
21
|
+
require "idn"
|
22
|
+
|
23
|
+
module Addressable
|
24
|
+
module IDNA
|
25
|
+
def self.punycode_encode(value)
|
26
|
+
IDN::Punycode.encode(value.to_s)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.punycode_decode(value)
|
30
|
+
IDN::Punycode.decode(value.to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.unicode_normalize_kc(value)
|
34
|
+
IDN::Stringprep.nfkc_normalize(value.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.to_ascii(value)
|
38
|
+
value.to_s.split('.', -1).map do |segment|
|
39
|
+
if segment.size > 0 && segment.size < 64
|
40
|
+
IDN::Idna.toASCII(segment, IDN::Idna::ALLOW_UNASSIGNED)
|
41
|
+
elsif segment.size >= 64
|
42
|
+
segment
|
43
|
+
else
|
44
|
+
''
|
45
|
+
end
|
46
|
+
end.join('.')
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.to_unicode(value)
|
50
|
+
value.to_s.split('.', -1).map do |segment|
|
51
|
+
if segment.size > 0 && segment.size < 64
|
52
|
+
IDN::Idna.toUnicode(segment, IDN::Idna::ALLOW_UNASSIGNED)
|
53
|
+
elsif segment.size >= 64
|
54
|
+
segment
|
55
|
+
else
|
56
|
+
''
|
57
|
+
end
|
58
|
+
end.join('.')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,676 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# encoding:utf-8
|
4
|
+
#--
|
5
|
+
# Copyright (C) Bob Aman
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#++
|
19
|
+
|
20
|
+
|
21
|
+
module Addressable
|
22
|
+
module IDNA
|
23
|
+
# This module is loosely based on idn_actionmailer by Mick Staugaard,
|
24
|
+
# the unicode library by Yoshida Masato, and the punycode implementation
|
25
|
+
# by Kazuhiro Nishiyama. Most of the code was copied verbatim, but
|
26
|
+
# some reformatting was done, and some translation from C was done.
|
27
|
+
#
|
28
|
+
# Without their code to work from as a base, we'd all still be relying
|
29
|
+
# on the presence of libidn. Which nobody ever seems to have installed.
|
30
|
+
#
|
31
|
+
# Original sources:
|
32
|
+
# http://github.com/staugaard/idn_actionmailer
|
33
|
+
# http://www.yoshidam.net/Ruby.html#unicode
|
34
|
+
# http://rubyforge.org/frs/?group_id=2550
|
35
|
+
|
36
|
+
|
37
|
+
UNICODE_TABLE = File.expand_path(
|
38
|
+
File.join(File.dirname(__FILE__), '../../..', 'data/unicode.data')
|
39
|
+
)
|
40
|
+
|
41
|
+
ACE_PREFIX = "xn--"
|
42
|
+
|
43
|
+
UTF8_REGEX = /\A(?:
|
44
|
+
[\x09\x0A\x0D\x20-\x7E] # ASCII
|
45
|
+
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|
46
|
+
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
|
47
|
+
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
|
48
|
+
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
|
49
|
+
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
50
|
+
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4nil5
|
51
|
+
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
52
|
+
)*\z/mnx
|
53
|
+
|
54
|
+
UTF8_REGEX_MULTIBYTE = /(?:
|
55
|
+
[\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|
56
|
+
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
|
57
|
+
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
|
58
|
+
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
|
59
|
+
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
60
|
+
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4nil5
|
61
|
+
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
62
|
+
)/mnx
|
63
|
+
|
64
|
+
# :startdoc:
|
65
|
+
|
66
|
+
# Converts from a Unicode internationalized domain name to an ASCII
|
67
|
+
# domain name as described in RFC 3490.
|
68
|
+
def self.to_ascii(input)
|
69
|
+
input = input.to_s unless input.is_a?(String)
|
70
|
+
input = input.dup
|
71
|
+
if input.respond_to?(:force_encoding)
|
72
|
+
input.force_encoding(Encoding::ASCII_8BIT)
|
73
|
+
end
|
74
|
+
if input =~ UTF8_REGEX && input =~ UTF8_REGEX_MULTIBYTE
|
75
|
+
parts = unicode_downcase(input).split('.')
|
76
|
+
parts.map! do |part|
|
77
|
+
if part.respond_to?(:force_encoding)
|
78
|
+
part.force_encoding(Encoding::ASCII_8BIT)
|
79
|
+
end
|
80
|
+
if part =~ UTF8_REGEX && part =~ UTF8_REGEX_MULTIBYTE
|
81
|
+
ACE_PREFIX + punycode_encode(unicode_normalize_kc(part))
|
82
|
+
else
|
83
|
+
part
|
84
|
+
end
|
85
|
+
end
|
86
|
+
parts.join('.')
|
87
|
+
else
|
88
|
+
input
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Converts from an ASCII domain name to a Unicode internationalized
|
93
|
+
# domain name as described in RFC 3490.
|
94
|
+
def self.to_unicode(input)
|
95
|
+
input = input.to_s unless input.is_a?(String)
|
96
|
+
parts = input.split('.')
|
97
|
+
parts.map! do |part|
|
98
|
+
if part =~ /^#{ACE_PREFIX}(.+)/
|
99
|
+
begin
|
100
|
+
punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1])
|
101
|
+
rescue Addressable::IDNA::PunycodeBadInput
|
102
|
+
# toUnicode is explicitly defined as never-fails by the spec
|
103
|
+
part
|
104
|
+
end
|
105
|
+
else
|
106
|
+
part
|
107
|
+
end
|
108
|
+
end
|
109
|
+
output = parts.join('.')
|
110
|
+
if output.respond_to?(:force_encoding)
|
111
|
+
output.force_encoding(Encoding::UTF_8)
|
112
|
+
end
|
113
|
+
output
|
114
|
+
end
|
115
|
+
|
116
|
+
# Unicode normalization form KC.
|
117
|
+
def self.unicode_normalize_kc(input)
|
118
|
+
input = input.to_s unless input.is_a?(String)
|
119
|
+
unpacked = input.unpack("U*")
|
120
|
+
unpacked =
|
121
|
+
unicode_compose(unicode_sort_canonical(unicode_decompose(unpacked)))
|
122
|
+
return unpacked.pack("U*")
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# Unicode aware downcase method.
|
127
|
+
#
|
128
|
+
# @api private
|
129
|
+
# @param [String] input
|
130
|
+
# The input string.
|
131
|
+
# @return [String] The downcased result.
|
132
|
+
def self.unicode_downcase(input)
|
133
|
+
input = input.to_s unless input.is_a?(String)
|
134
|
+
unpacked = input.unpack("U*")
|
135
|
+
unpacked.map! { |codepoint| lookup_unicode_lowercase(codepoint) }
|
136
|
+
return unpacked.pack("U*")
|
137
|
+
end
|
138
|
+
private_class_method :unicode_downcase
|
139
|
+
|
140
|
+
def self.unicode_compose(unpacked)
|
141
|
+
unpacked_result = []
|
142
|
+
length = unpacked.length
|
143
|
+
|
144
|
+
return unpacked if length == 0
|
145
|
+
|
146
|
+
starter = unpacked[0]
|
147
|
+
starter_cc = lookup_unicode_combining_class(starter)
|
148
|
+
starter_cc = 256 if starter_cc != 0
|
149
|
+
for i in 1...length
|
150
|
+
ch = unpacked[i]
|
151
|
+
|
152
|
+
if (starter_cc == 0 &&
|
153
|
+
(composite = unicode_compose_pair(starter, ch)) != nil)
|
154
|
+
starter = composite
|
155
|
+
else
|
156
|
+
unpacked_result << starter
|
157
|
+
starter = ch
|
158
|
+
end
|
159
|
+
end
|
160
|
+
unpacked_result << starter
|
161
|
+
return unpacked_result
|
162
|
+
end
|
163
|
+
private_class_method :unicode_compose
|
164
|
+
|
165
|
+
def self.unicode_compose_pair(ch_one, ch_two)
|
166
|
+
if ch_one >= HANGUL_LBASE && ch_one < HANGUL_LBASE + HANGUL_LCOUNT &&
|
167
|
+
ch_two >= HANGUL_VBASE && ch_two < HANGUL_VBASE + HANGUL_VCOUNT
|
168
|
+
# Hangul L + V
|
169
|
+
return HANGUL_SBASE + (
|
170
|
+
(ch_one - HANGUL_LBASE) * HANGUL_VCOUNT + (ch_two - HANGUL_VBASE)
|
171
|
+
) * HANGUL_TCOUNT
|
172
|
+
elsif ch_one >= HANGUL_SBASE &&
|
173
|
+
ch_one < HANGUL_SBASE + HANGUL_SCOUNT &&
|
174
|
+
(ch_one - HANGUL_SBASE) % HANGUL_TCOUNT == 0 &&
|
175
|
+
ch_two >= HANGUL_TBASE && ch_two < HANGUL_TBASE + HANGUL_TCOUNT
|
176
|
+
# Hangul LV + T
|
177
|
+
return ch_one + (ch_two - HANGUL_TBASE)
|
178
|
+
end
|
179
|
+
|
180
|
+
p = []
|
181
|
+
ucs4_to_utf8 = lambda do |ch|
|
182
|
+
if ch < 128
|
183
|
+
p << ch
|
184
|
+
elsif ch < 2048
|
185
|
+
p << (ch >> 6 | 192)
|
186
|
+
p << (ch & 63 | 128)
|
187
|
+
elsif ch < 0x10000
|
188
|
+
p << (ch >> 12 | 224)
|
189
|
+
p << (ch >> 6 & 63 | 128)
|
190
|
+
p << (ch & 63 | 128)
|
191
|
+
elsif ch < 0x200000
|
192
|
+
p << (ch >> 18 | 240)
|
193
|
+
p << (ch >> 12 & 63 | 128)
|
194
|
+
p << (ch >> 6 & 63 | 128)
|
195
|
+
p << (ch & 63 | 128)
|
196
|
+
elsif ch < 0x4000000
|
197
|
+
p << (ch >> 24 | 248)
|
198
|
+
p << (ch >> 18 & 63 | 128)
|
199
|
+
p << (ch >> 12 & 63 | 128)
|
200
|
+
p << (ch >> 6 & 63 | 128)
|
201
|
+
p << (ch & 63 | 128)
|
202
|
+
elsif ch < 0x80000000
|
203
|
+
p << (ch >> 30 | 252)
|
204
|
+
p << (ch >> 24 & 63 | 128)
|
205
|
+
p << (ch >> 18 & 63 | 128)
|
206
|
+
p << (ch >> 12 & 63 | 128)
|
207
|
+
p << (ch >> 6 & 63 | 128)
|
208
|
+
p << (ch & 63 | 128)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
ucs4_to_utf8.call(ch_one)
|
213
|
+
ucs4_to_utf8.call(ch_two)
|
214
|
+
|
215
|
+
return lookup_unicode_composition(p)
|
216
|
+
end
|
217
|
+
private_class_method :unicode_compose_pair
|
218
|
+
|
219
|
+
def self.unicode_sort_canonical(unpacked)
|
220
|
+
unpacked = unpacked.dup
|
221
|
+
i = 1
|
222
|
+
length = unpacked.length
|
223
|
+
|
224
|
+
return unpacked if length < 2
|
225
|
+
|
226
|
+
while i < length
|
227
|
+
last = unpacked[i-1]
|
228
|
+
ch = unpacked[i]
|
229
|
+
last_cc = lookup_unicode_combining_class(last)
|
230
|
+
cc = lookup_unicode_combining_class(ch)
|
231
|
+
if cc != 0 && last_cc != 0 && last_cc > cc
|
232
|
+
unpacked[i] = last
|
233
|
+
unpacked[i-1] = ch
|
234
|
+
i -= 1 if i > 1
|
235
|
+
else
|
236
|
+
i += 1
|
237
|
+
end
|
238
|
+
end
|
239
|
+
return unpacked
|
240
|
+
end
|
241
|
+
private_class_method :unicode_sort_canonical
|
242
|
+
|
243
|
+
def self.unicode_decompose(unpacked)
|
244
|
+
unpacked_result = []
|
245
|
+
for cp in unpacked
|
246
|
+
if cp >= HANGUL_SBASE && cp < HANGUL_SBASE + HANGUL_SCOUNT
|
247
|
+
l, v, t = unicode_decompose_hangul(cp)
|
248
|
+
unpacked_result << l
|
249
|
+
unpacked_result << v if v
|
250
|
+
unpacked_result << t if t
|
251
|
+
else
|
252
|
+
dc = lookup_unicode_compatibility(cp)
|
253
|
+
unless dc
|
254
|
+
unpacked_result << cp
|
255
|
+
else
|
256
|
+
unpacked_result.concat(unicode_decompose(dc.unpack("U*")))
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
return unpacked_result
|
261
|
+
end
|
262
|
+
private_class_method :unicode_decompose
|
263
|
+
|
264
|
+
def self.unicode_decompose_hangul(codepoint)
|
265
|
+
sindex = codepoint - HANGUL_SBASE;
|
266
|
+
if sindex < 0 || sindex >= HANGUL_SCOUNT
|
267
|
+
l = codepoint
|
268
|
+
v = t = nil
|
269
|
+
return l, v, t
|
270
|
+
end
|
271
|
+
l = HANGUL_LBASE + sindex / HANGUL_NCOUNT
|
272
|
+
v = HANGUL_VBASE + (sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT
|
273
|
+
t = HANGUL_TBASE + sindex % HANGUL_TCOUNT
|
274
|
+
if t == HANGUL_TBASE
|
275
|
+
t = nil
|
276
|
+
end
|
277
|
+
return l, v, t
|
278
|
+
end
|
279
|
+
private_class_method :unicode_decompose_hangul
|
280
|
+
|
281
|
+
def self.lookup_unicode_combining_class(codepoint)
|
282
|
+
codepoint_data = UNICODE_DATA[codepoint]
|
283
|
+
(codepoint_data ?
|
284
|
+
(codepoint_data[UNICODE_DATA_COMBINING_CLASS] || 0) :
|
285
|
+
0)
|
286
|
+
end
|
287
|
+
private_class_method :lookup_unicode_combining_class
|
288
|
+
|
289
|
+
def self.lookup_unicode_compatibility(codepoint)
|
290
|
+
codepoint_data = UNICODE_DATA[codepoint]
|
291
|
+
(codepoint_data ?
|
292
|
+
codepoint_data[UNICODE_DATA_COMPATIBILITY] : nil)
|
293
|
+
end
|
294
|
+
private_class_method :lookup_unicode_compatibility
|
295
|
+
|
296
|
+
def self.lookup_unicode_lowercase(codepoint)
|
297
|
+
codepoint_data = UNICODE_DATA[codepoint]
|
298
|
+
(codepoint_data ?
|
299
|
+
(codepoint_data[UNICODE_DATA_LOWERCASE] || codepoint) :
|
300
|
+
codepoint)
|
301
|
+
end
|
302
|
+
private_class_method :lookup_unicode_lowercase
|
303
|
+
|
304
|
+
def self.lookup_unicode_composition(unpacked)
|
305
|
+
return COMPOSITION_TABLE[unpacked]
|
306
|
+
end
|
307
|
+
private_class_method :lookup_unicode_composition
|
308
|
+
|
309
|
+
HANGUL_SBASE = 0xac00
|
310
|
+
HANGUL_LBASE = 0x1100
|
311
|
+
HANGUL_LCOUNT = 19
|
312
|
+
HANGUL_VBASE = 0x1161
|
313
|
+
HANGUL_VCOUNT = 21
|
314
|
+
HANGUL_TBASE = 0x11a7
|
315
|
+
HANGUL_TCOUNT = 28
|
316
|
+
HANGUL_NCOUNT = HANGUL_VCOUNT * HANGUL_TCOUNT # 588
|
317
|
+
HANGUL_SCOUNT = HANGUL_LCOUNT * HANGUL_NCOUNT # 11172
|
318
|
+
|
319
|
+
UNICODE_DATA_COMBINING_CLASS = 0
|
320
|
+
UNICODE_DATA_EXCLUSION = 1
|
321
|
+
UNICODE_DATA_CANONICAL = 2
|
322
|
+
UNICODE_DATA_COMPATIBILITY = 3
|
323
|
+
UNICODE_DATA_UPPERCASE = 4
|
324
|
+
UNICODE_DATA_LOWERCASE = 5
|
325
|
+
UNICODE_DATA_TITLECASE = 6
|
326
|
+
|
327
|
+
begin
|
328
|
+
if defined?(FakeFS)
|
329
|
+
fakefs_state = FakeFS.activated?
|
330
|
+
FakeFS.deactivate!
|
331
|
+
end
|
332
|
+
# This is a sparse Unicode table. Codepoints without entries are
|
333
|
+
# assumed to have the value: [0, 0, nil, nil, nil, nil, nil]
|
334
|
+
UNICODE_DATA = File.open(UNICODE_TABLE, "rb") do |file|
|
335
|
+
Marshal.load(file.read)
|
336
|
+
end
|
337
|
+
ensure
|
338
|
+
if defined?(FakeFS)
|
339
|
+
FakeFS.activate! if fakefs_state
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
COMPOSITION_TABLE = {}
|
344
|
+
UNICODE_DATA.each do |codepoint, data|
|
345
|
+
canonical = data[UNICODE_DATA_CANONICAL]
|
346
|
+
exclusion = data[UNICODE_DATA_EXCLUSION]
|
347
|
+
|
348
|
+
if canonical && exclusion == 0
|
349
|
+
COMPOSITION_TABLE[canonical.unpack("C*")] = codepoint
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
UNICODE_MAX_LENGTH = 256
|
354
|
+
ACE_MAX_LENGTH = 256
|
355
|
+
|
356
|
+
PUNYCODE_BASE = 36
|
357
|
+
PUNYCODE_TMIN = 1
|
358
|
+
PUNYCODE_TMAX = 26
|
359
|
+
PUNYCODE_SKEW = 38
|
360
|
+
PUNYCODE_DAMP = 700
|
361
|
+
PUNYCODE_INITIAL_BIAS = 72
|
362
|
+
PUNYCODE_INITIAL_N = 0x80
|
363
|
+
PUNYCODE_DELIMITER = 0x2D
|
364
|
+
|
365
|
+
PUNYCODE_MAXINT = 1 << 64
|
366
|
+
|
367
|
+
PUNYCODE_PRINT_ASCII =
|
368
|
+
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +
|
369
|
+
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +
|
370
|
+
" !\"\#$%&'()*+,-./" +
|
371
|
+
"0123456789:;<=>?" +
|
372
|
+
"@ABCDEFGHIJKLMNO" +
|
373
|
+
"PQRSTUVWXYZ[\\]^_" +
|
374
|
+
"`abcdefghijklmno" +
|
375
|
+
"pqrstuvwxyz{|}~\n"
|
376
|
+
|
377
|
+
# Input is invalid.
|
378
|
+
class PunycodeBadInput < StandardError; end
|
379
|
+
# Output would exceed the space provided.
|
380
|
+
class PunycodeBigOutput < StandardError; end
|
381
|
+
# Input needs wider integers to process.
|
382
|
+
class PunycodeOverflow < StandardError; end
|
383
|
+
|
384
|
+
def self.punycode_encode(unicode)
|
385
|
+
unicode = unicode.to_s unless unicode.is_a?(String)
|
386
|
+
input = unicode.unpack("U*")
|
387
|
+
output = [0] * (ACE_MAX_LENGTH + 1)
|
388
|
+
input_length = input.size
|
389
|
+
output_length = [ACE_MAX_LENGTH]
|
390
|
+
|
391
|
+
# Initialize the state
|
392
|
+
n = PUNYCODE_INITIAL_N
|
393
|
+
delta = out = 0
|
394
|
+
max_out = output_length[0]
|
395
|
+
bias = PUNYCODE_INITIAL_BIAS
|
396
|
+
|
397
|
+
# Handle the basic code points:
|
398
|
+
input_length.times do |j|
|
399
|
+
if punycode_basic?(input[j])
|
400
|
+
if max_out - out < 2
|
401
|
+
raise PunycodeBigOutput,
|
402
|
+
"Output would exceed the space provided."
|
403
|
+
end
|
404
|
+
output[out] = input[j]
|
405
|
+
out += 1
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
h = b = out
|
410
|
+
|
411
|
+
# h is the number of code points that have been handled, b is the
|
412
|
+
# number of basic code points, and out is the number of characters
|
413
|
+
# that have been output.
|
414
|
+
|
415
|
+
if b > 0
|
416
|
+
output[out] = PUNYCODE_DELIMITER
|
417
|
+
out += 1
|
418
|
+
end
|
419
|
+
|
420
|
+
# Main encoding loop:
|
421
|
+
|
422
|
+
while h < input_length
|
423
|
+
# All non-basic code points < n have been
|
424
|
+
# handled already. Find the next larger one:
|
425
|
+
|
426
|
+
m = PUNYCODE_MAXINT
|
427
|
+
input_length.times do |j|
|
428
|
+
m = input[j] if (n...m) === input[j]
|
429
|
+
end
|
430
|
+
|
431
|
+
# Increase delta enough to advance the decoder's
|
432
|
+
# <n,i> state to <m,0>, but guard against overflow:
|
433
|
+
|
434
|
+
if m - n > (PUNYCODE_MAXINT - delta) / (h + 1)
|
435
|
+
raise PunycodeOverflow, "Input needs wider integers to process."
|
436
|
+
end
|
437
|
+
delta += (m - n) * (h + 1)
|
438
|
+
n = m
|
439
|
+
|
440
|
+
input_length.times do |j|
|
441
|
+
# Punycode does not need to check whether input[j] is basic:
|
442
|
+
if input[j] < n
|
443
|
+
delta += 1
|
444
|
+
if delta == 0
|
445
|
+
raise PunycodeOverflow,
|
446
|
+
"Input needs wider integers to process."
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
if input[j] == n
|
451
|
+
# Represent delta as a generalized variable-length integer:
|
452
|
+
|
453
|
+
q = delta; k = PUNYCODE_BASE
|
454
|
+
while true
|
455
|
+
if out >= max_out
|
456
|
+
raise PunycodeBigOutput,
|
457
|
+
"Output would exceed the space provided."
|
458
|
+
end
|
459
|
+
t = (
|
460
|
+
if k <= bias
|
461
|
+
PUNYCODE_TMIN
|
462
|
+
elsif k >= bias + PUNYCODE_TMAX
|
463
|
+
PUNYCODE_TMAX
|
464
|
+
else
|
465
|
+
k - bias
|
466
|
+
end
|
467
|
+
)
|
468
|
+
break if q < t
|
469
|
+
output[out] =
|
470
|
+
punycode_encode_digit(t + (q - t) % (PUNYCODE_BASE - t))
|
471
|
+
out += 1
|
472
|
+
q = (q - t) / (PUNYCODE_BASE - t)
|
473
|
+
k += PUNYCODE_BASE
|
474
|
+
end
|
475
|
+
|
476
|
+
output[out] = punycode_encode_digit(q)
|
477
|
+
out += 1
|
478
|
+
bias = punycode_adapt(delta, h + 1, h == b)
|
479
|
+
delta = 0
|
480
|
+
h += 1
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
484
|
+
delta += 1
|
485
|
+
n += 1
|
486
|
+
end
|
487
|
+
|
488
|
+
output_length[0] = out
|
489
|
+
|
490
|
+
outlen = out
|
491
|
+
outlen.times do |j|
|
492
|
+
c = output[j]
|
493
|
+
unless c >= 0 && c <= 127
|
494
|
+
raise StandardError, "Invalid output char."
|
495
|
+
end
|
496
|
+
unless PUNYCODE_PRINT_ASCII[c]
|
497
|
+
raise PunycodeBadInput, "Input is invalid."
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
output[0..outlen].map { |x| x.chr }.join("").sub(/\0+\z/, "")
|
502
|
+
end
|
503
|
+
private_class_method :punycode_encode
|
504
|
+
|
505
|
+
def self.punycode_decode(punycode)
|
506
|
+
input = []
|
507
|
+
output = []
|
508
|
+
|
509
|
+
if ACE_MAX_LENGTH * 2 < punycode.size
|
510
|
+
raise PunycodeBigOutput, "Output would exceed the space provided."
|
511
|
+
end
|
512
|
+
punycode.each_byte do |c|
|
513
|
+
unless c >= 0 && c <= 127
|
514
|
+
raise PunycodeBadInput, "Input is invalid."
|
515
|
+
end
|
516
|
+
input.push(c)
|
517
|
+
end
|
518
|
+
|
519
|
+
input_length = input.length
|
520
|
+
output_length = [UNICODE_MAX_LENGTH]
|
521
|
+
|
522
|
+
# Initialize the state
|
523
|
+
n = PUNYCODE_INITIAL_N
|
524
|
+
|
525
|
+
out = i = 0
|
526
|
+
max_out = output_length[0]
|
527
|
+
bias = PUNYCODE_INITIAL_BIAS
|
528
|
+
|
529
|
+
# Handle the basic code points: Let b be the number of input code
|
530
|
+
# points before the last delimiter, or 0 if there is none, then
|
531
|
+
# copy the first b code points to the output.
|
532
|
+
|
533
|
+
b = 0
|
534
|
+
input_length.times do |j|
|
535
|
+
b = j if punycode_delimiter?(input[j])
|
536
|
+
end
|
537
|
+
if b > max_out
|
538
|
+
raise PunycodeBigOutput, "Output would exceed the space provided."
|
539
|
+
end
|
540
|
+
|
541
|
+
b.times do |j|
|
542
|
+
unless punycode_basic?(input[j])
|
543
|
+
raise PunycodeBadInput, "Input is invalid."
|
544
|
+
end
|
545
|
+
output[out] = input[j]
|
546
|
+
out+=1
|
547
|
+
end
|
548
|
+
|
549
|
+
# Main decoding loop: Start just after the last delimiter if any
|
550
|
+
# basic code points were copied; start at the beginning otherwise.
|
551
|
+
|
552
|
+
in_ = b > 0 ? b + 1 : 0
|
553
|
+
while in_ < input_length
|
554
|
+
|
555
|
+
# in_ is the index of the next character to be consumed, and
|
556
|
+
# out is the number of code points in the output array.
|
557
|
+
|
558
|
+
# Decode a generalized variable-length integer into delta,
|
559
|
+
# which gets added to i. The overflow checking is easier
|
560
|
+
# if we increase i as we go, then subtract off its starting
|
561
|
+
# value at the end to obtain delta.
|
562
|
+
|
563
|
+
oldi = i; w = 1; k = PUNYCODE_BASE
|
564
|
+
while true
|
565
|
+
if in_ >= input_length
|
566
|
+
raise PunycodeBadInput, "Input is invalid."
|
567
|
+
end
|
568
|
+
digit = punycode_decode_digit(input[in_])
|
569
|
+
in_+=1
|
570
|
+
if digit >= PUNYCODE_BASE
|
571
|
+
raise PunycodeBadInput, "Input is invalid."
|
572
|
+
end
|
573
|
+
if digit > (PUNYCODE_MAXINT - i) / w
|
574
|
+
raise PunycodeOverflow, "Input needs wider integers to process."
|
575
|
+
end
|
576
|
+
i += digit * w
|
577
|
+
t = (
|
578
|
+
if k <= bias
|
579
|
+
PUNYCODE_TMIN
|
580
|
+
elsif k >= bias + PUNYCODE_TMAX
|
581
|
+
PUNYCODE_TMAX
|
582
|
+
else
|
583
|
+
k - bias
|
584
|
+
end
|
585
|
+
)
|
586
|
+
break if digit < t
|
587
|
+
if w > PUNYCODE_MAXINT / (PUNYCODE_BASE - t)
|
588
|
+
raise PunycodeOverflow, "Input needs wider integers to process."
|
589
|
+
end
|
590
|
+
w *= PUNYCODE_BASE - t
|
591
|
+
k += PUNYCODE_BASE
|
592
|
+
end
|
593
|
+
|
594
|
+
bias = punycode_adapt(i - oldi, out + 1, oldi == 0)
|
595
|
+
|
596
|
+
# I was supposed to wrap around from out + 1 to 0,
|
597
|
+
# incrementing n each time, so we'll fix that now:
|
598
|
+
|
599
|
+
if i / (out + 1) > PUNYCODE_MAXINT - n
|
600
|
+
raise PunycodeOverflow, "Input needs wider integers to process."
|
601
|
+
end
|
602
|
+
n += i / (out + 1)
|
603
|
+
i %= out + 1
|
604
|
+
|
605
|
+
# Insert n at position i of the output:
|
606
|
+
|
607
|
+
# not needed for Punycode:
|
608
|
+
# raise PUNYCODE_INVALID_INPUT if decode_digit(n) <= base
|
609
|
+
if out >= max_out
|
610
|
+
raise PunycodeBigOutput, "Output would exceed the space provided."
|
611
|
+
end
|
612
|
+
|
613
|
+
#memmove(output + i + 1, output + i, (out - i) * sizeof *output)
|
614
|
+
output[i + 1, out - i] = output[i, out - i]
|
615
|
+
output[i] = n
|
616
|
+
i += 1
|
617
|
+
|
618
|
+
out += 1
|
619
|
+
end
|
620
|
+
|
621
|
+
output_length[0] = out
|
622
|
+
|
623
|
+
output.pack("U*")
|
624
|
+
end
|
625
|
+
private_class_method :punycode_decode
|
626
|
+
|
627
|
+
def self.punycode_basic?(codepoint)
|
628
|
+
codepoint < 0x80
|
629
|
+
end
|
630
|
+
private_class_method :punycode_basic?
|
631
|
+
|
632
|
+
def self.punycode_delimiter?(codepoint)
|
633
|
+
codepoint == PUNYCODE_DELIMITER
|
634
|
+
end
|
635
|
+
private_class_method :punycode_delimiter?
|
636
|
+
|
637
|
+
def self.punycode_encode_digit(d)
|
638
|
+
d + 22 + 75 * ((d < 26) ? 1 : 0)
|
639
|
+
end
|
640
|
+
private_class_method :punycode_encode_digit
|
641
|
+
|
642
|
+
# Returns the numeric value of a basic codepoint
|
643
|
+
# (for use in representing integers) in the range 0 to
|
644
|
+
# base - 1, or PUNYCODE_BASE if codepoint does not represent a value.
|
645
|
+
def self.punycode_decode_digit(codepoint)
|
646
|
+
if codepoint - 48 < 10
|
647
|
+
codepoint - 22
|
648
|
+
elsif codepoint - 65 < 26
|
649
|
+
codepoint - 65
|
650
|
+
elsif codepoint - 97 < 26
|
651
|
+
codepoint - 97
|
652
|
+
else
|
653
|
+
PUNYCODE_BASE
|
654
|
+
end
|
655
|
+
end
|
656
|
+
private_class_method :punycode_decode_digit
|
657
|
+
|
658
|
+
# Bias adaptation method
|
659
|
+
def self.punycode_adapt(delta, numpoints, firsttime)
|
660
|
+
delta = firsttime ? delta / PUNYCODE_DAMP : delta >> 1
|
661
|
+
# delta >> 1 is a faster way of doing delta / 2
|
662
|
+
delta += delta / numpoints
|
663
|
+
difference = PUNYCODE_BASE - PUNYCODE_TMIN
|
664
|
+
|
665
|
+
k = 0
|
666
|
+
while delta > (difference * PUNYCODE_TMAX) / 2
|
667
|
+
delta /= difference
|
668
|
+
k += PUNYCODE_BASE
|
669
|
+
end
|
670
|
+
|
671
|
+
k + (difference + 1) * delta / (delta + PUNYCODE_SKEW)
|
672
|
+
end
|
673
|
+
private_class_method :punycode_adapt
|
674
|
+
end
|
675
|
+
# :startdoc:
|
676
|
+
end
|