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.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +6 -6
  4. data/contrib/zsh/generate_zsh_completion.rb +2 -2
  5. data/lib/vagrant/errors.rb +8 -0
  6. data/plugins/commands/upload/command.rb +1 -1
  7. data/plugins/guests/atomic/guest.rb +1 -1
  8. data/plugins/guests/coreos/cap/configure_networks.rb +65 -0
  9. data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +6 -3
  10. data/plugins/guests/suse/cap/halt.rb +5 -1
  11. data/plugins/guests/windows/cap/rsync.rb +5 -1
  12. data/plugins/hosts/darwin/cap/path.rb +4 -0
  13. data/plugins/hosts/darwin/cap/version.rb +23 -0
  14. data/plugins/hosts/darwin/plugin.rb +5 -0
  15. data/plugins/hosts/windows/cap/ssh.rb +1 -1
  16. data/plugins/providers/virtualbox/action/network.rb +39 -2
  17. data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +5 -3
  18. data/plugins/provisioners/chef/cap/linux/chef_installed.rb +5 -3
  19. data/plugins/provisioners/chef/cap/omnios/chef_installed.rb +7 -5
  20. data/plugins/provisioners/chef/cap/windows/chef_installed.rb +3 -2
  21. data/templates/locales/en.yml +25 -0
  22. data/vagrant.gemspec +1 -1
  23. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTING.md +23 -0
  24. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTORS.md +140 -0
  25. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/LICENSE.md +20 -0
  26. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/README.md +492 -0
  27. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/data/cacert.pem +3232 -0
  28. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/excon.gemspec +45 -0
  29. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/connection.rb +599 -0
  30. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/constants.rb +172 -0
  31. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/error.rb +229 -0
  32. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/extensions/uri.rb +34 -0
  33. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/headers.rb +85 -0
  34. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
  35. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
  36. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/base.rb +31 -0
  37. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/capture_cookies.rb +32 -0
  38. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/decompress.rb +44 -0
  39. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/escape_path.rb +12 -0
  40. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/expects.rb +25 -0
  41. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/idempotent.rb +57 -0
  42. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/instrumentor.rb +49 -0
  43. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/mock.rb +61 -0
  44. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/redirect_follower.rb +87 -0
  45. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/response_parser.rb +16 -0
  46. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/pretty_printer.rb +39 -0
  47. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/response.rb +234 -0
  48. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/socket.rb +297 -0
  49. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/ssl_socket.rb +194 -0
  50. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/exec.rb +26 -0
  51. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/puma.rb +23 -0
  52. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/unicorn.rb +40 -0
  53. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/webrick.rb +26 -0
  54. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/server.rb +106 -0
  55. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/unix_socket.rb +42 -0
  56. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/utils.rb +143 -0
  57. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/version.rb +4 -0
  58. data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon.rb +255 -0
  59. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/MIT-LICENSE +20 -0
  60. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/README.md +122 -0
  61. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/base.rb +289 -0
  62. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache.rb +113 -0
  63. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache_file.rb +36 -0
  64. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cascade.rb +56 -0
  65. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/chain.rb +130 -0
  66. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/fallbacks.rb +97 -0
  67. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/flatten.rb +118 -0
  68. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/gettext.rb +85 -0
  69. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/interpolation_compiler.rb +123 -0
  70. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/key_value.rb +206 -0
  71. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/memoize.rb +54 -0
  72. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/metadata.rb +71 -0
  73. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/pluralization.rb +55 -0
  74. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/simple.rb +108 -0
  75. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/transliterator.rb +108 -0
  76. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend.rb +21 -0
  77. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/config.rb +165 -0
  78. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/core_ext/hash.rb +59 -0
  79. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/exceptions.rb +111 -0
  80. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/helpers.rb +75 -0
  81. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/po_parser.rb +329 -0
  82. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext.rb +28 -0
  83. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/interpolate/ruby.rb +39 -0
  84. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/fallbacks.rb +99 -0
  85. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/parents.rb +24 -0
  86. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/rfc4646.rb +74 -0
  87. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/simple.rb +39 -0
  88. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag.rb +28 -0
  89. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale.rb +8 -0
  90. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/middleware.rb +17 -0
  91. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/basics.rb +60 -0
  92. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/defaults.rb +52 -0
  93. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/interpolation.rb +163 -0
  94. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/link.rb +66 -0
  95. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date.rb +117 -0
  96. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date_time.rb +103 -0
  97. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/procs.rb +117 -0
  98. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/time.rb +103 -0
  99. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization.rb +19 -0
  100. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/lookup.rb +81 -0
  101. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/pluralization.rb +35 -0
  102. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/procs.rb +60 -0
  103. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests.rb +14 -0
  104. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/version.rb +5 -0
  105. data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n.rb +415 -0
  106. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Code-of-Conduct.md +73 -0
  107. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Contributing.md +132 -0
  108. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/History.md +269 -0
  109. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Licence.md +25 -0
  110. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Manifest.txt +31 -0
  111. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/README.rdoc +194 -0
  112. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Rakefile +270 -0
  113. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb +57 -0
  114. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type.rb +634 -0
  115. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/_columnar.rb +137 -0
  116. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/cache.rb +58 -0
  117. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/columnar.rb +3 -0
  118. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/container.rb +96 -0
  119. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/deprecations.rb +36 -0
  120. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/full.rb +19 -0
  121. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/loader.rb +159 -0
  122. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/logger.rb +37 -0
  123. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/registry.rb +90 -0
  124. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types.rb +233 -0
  125. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime-types.rb +3 -0
  126. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/bad-fixtures/malformed +9 -0
  127. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/json.json +1 -0
  128. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/old-data +9 -0
  129. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/yaml.yaml +55 -0
  130. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/minitest_helper.rb +11 -0
  131. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_type.rb +621 -0
  132. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types.rb +169 -0
  133. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_cache.rb +118 -0
  134. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_class.rb +159 -0
  135. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_lazy.rb +49 -0
  136. data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_loader.rb +32 -0
  137. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Code-of-Conduct.md +75 -0
  138. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Contributing.md +241 -0
  139. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/History.md +494 -0
  140. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Licence.md +24 -0
  141. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Manifest.txt +34 -0
  142. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/README.md +73 -0
  143. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Rakefile +155 -0
  144. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/content_type_mime.db +878 -0
  145. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/ext_mime.db +1198 -0
  146. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime-types.json +1 -0
  147. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.content_type.column +2376 -0
  148. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.docs.column +2376 -0
  149. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.encoding.column +2376 -0
  150. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.flags.column +2376 -0
  151. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.friendly.column +2376 -0
  152. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.pext.column +2376 -0
  153. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.use_instead.column +2376 -0
  154. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.xrefs.column +2376 -0
  155. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime/types/data.rb +21 -0
  156. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime-types-data.rb +3 -0
  157. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/application.yaml +17254 -0
  158. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/audio.yaml +1716 -0
  159. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/chemical.yaml +71 -0
  160. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/conference.yaml +9 -0
  161. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/drawing.yaml +15 -0
  162. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/font.yaml +65 -0
  163. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/image.yaml +1251 -0
  164. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/message.yaml +200 -0
  165. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/model.yaml +390 -0
  166. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/multipart.yaml +179 -0
  167. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/provisional-standard-types.yaml +129 -0
  168. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/text.yaml +1166 -0
  169. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/video.yaml +1121 -0
  170. data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/world.yaml +8 -0
  171. data/vendor/bundle/ruby/3.0.0/specifications/excon-0.89.0.gemspec +58 -0
  172. data/vendor/bundle/ruby/3.0.0/specifications/i18n-1.8.11.gemspec +32 -0
  173. data/vendor/bundle/ruby/3.0.0/specifications/mime-types-3.4.1.gemspec +63 -0
  174. data/vendor/bundle/ruby/3.0.0/specifications/mime-types-data-3.2021.1115.gemspec +54 -0
  175. data/version.txt +1 -1
  176. metadata +157 -4
@@ -0,0 +1,415 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'concurrent/map'
4
+ require 'concurrent/hash'
5
+
6
+ require 'i18n/version'
7
+ require 'i18n/exceptions'
8
+ require 'i18n/interpolate/ruby'
9
+
10
+ module I18n
11
+ autoload :Backend, 'i18n/backend'
12
+ autoload :Config, 'i18n/config'
13
+ autoload :Gettext, 'i18n/gettext'
14
+ autoload :Locale, 'i18n/locale'
15
+ autoload :Tests, 'i18n/tests'
16
+ autoload :Middleware, 'i18n/middleware'
17
+
18
+ RESERVED_KEYS = %i[
19
+ cascade
20
+ deep_interpolation
21
+ default
22
+ exception_handler
23
+ fallback
24
+ fallback_in_progress
25
+ format
26
+ object
27
+ raise
28
+ resolve
29
+ scope
30
+ separator
31
+ throw
32
+ ].freeze
33
+ RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/
34
+ EMPTY_HASH = {}.freeze
35
+
36
+ def self.new_double_nested_cache # :nodoc:
37
+ Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
38
+ end
39
+
40
+ module Base
41
+ # Gets I18n configuration object.
42
+ def config
43
+ Thread.current[:i18n_config] ||= I18n::Config.new
44
+ end
45
+
46
+ # Sets I18n configuration object.
47
+ def config=(value)
48
+ Thread.current[:i18n_config] = value
49
+ end
50
+
51
+ # Write methods which delegates to the configuration object
52
+ %w(locale backend default_locale available_locales default_separator
53
+ exception_handler load_path enforce_available_locales).each do |method|
54
+ module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1
55
+ def #{method}
56
+ config.#{method}
57
+ end
58
+
59
+ def #{method}=(value)
60
+ config.#{method} = (value)
61
+ end
62
+ DELEGATORS
63
+ end
64
+
65
+ # Tells the backend to reload translations. Used in situations like the
66
+ # Rails development environment. Backends can implement whatever strategy
67
+ # is useful.
68
+ def reload!
69
+ config.clear_available_locales_set
70
+ config.backend.reload!
71
+ end
72
+
73
+ # Tells the backend to load translations now. Used in situations like the
74
+ # Rails production environment. Backends can implement whatever strategy
75
+ # is useful.
76
+ def eager_load!
77
+ config.backend.eager_load!
78
+ end
79
+
80
+ # Translates, pluralizes and interpolates a given key using a given locale,
81
+ # scope, and default, as well as interpolation values.
82
+ #
83
+ # *LOOKUP*
84
+ #
85
+ # Translation data is organized as a nested hash using the upper-level keys
86
+ # as namespaces. <em>E.g.</em>, ActionView ships with the translation:
87
+ # <tt>:date => {:formats => {:short => "%b %d"}}</tt>.
88
+ #
89
+ # Translations can be looked up at any level of this hash using the key argument
90
+ # and the scope option. <em>E.g.</em>, in this example <tt>I18n.t :date</tt>
91
+ # returns the whole translations hash <tt>{:formats => {:short => "%b %d"}}</tt>.
92
+ #
93
+ # Key can be either a single key or a dot-separated key (both Strings and Symbols
94
+ # work). <em>E.g.</em>, the short format can be looked up using both:
95
+ # I18n.t 'date.formats.short'
96
+ # I18n.t :'date.formats.short'
97
+ #
98
+ # Scope can be either a single key, a dot-separated key or an array of keys
99
+ # or dot-separated keys. Keys and scopes can be combined freely. So these
100
+ # examples will all look up the same short date format:
101
+ # I18n.t 'date.formats.short'
102
+ # I18n.t 'formats.short', :scope => 'date'
103
+ # I18n.t 'short', :scope => 'date.formats'
104
+ # I18n.t 'short', :scope => %w(date formats)
105
+ #
106
+ # *INTERPOLATION*
107
+ #
108
+ # Translations can contain interpolation variables which will be replaced by
109
+ # values passed to #translate as part of the options hash, with the keys matching
110
+ # the interpolation variable names.
111
+ #
112
+ # <em>E.g.</em>, with a translation <tt>:foo => "foo %{bar}"</tt> the option
113
+ # value for the key +bar+ will be interpolated into the translation:
114
+ # I18n.t :foo, :bar => 'baz' # => 'foo baz'
115
+ #
116
+ # *PLURALIZATION*
117
+ #
118
+ # Translation data can contain pluralized translations. Pluralized translations
119
+ # are arrays of singular/plural versions of translations like <tt>['Foo', 'Foos']</tt>.
120
+ #
121
+ # Note that <tt>I18n::Backend::Simple</tt> only supports an algorithm for English
122
+ # pluralization rules. Other algorithms can be supported by custom backends.
123
+ #
124
+ # This returns the singular version of a pluralized translation:
125
+ # I18n.t :foo, :count => 1 # => 'Foo'
126
+ #
127
+ # These both return the plural version of a pluralized translation:
128
+ # I18n.t :foo, :count => 0 # => 'Foos'
129
+ # I18n.t :foo, :count => 2 # => 'Foos'
130
+ #
131
+ # The <tt>:count</tt> option can be used both for pluralization and interpolation.
132
+ # <em>E.g.</em>, with the translation
133
+ # <tt>:foo => ['%{count} foo', '%{count} foos']</tt>, count will
134
+ # be interpolated to the pluralized translation:
135
+ # I18n.t :foo, :count => 1 # => '1 foo'
136
+ #
137
+ # *DEFAULTS*
138
+ #
139
+ # This returns the translation for <tt>:foo</tt> or <tt>default</tt> if no translation was found:
140
+ # I18n.t :foo, :default => 'default'
141
+ #
142
+ # This returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt> if no
143
+ # translation for <tt>:foo</tt> was found:
144
+ # I18n.t :foo, :default => :bar
145
+ #
146
+ # Returns the translation for <tt>:foo</tt> or the translation for <tt>:bar</tt>
147
+ # or <tt>default</tt> if no translations for <tt>:foo</tt> and <tt>:bar</tt> were found.
148
+ # I18n.t :foo, :default => [:bar, 'default']
149
+ #
150
+ # *BULK LOOKUP*
151
+ #
152
+ # This returns an array with the translations for <tt>:foo</tt> and <tt>:bar</tt>.
153
+ # I18n.t [:foo, :bar]
154
+ #
155
+ # Can be used with dot-separated nested keys:
156
+ # I18n.t [:'baz.foo', :'baz.bar']
157
+ #
158
+ # Which is the same as using a scope option:
159
+ # I18n.t [:foo, :bar], :scope => :baz
160
+ #
161
+ # *LAMBDAS*
162
+ #
163
+ # Both translations and defaults can be given as Ruby lambdas. Lambdas will be
164
+ # called and passed the key and options.
165
+ #
166
+ # E.g. assuming the key <tt>:salutation</tt> resolves to:
167
+ # lambda { |key, options| options[:gender] == 'm' ? "Mr. #{options[:name]}" : "Mrs. #{options[:name]}" }
168
+ #
169
+ # Then <tt>I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith".
170
+ #
171
+ # Note that the string returned by lambda will go through string interpolation too,
172
+ # so the following lambda would give the same result:
173
+ # lambda { |key, options| options[:gender] == 'm' ? "Mr. %{name}" : "Mrs. %{name}" }
174
+ #
175
+ # It is recommended to use/implement lambdas in an "idempotent" way. E.g. when
176
+ # a cache layer is put in front of I18n.translate it will generate a cache key
177
+ # from the argument values passed to #translate. Therefore your lambdas should
178
+ # always return the same translations/values per unique combination of argument
179
+ # values.
180
+ #
181
+ # *Ruby 2.7+ keyword arguments warning*
182
+ #
183
+ # This method uses keyword arguments.
184
+ # There is a breaking change in ruby that produces warning with ruby 2.7 and won't work as expected with ruby 3.0
185
+ # The "hash" parameter must be passed as keyword argument.
186
+ #
187
+ # Good:
188
+ # I18n.t(:salutation, :gender => 'w', :name => 'Smith')
189
+ # I18n.t(:salutation, **{ :gender => 'w', :name => 'Smith' })
190
+ # I18n.t(:salutation, **any_hash)
191
+ #
192
+ # Bad:
193
+ # I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
194
+ # I18n.t(:salutation, any_hash)
195
+ #
196
+ def translate(key = nil, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
197
+ locale ||= config.locale
198
+ raise Disabled.new('t') if locale == false
199
+ enforce_available_locales!(locale)
200
+
201
+ backend = config.backend
202
+
203
+ result = catch(:exception) do
204
+ if key.is_a?(Array)
205
+ key.map { |k| backend.translate(locale, k, options) }
206
+ else
207
+ backend.translate(locale, key, options)
208
+ end
209
+ end
210
+
211
+ if result.is_a?(MissingTranslation)
212
+ handle_exception((throw && :throw || raise && :raise), result, locale, key, options)
213
+ else
214
+ result
215
+ end
216
+ end
217
+ alias :t :translate
218
+
219
+ # Wrapper for <tt>translate</tt> that adds <tt>:raise => true</tt>. With
220
+ # this option, if no translation is found, it will raise <tt>I18n::MissingTranslationData</tt>
221
+ def translate!(key, **options)
222
+ translate(key, **options, raise: true)
223
+ end
224
+ alias :t! :translate!
225
+
226
+ # Returns true if a translation exists for a given key, otherwise returns false.
227
+ def exists?(key, _locale = nil, locale: _locale, **options)
228
+ locale ||= config.locale
229
+ raise Disabled.new('exists?') if locale == false
230
+ raise I18n::ArgumentError if key.is_a?(String) && key.empty?
231
+ config.backend.exists?(locale, key, options)
232
+ end
233
+
234
+ # Transliterates UTF-8 characters to ASCII. By default this method will
235
+ # transliterate only Latin strings to an ASCII approximation:
236
+ #
237
+ # I18n.transliterate("Ærøskøbing")
238
+ # # => "AEroskobing"
239
+ #
240
+ # I18n.transliterate("日本語")
241
+ # # => "???"
242
+ #
243
+ # It's also possible to add support for per-locale transliterations. I18n
244
+ # expects transliteration rules to be stored at
245
+ # <tt>i18n.transliterate.rule</tt>.
246
+ #
247
+ # Transliteration rules can either be a Hash or a Proc. Procs must accept a
248
+ # single string argument. Hash rules inherit the default transliteration
249
+ # rules, while Procs do not.
250
+ #
251
+ # *Examples*
252
+ #
253
+ # Setting a Hash in <locale>.yml:
254
+ #
255
+ # i18n:
256
+ # transliterate:
257
+ # rule:
258
+ # ü: "ue"
259
+ # ö: "oe"
260
+ #
261
+ # Setting a Hash using Ruby:
262
+ #
263
+ # store_translations(:de, :i18n => {
264
+ # :transliterate => {
265
+ # :rule => {
266
+ # "ü" => "ue",
267
+ # "ö" => "oe"
268
+ # }
269
+ # }
270
+ # )
271
+ #
272
+ # Setting a Proc:
273
+ #
274
+ # translit = lambda {|string| MyTransliterator.transliterate(string) }
275
+ # store_translations(:xx, :i18n => {:transliterate => {:rule => translit})
276
+ #
277
+ # Transliterating strings:
278
+ #
279
+ # I18n.locale = :en
280
+ # I18n.transliterate("Jürgen") # => "Jurgen"
281
+ # I18n.locale = :de
282
+ # I18n.transliterate("Jürgen") # => "Juergen"
283
+ # I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen"
284
+ # I18n.transliterate("Jürgen", :locale => :de) # => "Juergen"
285
+ def transliterate(key, throw: false, raise: false, locale: nil, replacement: nil, **options)
286
+ locale ||= config.locale
287
+ raise Disabled.new('transliterate') if locale == false
288
+ enforce_available_locales!(locale)
289
+
290
+ config.backend.transliterate(locale, key, replacement)
291
+ rescue I18n::ArgumentError => exception
292
+ handle_exception((throw && :throw || raise && :raise), exception, locale, key, options)
293
+ end
294
+
295
+ # Localizes certain objects, such as dates and numbers to local formatting.
296
+ def localize(object, locale: nil, format: nil, **options)
297
+ locale ||= config.locale
298
+ raise Disabled.new('l') if locale == false
299
+ enforce_available_locales!(locale)
300
+
301
+ format ||= :default
302
+ config.backend.localize(locale, object, format, options)
303
+ end
304
+ alias :l :localize
305
+
306
+ # Executes block with given I18n.locale set.
307
+ def with_locale(tmp_locale = nil)
308
+ if tmp_locale == nil
309
+ yield
310
+ else
311
+ current_locale = self.locale
312
+ self.locale = tmp_locale
313
+ begin
314
+ yield
315
+ ensure
316
+ self.locale = current_locale
317
+ end
318
+ end
319
+ end
320
+
321
+ # Merges the given locale, key and scope into a single array of keys.
322
+ # Splits keys that contain dots into multiple keys. Makes sure all
323
+ # keys are Symbols.
324
+ def normalize_keys(locale, key, scope, separator = nil)
325
+ separator ||= I18n.default_separator
326
+
327
+ keys = []
328
+ keys.concat normalize_key(locale, separator)
329
+ keys.concat normalize_key(scope, separator)
330
+ keys.concat normalize_key(key, separator)
331
+ keys
332
+ end
333
+
334
+ # Returns true when the passed locale, which can be either a String or a
335
+ # Symbol, is in the list of available locales. Returns false otherwise.
336
+ def locale_available?(locale)
337
+ I18n.config.available_locales_set.include?(locale)
338
+ end
339
+
340
+ # Raises an InvalidLocale exception when the passed locale is not available.
341
+ def enforce_available_locales!(locale)
342
+ if locale != false && config.enforce_available_locales
343
+ raise I18n::InvalidLocale.new(locale) if !locale_available?(locale)
344
+ end
345
+ end
346
+
347
+ def available_locales_initialized?
348
+ config.available_locales_initialized?
349
+ end
350
+
351
+ private
352
+
353
+ # Any exceptions thrown in translate will be sent to the @@exception_handler
354
+ # which can be a Symbol, a Proc or any other Object unless they're forced to
355
+ # be raised or thrown (MissingTranslation).
356
+ #
357
+ # If exception_handler is a Symbol then it will simply be sent to I18n as
358
+ # a method call. A Proc will simply be called. In any other case the
359
+ # method #call will be called on the exception_handler object.
360
+ #
361
+ # Examples:
362
+ #
363
+ # I18n.exception_handler = :custom_exception_handler # this is the default
364
+ # I18n.custom_exception_handler(exception, locale, key, options) # will be called like this
365
+ #
366
+ # I18n.exception_handler = lambda { |*args| ... } # a lambda
367
+ # I18n.exception_handler.call(exception, locale, key, options) # will be called like this
368
+ #
369
+ # I18n.exception_handler = I18nExceptionHandler.new # an object
370
+ # I18n.exception_handler.call(exception, locale, key, options) # will be called like this
371
+ def handle_exception(handling, exception, locale, key, options)
372
+ case handling
373
+ when :raise
374
+ raise exception.respond_to?(:to_exception) ? exception.to_exception : exception
375
+ when :throw
376
+ throw :exception, exception
377
+ else
378
+ case handler = options[:exception_handler] || config.exception_handler
379
+ when Symbol
380
+ send(handler, exception, locale, key, options)
381
+ else
382
+ handler.call(exception, locale, key, options)
383
+ end
384
+ end
385
+ end
386
+
387
+ @@normalized_key_cache = I18n.new_double_nested_cache
388
+
389
+ def normalize_key(key, separator)
390
+ @@normalized_key_cache[separator][key] ||=
391
+ case key
392
+ when Array
393
+ key.flat_map { |k| normalize_key(k, separator) }
394
+ else
395
+ keys = key.to_s.split(separator)
396
+ keys.delete('')
397
+ keys.map! do |k|
398
+ case k
399
+ when /\A[-+]?[1-9]\d*\z/ # integer
400
+ k.to_i
401
+ when 'true'
402
+ true
403
+ when 'false'
404
+ false
405
+ else
406
+ k.to_sym
407
+ end
408
+ end
409
+ keys
410
+ end
411
+ end
412
+ end
413
+
414
+ extend Base
415
+ end
@@ -0,0 +1,73 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
@@ -0,0 +1,132 @@
1
+ # Contributing
2
+
3
+ I value any contribution to mime-types you can provide: a bug report, a feature
4
+ request, or code contributions.
5
+
6
+ There are a few guidelines for contributing to mime-types:
7
+
8
+ - Code changes _will_ _not_ be accepted without tests. The test suite is
9
+ written with [minitest].
10
+ - Match my coding style.
11
+ - Use a thoughtfully-named topic branch that contains your change. Rebase your
12
+ commits into logical chunks as necessary.
13
+ - Use [quality commit messages].
14
+ - Do not change the version number; when your patch is accepted and a release
15
+ is made, the version will be updated at that point.
16
+ - Submit a GitHub pull request with your changes.
17
+ - New or changed behaviours require new or updated documentation.
18
+
19
+ ## Adding or Modifying MIME Types
20
+
21
+ The mime-types registry is no longer contained in mime-types, but in
22
+ [mime-types-data]. Please see that project for contributions there.
23
+
24
+ ### Test Dependencies
25
+
26
+ mime-types uses Ryan Davis’s [Hoe] to manage the release process, and it adds
27
+ a number of rake tasks. You will mostly be interested in `rake`, which runs
28
+ the tests the same way that `rake test` or `rake travis` will do.
29
+
30
+ To assist with the installation of the development dependencies for
31
+ mime-types, I have provided the simplest possible Gemfile pointing to the
32
+ (generated) `mime-types.gemspec` file. This will permit you to do `bundle
33
+ install` to get the development dependencies. If you aleady have `hoe`
34
+ installed, you can accomplish the same thing with `rake newb`.
35
+
36
+ This task will install any missing dependencies, run the tests/specs, and
37
+ generate the RDoc.
38
+
39
+ You can run tests with code coverage analysis by running `rake
40
+ test:coverage`.
41
+
42
+ ## Benchmarks
43
+
44
+ mime-types offers several benchmark tasks to measure different measures of
45
+ performance.
46
+
47
+ There is a repeated load test, measuring how long it takes to start and load
48
+ mime-types with its full registry. By default, it runs fifty loops and uses the
49
+ built-in benchmark library:
50
+
51
+ - `rake benchmark:load`
52
+
53
+ There are two allocation tracing benchmarks (for normal and columnar loads).
54
+ These can only be run on Ruby 2.1 or better and requires the
55
+ [allocation\_tracer] gem (not installed by default).
56
+
57
+ - `rake benchmark:allocations`
58
+ - `rake benchmark:allocations:columnar`
59
+
60
+ There are two loaded object count benchmarks (for normal and columnar loads).
61
+ These use `ObjectSpace.count_objects`.
62
+
63
+ - `rake benchmark:objects`
64
+ - `rake benchmark:objects:columnar`
65
+
66
+ ## Workflow
67
+
68
+ Here's the most direct way to get your work merged into the project:
69
+
70
+ - Fork the project.
71
+ - Clone down your fork (`git clone git://github.com/<username>/ruby-mime-types.git`).
72
+ - Create a topic branch to contain your change (`git checkout -b my_awesome_feature`).
73
+ - Hack away, add tests. Not necessarily in that order.
74
+ - Make sure everything still passes by running `rake`.
75
+ - If necessary, rebase your commits into logical chunks, without errors.
76
+ - Push the branch up (`git push origin my_awesome_feature`).
77
+ - Create a pull request against mime-types/ruby-mime-types and describe what
78
+ your change does and the why you think it should be merged.
79
+
80
+ ## Contributors
81
+
82
+ - Austin Ziegler created mime-types.
83
+
84
+ Thanks to everyone else who has contributed to mime-types over the years:
85
+
86
+ - Aaron Patterson
87
+ - Aggelos Avgerinos
88
+ - Al Snow
89
+ - Andre Pankratz
90
+ - Andy Brody
91
+ - Arnaud Meuret
92
+ - Brandon Galbraith
93
+ - Burke Libbey
94
+ - Chris Gat
95
+ - David Genord
96
+ - Dillon Welch
97
+ - Eric Marden
98
+ - Edward Betts
99
+ - Garret Alfert
100
+ - Godfrey Chan
101
+ - Greg Brockman
102
+ - Hans de Graaff
103
+ - Henrik Hodne
104
+ - Igor Victor
105
+ - Janko Marohnić
106
+ - Jean Boussier
107
+ - Jeremy Evans
108
+ - Juanito Fatas
109
+ - Jun Aruga
110
+ - Łukasz Śliwa
111
+ - Keerthi Siva
112
+ - Ken Ip
113
+ - Kevin Menard
114
+ - Koichi ITO
115
+ - Martin d'Allens
116
+ - Mauricio Linhares
117
+ - Nicolas Leger
118
+ - Nicholas La Roux
119
+ - nycvotes-dev
120
+ - Olle Jonsson
121
+ - Postmodern
122
+ - Richard Hirner
123
+ - Richard Hurt
124
+ - Richard Schneeman
125
+ - Tibor Szolár
126
+ - Todd Carrico
127
+
128
+ [minitest]: https://github.com/seattlerb/minitest
129
+ [quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
130
+ [mime-types-data]: https://github.com/mime-types/mime-types-data
131
+ [hoe]: https://github.com/seattlerb/hoe
132
+ [allocation\_tracer]: https://github.com/ko1/allocation_tracer