vagrant-unbundled 2.2.18.0 → 2.2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +6 -6
- data/contrib/zsh/generate_zsh_completion.rb +2 -2
- data/lib/vagrant/errors.rb +8 -0
- data/plugins/commands/upload/command.rb +1 -1
- data/plugins/guests/atomic/guest.rb +1 -1
- data/plugins/guests/coreos/cap/configure_networks.rb +65 -0
- data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +6 -3
- data/plugins/guests/suse/cap/halt.rb +5 -1
- data/plugins/guests/windows/cap/rsync.rb +5 -1
- data/plugins/hosts/darwin/cap/path.rb +4 -0
- data/plugins/hosts/darwin/cap/version.rb +23 -0
- data/plugins/hosts/darwin/plugin.rb +5 -0
- data/plugins/hosts/windows/cap/ssh.rb +1 -1
- data/plugins/providers/virtualbox/action/network.rb +39 -2
- data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +5 -3
- data/plugins/provisioners/chef/cap/linux/chef_installed.rb +5 -3
- data/plugins/provisioners/chef/cap/omnios/chef_installed.rb +7 -5
- data/plugins/provisioners/chef/cap/windows/chef_installed.rb +3 -2
- data/templates/locales/en.yml +25 -0
- data/vagrant.gemspec +1 -1
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTING.md +23 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTORS.md +140 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/README.md +492 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/data/cacert.pem +3232 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/excon.gemspec +45 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/connection.rb +599 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/constants.rb +172 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/error.rb +229 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/extensions/uri.rb +34 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/headers.rb +85 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/base.rb +31 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/capture_cookies.rb +32 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/decompress.rb +44 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/escape_path.rb +12 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/expects.rb +25 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/idempotent.rb +57 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/instrumentor.rb +49 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/mock.rb +61 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/redirect_follower.rb +87 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/response_parser.rb +16 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/pretty_printer.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/response.rb +234 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/socket.rb +297 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/ssl_socket.rb +194 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/exec.rb +26 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/puma.rb +23 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/unicorn.rb +40 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/webrick.rb +26 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/server.rb +106 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/unix_socket.rb +42 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/utils.rb +143 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/version.rb +4 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon.rb +255 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/README.md +122 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/base.rb +289 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache.rb +113 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache_file.rb +36 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cascade.rb +56 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/chain.rb +130 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/fallbacks.rb +97 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/flatten.rb +118 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/gettext.rb +85 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/interpolation_compiler.rb +123 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/key_value.rb +206 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/memoize.rb +54 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/metadata.rb +71 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/pluralization.rb +55 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/simple.rb +108 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/transliterator.rb +108 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/config.rb +165 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/core_ext/hash.rb +59 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/exceptions.rb +111 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/helpers.rb +75 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/po_parser.rb +329 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext.rb +28 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/interpolate/ruby.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/fallbacks.rb +99 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/parents.rb +24 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/rfc4646.rb +74 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/simple.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag.rb +28 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale.rb +8 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/middleware.rb +17 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/basics.rb +60 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/defaults.rb +52 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/interpolation.rb +163 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/link.rb +66 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date.rb +117 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date_time.rb +103 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/procs.rb +117 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/time.rb +103 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization.rb +19 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/lookup.rb +81 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/pluralization.rb +35 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/procs.rb +60 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests.rb +14 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/version.rb +5 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n.rb +415 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Code-of-Conduct.md +73 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Contributing.md +132 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/History.md +269 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Licence.md +25 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Manifest.txt +31 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/README.rdoc +194 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Rakefile +270 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb +57 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type.rb +634 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/_columnar.rb +137 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/cache.rb +58 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/columnar.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/container.rb +96 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/deprecations.rb +36 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/full.rb +19 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/loader.rb +159 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/logger.rb +37 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/registry.rb +90 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types.rb +233 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime-types.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/bad-fixtures/malformed +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/json.json +1 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/old-data +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/yaml.yaml +55 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/minitest_helper.rb +11 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_type.rb +621 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types.rb +169 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_cache.rb +118 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_class.rb +159 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_lazy.rb +49 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_loader.rb +32 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Code-of-Conduct.md +75 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Contributing.md +241 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/History.md +494 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Licence.md +24 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Manifest.txt +34 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/README.md +73 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Rakefile +155 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/content_type_mime.db +878 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/ext_mime.db +1198 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime-types.json +1 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.content_type.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.docs.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.encoding.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.flags.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.friendly.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.pext.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.use_instead.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.xrefs.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime/types/data.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime-types-data.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/application.yaml +17254 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/audio.yaml +1716 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/chemical.yaml +71 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/conference.yaml +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/drawing.yaml +15 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/font.yaml +65 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/image.yaml +1251 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/message.yaml +200 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/model.yaml +390 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/multipart.yaml +179 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/provisional-standard-types.yaml +129 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/text.yaml +1166 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/video.yaml +1121 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/world.yaml +8 -0
- data/vendor/bundle/ruby/3.0.0/specifications/excon-0.89.0.gemspec +58 -0
- data/vendor/bundle/ruby/3.0.0/specifications/i18n-1.8.11.gemspec +32 -0
- data/vendor/bundle/ruby/3.0.0/specifications/mime-types-3.4.1.gemspec +63 -0
- data/vendor/bundle/ruby/3.0.0/specifications/mime-types-data-3.2021.1115.gemspec +54 -0
- data/version.txt +1 -1
- metadata +157 -4
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'open4'
|
2
|
+
require 'excon'
|
3
|
+
require 'excon/test/plugin/server/webrick'
|
4
|
+
require 'excon/test/plugin/server/unicorn'
|
5
|
+
require 'excon/test/plugin/server/puma'
|
6
|
+
require 'excon/test/plugin/server/exec'
|
7
|
+
|
8
|
+
|
9
|
+
module Excon
|
10
|
+
module Test
|
11
|
+
class Server
|
12
|
+
attr_accessor :app, :server, :bind, :pid, :read, :write, :error, :started_at, :timeout
|
13
|
+
|
14
|
+
# Methods that must be implemented by a plugin
|
15
|
+
INSTANCE_REQUIRES = [:start]
|
16
|
+
Excon.defaults.merge!(
|
17
|
+
connect_timeout: 5,
|
18
|
+
read_timeout: 5,
|
19
|
+
write_timeout: 5
|
20
|
+
)
|
21
|
+
|
22
|
+
def initialize(args)
|
23
|
+
# TODO: Validate these args
|
24
|
+
@server = args.keys.first
|
25
|
+
@app = args[server]
|
26
|
+
args[:bind] ||= 'tcp://127.0.0.1:9292'
|
27
|
+
@bind = URI.parse(args[:bind])
|
28
|
+
@is_unix_socket = (@bind.scheme == 'unix')
|
29
|
+
@bind.host = @bind.host.gsub(/[\[\]]/, '') unless @is_unix_socket
|
30
|
+
if args[:timeout]
|
31
|
+
@timeout = args[:timeout]
|
32
|
+
else
|
33
|
+
@timeout = 20
|
34
|
+
end
|
35
|
+
name = @server.to_s.split('_').collect(&:capitalize).join
|
36
|
+
plug = nested_const_get("Excon::Test::Plugin::Server::#{name}")
|
37
|
+
self.extend plug
|
38
|
+
check_implementation(plug)
|
39
|
+
end
|
40
|
+
|
41
|
+
def open_process(*args)
|
42
|
+
if RUBY_PLATFORM == 'java'
|
43
|
+
@pid, @write, @read, @error = IO.popen4(*args)
|
44
|
+
else
|
45
|
+
GC.disable if RUBY_VERSION < '1.9'
|
46
|
+
@pid, @write, @read, @error = Open4.popen4(*args)
|
47
|
+
end
|
48
|
+
@started_at = Time.now
|
49
|
+
end
|
50
|
+
|
51
|
+
def elapsed_time
|
52
|
+
Time.now - started_at
|
53
|
+
end
|
54
|
+
|
55
|
+
def stop
|
56
|
+
if RUBY_PLATFORM == 'java'
|
57
|
+
Process.kill('USR1', pid)
|
58
|
+
else
|
59
|
+
Process.kill(9, pid)
|
60
|
+
GC.enable if RUBY_VERSION < '1.9'
|
61
|
+
Process.wait(pid)
|
62
|
+
end
|
63
|
+
|
64
|
+
if @is_unix_socket
|
65
|
+
socket = @bind.path
|
66
|
+
File.delete(socket) if File.exist?(socket)
|
67
|
+
end
|
68
|
+
|
69
|
+
# TODO: Ensure process is really dead
|
70
|
+
dump_errors
|
71
|
+
true
|
72
|
+
end
|
73
|
+
def dump_errors
|
74
|
+
lines = error.read.split($/)
|
75
|
+
while (line = lines.shift)
|
76
|
+
case line
|
77
|
+
when /(ERROR|Error)/
|
78
|
+
unless line =~ /(null cert chain|did not return a certificate|SSL_read:: internal error)/
|
79
|
+
in_err = true
|
80
|
+
puts
|
81
|
+
end
|
82
|
+
when /^(127|localhost)/
|
83
|
+
in_err = false
|
84
|
+
end
|
85
|
+
puts line if in_err
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def nested_const_get(namespace)
|
92
|
+
namespace.split('::').inject(Object) do |mod, klass|
|
93
|
+
mod.const_get(klass)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def check_implementation(plug)
|
98
|
+
INSTANCE_REQUIRES.each do |m|
|
99
|
+
unless self.respond_to? m
|
100
|
+
raise "FATAL: #{plug} does not implement ##{m}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Excon
|
3
|
+
class UnixSocket < Excon::Socket
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def connect
|
8
|
+
@socket = ::Socket.new(::Socket::AF_UNIX, ::Socket::SOCK_STREAM, 0)
|
9
|
+
# If a Unix proxy was specified, the :path option will be set for it,
|
10
|
+
# otherwise fall back to the :socket option.
|
11
|
+
proxy_path = @data[:proxy] ? @data[:proxy][:path] : nil
|
12
|
+
sockaddr = ::Socket.sockaddr_un(proxy_path || @data[:socket])
|
13
|
+
if @nonblock
|
14
|
+
begin
|
15
|
+
@socket.connect_nonblock(sockaddr)
|
16
|
+
rescue Errno::EINPROGRESS
|
17
|
+
unless IO.select(nil, [@socket], nil, @data[:connect_timeout])
|
18
|
+
raise(Excon::Errors::Timeout.new("connect timeout reached"))
|
19
|
+
end
|
20
|
+
begin
|
21
|
+
@socket.connect_nonblock(sockaddr)
|
22
|
+
rescue Errno::EISCONN
|
23
|
+
0 # same return as connect_nonblock success
|
24
|
+
end
|
25
|
+
end
|
26
|
+
else
|
27
|
+
begin
|
28
|
+
Timeout.timeout(@data[:connect_timeout]) do
|
29
|
+
@socket.connect(sockaddr)
|
30
|
+
end
|
31
|
+
rescue Timeout::Error
|
32
|
+
raise Excon::Errors::Timeout.new('connect timeout reached')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
rescue => error
|
37
|
+
@socket.close rescue nil if @socket
|
38
|
+
raise error
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Excon
|
3
|
+
module Utils
|
4
|
+
extend self
|
5
|
+
|
6
|
+
CONTROL = (0x0..0x1f).map {|c| c.chr }.join + "\x7f"
|
7
|
+
DELIMS = '<>#%"'
|
8
|
+
UNWISE = '{}|\\^[]`'
|
9
|
+
NONASCII = (0x80..0xff).map {|c| c.chr }.join
|
10
|
+
UNESCAPED = /([#{ Regexp.escape(CONTROL + ' ' + DELIMS + UNWISE + NONASCII) }])/
|
11
|
+
ESCAPED = /%([0-9a-fA-F]{2})/
|
12
|
+
|
13
|
+
def binary_encode(string)
|
14
|
+
if FORCE_ENC && string.encoding != Encoding::ASCII_8BIT
|
15
|
+
if string.frozen?
|
16
|
+
string.dup.force_encoding('BINARY')
|
17
|
+
else
|
18
|
+
string.force_encoding('BINARY')
|
19
|
+
end
|
20
|
+
else
|
21
|
+
string
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def connection_uri(datum = @data)
|
26
|
+
unless datum
|
27
|
+
raise ArgumentError, '`datum` must be given unless called on a Connection'
|
28
|
+
end
|
29
|
+
if datum[:scheme] == UNIX
|
30
|
+
"#{datum[:scheme]}://#{datum[:socket]}"
|
31
|
+
else
|
32
|
+
"#{datum[:scheme]}://#{datum[:host]}#{port_string(datum)}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Redact sensitive info from provided data
|
37
|
+
def redact(datum)
|
38
|
+
datum = datum.dup
|
39
|
+
if datum.has_key?(:headers)
|
40
|
+
if datum[:headers].has_key?('Authorization') || datum[:headers].has_key?('Proxy-Authorization')
|
41
|
+
datum[:headers] = datum[:headers].dup
|
42
|
+
end
|
43
|
+
if datum[:headers].has_key?('Authorization')
|
44
|
+
datum[:headers]['Authorization'] = REDACTED
|
45
|
+
end
|
46
|
+
if datum[:headers].has_key?('Proxy-Authorization')
|
47
|
+
datum[:headers]['Proxy-Authorization'] = REDACTED
|
48
|
+
end
|
49
|
+
end
|
50
|
+
if datum.has_key?(:password)
|
51
|
+
datum[:password] = REDACTED
|
52
|
+
end
|
53
|
+
if datum.has_key?(:proxy) && datum[:proxy] && datum[:proxy].has_key?(:password)
|
54
|
+
datum[:proxy] = datum[:proxy].dup
|
55
|
+
datum[:proxy][:password] = REDACTED
|
56
|
+
end
|
57
|
+
datum
|
58
|
+
end
|
59
|
+
|
60
|
+
def request_uri(datum)
|
61
|
+
connection_uri(datum) + datum[:path] + query_string(datum)
|
62
|
+
end
|
63
|
+
|
64
|
+
def port_string(datum)
|
65
|
+
if datum[:port].nil? || (datum[:omit_default_port] && ((datum[:scheme].casecmp('http') == 0 && datum[:port] == 80) || (datum[:scheme].casecmp('https') == 0 && datum[:port] == 443)))
|
66
|
+
''
|
67
|
+
else
|
68
|
+
':' + datum[:port].to_s
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def query_string(datum)
|
73
|
+
str = String.new
|
74
|
+
case datum[:query]
|
75
|
+
when String
|
76
|
+
str << '?' << datum[:query]
|
77
|
+
when Hash
|
78
|
+
str << '?'
|
79
|
+
datum[:query].sort_by {|k,_| k.to_s }.each do |key, values|
|
80
|
+
key = CGI.escape(key.to_s)
|
81
|
+
if values.nil?
|
82
|
+
str << key << '&'
|
83
|
+
else
|
84
|
+
[values].flatten.each do |value|
|
85
|
+
str << key << '=' << CGI.escape(value.to_s) << '&'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
str.chop! # remove trailing '&'
|
90
|
+
end
|
91
|
+
str
|
92
|
+
end
|
93
|
+
|
94
|
+
# Splits a header value +str+ according to HTTP specification.
|
95
|
+
def split_header_value(str)
|
96
|
+
return [] if str.nil?
|
97
|
+
str = str.dup.strip
|
98
|
+
str = binary_encode(str)
|
99
|
+
str.scan(%r'\G((?:"(?:\\.|[^"])+?"|[^",])+)
|
100
|
+
(?:,\s*|\Z)'xn).flatten
|
101
|
+
end
|
102
|
+
|
103
|
+
# Escapes HTTP reserved and unwise characters in +str+
|
104
|
+
def escape_uri(str)
|
105
|
+
str = str.dup
|
106
|
+
str = binary_encode(str)
|
107
|
+
str.gsub(UNESCAPED) { "%%%02X" % $1[0].ord }
|
108
|
+
end
|
109
|
+
|
110
|
+
# Unescapes HTTP reserved and unwise characters in +str+
|
111
|
+
def unescape_uri(str)
|
112
|
+
str = str.dup
|
113
|
+
str = binary_encode(str)
|
114
|
+
str.gsub(ESCAPED) { $1.hex.chr }
|
115
|
+
end
|
116
|
+
|
117
|
+
# Unescape form encoded values in +str+
|
118
|
+
def unescape_form(str)
|
119
|
+
str = str.dup
|
120
|
+
str = binary_encode(str)
|
121
|
+
str.gsub!(/\+/, ' ')
|
122
|
+
str.gsub(ESCAPED) { $1.hex.chr }
|
123
|
+
end
|
124
|
+
|
125
|
+
# Performs validation on the passed header hash and returns a string representation of the headers
|
126
|
+
def headers_hash_to_s(headers)
|
127
|
+
headers_str = String.new
|
128
|
+
headers.each do |key, values|
|
129
|
+
if key.to_s.match(/[\r\n]/)
|
130
|
+
raise Excon::Errors::InvalidHeaderKey.new(key.to_s.inspect + ' contains forbidden "\r" or "\n"')
|
131
|
+
end
|
132
|
+
[values].flatten.each do |value|
|
133
|
+
if value.to_s.match(/[\r\n]/)
|
134
|
+
# Don't include the potentially sensitive header value (i.e. authorization token) in the message
|
135
|
+
raise Excon::Errors::InvalidHeaderValue.new(key.to_s + ' header value contains forbidden "\r" or "\n"')
|
136
|
+
end
|
137
|
+
headers_str << key.to_s << ': ' << value.to_s << CR_NL
|
138
|
+
end
|
139
|
+
end
|
140
|
+
headers_str
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
3
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require 'cgi'
|
6
|
+
require 'forwardable'
|
7
|
+
require 'openssl'
|
8
|
+
require 'rbconfig'
|
9
|
+
require 'socket'
|
10
|
+
require 'timeout'
|
11
|
+
require 'uri'
|
12
|
+
require 'zlib'
|
13
|
+
require 'stringio'
|
14
|
+
|
15
|
+
require 'excon/version'
|
16
|
+
|
17
|
+
require 'excon/extensions/uri'
|
18
|
+
|
19
|
+
require 'excon/middlewares/base'
|
20
|
+
require 'excon/middlewares/expects'
|
21
|
+
require 'excon/middlewares/idempotent'
|
22
|
+
require 'excon/middlewares/instrumentor'
|
23
|
+
require 'excon/middlewares/mock'
|
24
|
+
require 'excon/middlewares/response_parser'
|
25
|
+
|
26
|
+
require 'excon/error'
|
27
|
+
require 'excon/constants'
|
28
|
+
require 'excon/utils'
|
29
|
+
|
30
|
+
require 'excon/connection'
|
31
|
+
require 'excon/headers'
|
32
|
+
require 'excon/response'
|
33
|
+
require 'excon/middlewares/decompress'
|
34
|
+
require 'excon/middlewares/escape_path'
|
35
|
+
require 'excon/middlewares/redirect_follower'
|
36
|
+
require 'excon/middlewares/capture_cookies'
|
37
|
+
require 'excon/pretty_printer'
|
38
|
+
require 'excon/socket'
|
39
|
+
require 'excon/ssl_socket'
|
40
|
+
require 'excon/instrumentors/standard_instrumentor'
|
41
|
+
require 'excon/instrumentors/logging_instrumentor'
|
42
|
+
require 'excon/unix_socket'
|
43
|
+
|
44
|
+
# Define defaults first so they will be available to other files
|
45
|
+
module Excon
|
46
|
+
class << self
|
47
|
+
|
48
|
+
# @return [Hash] defaults for Excon connections
|
49
|
+
def defaults
|
50
|
+
@defaults ||= DEFAULTS
|
51
|
+
end
|
52
|
+
|
53
|
+
# Change defaults for Excon connections
|
54
|
+
# @return [Hash] defaults for Excon connections
|
55
|
+
def defaults=(new_defaults)
|
56
|
+
@defaults = new_defaults
|
57
|
+
end
|
58
|
+
|
59
|
+
def display_warning(warning)
|
60
|
+
# Show warning if $VERBOSE or ENV['EXCON_DEBUG'] is set
|
61
|
+
if $VERBOSE || ENV['EXCON_DEBUG']
|
62
|
+
$stderr.puts "[excon][WARNING] #{warning}\n#{ caller.join("\n") }"
|
63
|
+
end
|
64
|
+
|
65
|
+
if @raise_on_warnings
|
66
|
+
raise Error::Warning.new(warning)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def set_raise_on_warnings!(should_raise)
|
71
|
+
@raise_on_warnings = should_raise
|
72
|
+
end
|
73
|
+
|
74
|
+
# Status of mocking
|
75
|
+
def mock
|
76
|
+
display_warning('Excon#mock is deprecated, use Excon.defaults[:mock] instead.')
|
77
|
+
self.defaults[:mock]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Change the status of mocking
|
81
|
+
# false is the default and works as expected
|
82
|
+
# true returns a value from stubs or raises
|
83
|
+
def mock=(new_mock)
|
84
|
+
display_warning('Excon#mock is deprecated, use Excon.defaults[:mock]= instead.')
|
85
|
+
self.defaults[:mock] = new_mock
|
86
|
+
end
|
87
|
+
|
88
|
+
# @return [String] The filesystem path to the SSL Certificate Authority
|
89
|
+
def ssl_ca_path
|
90
|
+
display_warning('Excon#ssl_ca_path is deprecated, use Excon.defaults[:ssl_ca_path] instead.')
|
91
|
+
self.defaults[:ssl_ca_path]
|
92
|
+
end
|
93
|
+
|
94
|
+
# Change path to the SSL Certificate Authority
|
95
|
+
# @return [String] The filesystem path to the SSL Certificate Authority
|
96
|
+
def ssl_ca_path=(new_ssl_ca_path)
|
97
|
+
display_warning('Excon#ssl_ca_path= is deprecated, use Excon.defaults[:ssl_ca_path]= instead.')
|
98
|
+
self.defaults[:ssl_ca_path] = new_ssl_ca_path
|
99
|
+
end
|
100
|
+
|
101
|
+
# @return [true, false] Whether or not to verify the peer's SSL certificate / chain
|
102
|
+
def ssl_verify_peer
|
103
|
+
display_warning('Excon#ssl_verify_peer is deprecated, use Excon.defaults[:ssl_verify_peer] instead.')
|
104
|
+
self.defaults[:ssl_verify_peer]
|
105
|
+
end
|
106
|
+
|
107
|
+
# Change the status of ssl peer verification
|
108
|
+
# @see Excon#ssl_verify_peer (attr_reader)
|
109
|
+
def ssl_verify_peer=(new_ssl_verify_peer)
|
110
|
+
display_warning('Excon#ssl_verify_peer= is deprecated, use Excon.defaults[:ssl_verify_peer]= instead.')
|
111
|
+
self.defaults[:ssl_verify_peer] = new_ssl_verify_peer
|
112
|
+
end
|
113
|
+
|
114
|
+
# @see Connection#initialize
|
115
|
+
# Initializes a new keep-alive session for a given remote host
|
116
|
+
# @param [String] url The destination URL
|
117
|
+
# @param [Hash<Symbol, >] params One or more option params to set on the Connection instance
|
118
|
+
# @return [Connection] A new Excon::Connection instance
|
119
|
+
def new(url, params = {})
|
120
|
+
uri_parser = params[:uri_parser] || defaults[:uri_parser]
|
121
|
+
uri = uri_parser.parse(url)
|
122
|
+
if params[:path]
|
123
|
+
uri_parser.parse(params[:path])
|
124
|
+
end
|
125
|
+
unless uri.scheme
|
126
|
+
raise ArgumentError.new("Invalid URI: #{uri}")
|
127
|
+
end
|
128
|
+
params = {
|
129
|
+
:host => uri.host,
|
130
|
+
:hostname => uri.hostname,
|
131
|
+
:path => uri.path,
|
132
|
+
:port => uri.port,
|
133
|
+
:query => uri.query,
|
134
|
+
:scheme => uri.scheme
|
135
|
+
}.merge(params)
|
136
|
+
if uri.password
|
137
|
+
params[:password] = Utils.unescape_uri(uri.password)
|
138
|
+
end
|
139
|
+
if uri.user
|
140
|
+
params[:user] = Utils.unescape_uri(uri.user)
|
141
|
+
end
|
142
|
+
Excon::Connection.new(params)
|
143
|
+
end
|
144
|
+
|
145
|
+
# push an additional stub onto the list to check for mock requests
|
146
|
+
# @param request_params [Hash<Symbol, >] request params to match against, omitted params match all
|
147
|
+
# @param response_params [Hash<Symbol, >] response params to return from matched request or block to call with params
|
148
|
+
def stub(request_params = {}, response_params = nil, &block)
|
149
|
+
if (method = request_params.delete(:method))
|
150
|
+
request_params[:method] = method.to_s.downcase.to_sym
|
151
|
+
end
|
152
|
+
if (url = request_params.delete(:url))
|
153
|
+
uri = URI.parse(url)
|
154
|
+
request_params = {
|
155
|
+
:host => uri.host,
|
156
|
+
:path => uri.path,
|
157
|
+
:port => uri.port,
|
158
|
+
:query => uri.query,
|
159
|
+
:scheme => uri.scheme
|
160
|
+
}.merge!(request_params)
|
161
|
+
if uri.user || uri.password
|
162
|
+
request_params[:headers] ||= {}
|
163
|
+
user, pass = Utils.unescape_form(uri.user.to_s), Utils.unescape_form(uri.password.to_s)
|
164
|
+
request_params[:headers]['Authorization'] ||= 'Basic ' + ["#{user}:#{pass}"].pack('m').delete(Excon::CR_NL)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
if request_params.has_key?(:headers)
|
168
|
+
headers = Excon::Headers.new
|
169
|
+
request_params[:headers].each do |key, value|
|
170
|
+
headers[key] = value
|
171
|
+
end
|
172
|
+
request_params[:headers] = headers
|
173
|
+
end
|
174
|
+
if block_given?
|
175
|
+
if response_params
|
176
|
+
raise(ArgumentError.new("stub requires either response_params OR a block"))
|
177
|
+
else
|
178
|
+
stub = [request_params, block]
|
179
|
+
end
|
180
|
+
elsif response_params
|
181
|
+
stub = [request_params, response_params]
|
182
|
+
else
|
183
|
+
raise(ArgumentError.new("stub requires either response_params OR a block"))
|
184
|
+
end
|
185
|
+
stubs.unshift(stub)
|
186
|
+
stub
|
187
|
+
end
|
188
|
+
|
189
|
+
# get a stub matching params or nil
|
190
|
+
# @param request_params [Hash<Symbol, >] request params to match against, omitted params match all
|
191
|
+
# @return [Hash<Symbol, >] response params to return from matched request or block to call with params
|
192
|
+
def stub_for(request_params={})
|
193
|
+
if (method = request_params.delete(:method))
|
194
|
+
request_params[:method] = method.to_s.downcase.to_sym
|
195
|
+
end
|
196
|
+
Excon.stubs.each do |stub, response_params|
|
197
|
+
captures = { :headers => {} }
|
198
|
+
headers_match = !stub.has_key?(:headers) || stub[:headers].keys.all? do |key|
|
199
|
+
case value = stub[:headers][key]
|
200
|
+
when Regexp
|
201
|
+
if (match = value.match(request_params[:headers][key]))
|
202
|
+
captures[:headers][key] = match.captures
|
203
|
+
end
|
204
|
+
match
|
205
|
+
else
|
206
|
+
value == request_params[:headers][key]
|
207
|
+
end
|
208
|
+
end
|
209
|
+
non_headers_match = (stub.keys - [:headers]).all? do |key|
|
210
|
+
case value = stub[key]
|
211
|
+
when Regexp
|
212
|
+
if (match = value.match(request_params[key]))
|
213
|
+
captures[key] = match.captures
|
214
|
+
end
|
215
|
+
match
|
216
|
+
else
|
217
|
+
value == request_params[key]
|
218
|
+
end
|
219
|
+
end
|
220
|
+
if headers_match && non_headers_match
|
221
|
+
request_params[:captures] = captures
|
222
|
+
return [stub, response_params]
|
223
|
+
end
|
224
|
+
end
|
225
|
+
nil
|
226
|
+
end
|
227
|
+
|
228
|
+
# get a list of defined stubs
|
229
|
+
def stubs
|
230
|
+
case Excon.defaults[:stubs]
|
231
|
+
when :global
|
232
|
+
@stubs ||= []
|
233
|
+
when :local
|
234
|
+
Thread.current[:_excon_stubs] ||= []
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# remove first/oldest stub matching request_params
|
239
|
+
# @param request_params [Hash<Symbol, >] request params to match against, omitted params match all
|
240
|
+
# @return [Hash<Symbol, >] response params from deleted stub
|
241
|
+
def unstub(request_params = {})
|
242
|
+
stub = stub_for(request_params)
|
243
|
+
Excon.stubs.delete_at(Excon.stubs.index(stub))
|
244
|
+
end
|
245
|
+
|
246
|
+
# Generic non-persistent HTTP methods
|
247
|
+
HTTP_VERBS.each do |method|
|
248
|
+
module_eval <<-DEF, __FILE__, __LINE__ + 1
|
249
|
+
def #{method}(url, params = {}, &block)
|
250
|
+
new(url, params).request(:method => :#{method}, &block)
|
251
|
+
end
|
252
|
+
DEF
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 The Ruby I18n team
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# Ruby I18n
|
2
|
+
|
3
|
+
[![Build Status](https://github.com/ruby-i18n/i18n/workflows/Ruby/badge.svg)](https://github.com/ruby-i18n/i18n/actions?query=workflow%3ARuby)
|
4
|
+
|
5
|
+
Ruby internationalization and localization (i18n) solution.
|
6
|
+
|
7
|
+
Currently maintained by @radar.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
### Rails
|
12
|
+
|
13
|
+
You will most commonly use this library within a Rails app.
|
14
|
+
|
15
|
+
[See the Rails Guide](https://guides.rubyonrails.org/i18n.html) for an example of its usage.
|
16
|
+
|
17
|
+
### Ruby (without Rails)
|
18
|
+
|
19
|
+
If you want to use this library without Rails, you can simply add `i18n` to your `Gemfile`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'i18n'
|
23
|
+
```
|
24
|
+
|
25
|
+
Then configure I18n with some translations, and a default locale:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
I18n.load_path << Dir[File.expand_path("config/locales") + "/*.yml"]
|
29
|
+
I18n.default_locale = :en # (note that `en` is already the default!)
|
30
|
+
```
|
31
|
+
|
32
|
+
A simple translation file in your project might live at `config/locales/en.yml` and look like:
|
33
|
+
|
34
|
+
```yml
|
35
|
+
en:
|
36
|
+
test: "This is a test"
|
37
|
+
```
|
38
|
+
|
39
|
+
You can then access this translation by doing:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
I18n.t(:test)
|
43
|
+
```
|
44
|
+
|
45
|
+
You can switch locales in your project by setting `I18n.locale` to a different value:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
I18n.locale = :de
|
49
|
+
I18n.t(:test) # => "Dies ist ein Test"
|
50
|
+
```
|
51
|
+
|
52
|
+
## Features
|
53
|
+
|
54
|
+
* Translation and localization
|
55
|
+
* Interpolation of values to translations
|
56
|
+
* Pluralization (CLDR compatible)
|
57
|
+
* Customizable transliteration to ASCII
|
58
|
+
* Flexible defaults
|
59
|
+
* Bulk lookup
|
60
|
+
* Lambdas as translation data
|
61
|
+
* Custom key/scope separator
|
62
|
+
* Custom exception handlers
|
63
|
+
* Extensible architecture with a swappable backend
|
64
|
+
|
65
|
+
## Pluggable Features
|
66
|
+
|
67
|
+
* Cache
|
68
|
+
* Pluralization: lambda pluralizers stored as translation data
|
69
|
+
* Locale fallbacks, RFC4647 compliant (optionally: RFC4646 locale validation)
|
70
|
+
* [Gettext support](https://github.com/ruby-i18n/i18n/wiki/Gettext)
|
71
|
+
* Translation metadata
|
72
|
+
|
73
|
+
## Alternative Backend
|
74
|
+
|
75
|
+
* Chain
|
76
|
+
* ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs)
|
77
|
+
* KeyValue (uses active_support/json and cannot store procs)
|
78
|
+
|
79
|
+
For more information and lots of resources see [the 'Resources' page on the wiki](https://github.com/ruby-i18n/i18n/wiki/Resources).
|
80
|
+
|
81
|
+
## Tests
|
82
|
+
|
83
|
+
You can run tests both with
|
84
|
+
|
85
|
+
* `rake test` or just `rake`
|
86
|
+
* run any test file directly, e.g. `ruby -Ilib:test test/api/simple_test.rb`
|
87
|
+
|
88
|
+
You can run all tests against all Gemfiles with
|
89
|
+
|
90
|
+
* `ruby test/run_all.rb`
|
91
|
+
|
92
|
+
The structure of the test suite is a bit unusual as it uses modules to reuse
|
93
|
+
particular tests in different test cases.
|
94
|
+
|
95
|
+
The reason for this is that we need to enforce the I18n API across various
|
96
|
+
combinations of extensions. E.g. the Simple backend alone needs to support
|
97
|
+
the same API as any combination of feature and/or optimization modules included
|
98
|
+
to the Simple backend. We test this by reusing the same API definition (implemented
|
99
|
+
as test methods) in test cases with different setups.
|
100
|
+
|
101
|
+
You can find the test cases that enforce the API in test/api. And you can find
|
102
|
+
the API definition test methods in test/api/tests.
|
103
|
+
|
104
|
+
All other test cases (e.g. as defined in test/backend, test/core_ext) etc.
|
105
|
+
follow the usual test setup and should be easy to grok.
|
106
|
+
|
107
|
+
## More Documentation
|
108
|
+
|
109
|
+
Additional documentation can be found here: https://github.com/ruby-i18n/i18n/wiki
|
110
|
+
|
111
|
+
## Contributors
|
112
|
+
|
113
|
+
* @radar
|
114
|
+
* @carlosantoniodasilva
|
115
|
+
* @josevalim
|
116
|
+
* @knapo
|
117
|
+
* @tigrish
|
118
|
+
* [and many more](https://github.com/ruby-i18n/i18n/graphs/contributors)
|
119
|
+
|
120
|
+
## License
|
121
|
+
|
122
|
+
MIT License. See the included MIT-LICENSE file.
|