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,74 @@
1
+ # RFC 4646/47 compliant Locale tag implementation that parses locale tags to
2
+ # subtags such as language, script, region, variant etc.
3
+ #
4
+ # For more information see by http://en.wikipedia.org/wiki/IETF_language_tag
5
+ #
6
+ # Rfc4646::Parser does not implement grandfathered tags.
7
+
8
+ module I18n
9
+ module Locale
10
+ module Tag
11
+ RFC4646_SUBTAGS = [ :language, :script, :region, :variant, :extension, :privateuse, :grandfathered ]
12
+ RFC4646_FORMATS = { :language => :downcase, :script => :capitalize, :region => :upcase, :variant => :downcase }
13
+
14
+ class Rfc4646 < Struct.new(*RFC4646_SUBTAGS)
15
+ class << self
16
+ # Parses the given tag and returns a Tag instance if it is valid.
17
+ # Returns false if the given tag is not valid according to RFC 4646.
18
+ def tag(tag)
19
+ matches = parser.match(tag)
20
+ new(*matches) if matches
21
+ end
22
+
23
+ def parser
24
+ @@parser ||= Rfc4646::Parser
25
+ end
26
+
27
+ def parser=(parser)
28
+ @@parser = parser
29
+ end
30
+ end
31
+
32
+ include Parents
33
+
34
+ RFC4646_FORMATS.each do |name, format|
35
+ define_method(name) { self[name].send(format) unless self[name].nil? }
36
+ end
37
+
38
+ def to_sym
39
+ to_s.to_sym
40
+ end
41
+
42
+ def to_s
43
+ @tag ||= to_a.compact.join("-")
44
+ end
45
+
46
+ def to_a
47
+ members.collect { |attr| self.send(attr) }
48
+ end
49
+
50
+ module Parser
51
+ PATTERN = %r{\A(?:
52
+ ([a-z]{2,3}(?:(?:-[a-z]{3}){0,3})?|[a-z]{4}|[a-z]{5,8}) # language
53
+ (?:-([a-z]{4}))? # script
54
+ (?:-([a-z]{2}|\d{3}))? # region
55
+ (?:-([0-9a-z]{5,8}|\d[0-9a-z]{3}))* # variant
56
+ (?:-([0-9a-wyz](?:-[0-9a-z]{2,8})+))* # extension
57
+ (?:-(x(?:-[0-9a-z]{1,8})+))?| # privateuse subtag
58
+ (x(?:-[0-9a-z]{1,8})+)| # privateuse tag
59
+ /* ([a-z]{1,3}(?:-[0-9a-z]{2,8}){1,2}) */ # grandfathered
60
+ )\z}xi
61
+
62
+ class << self
63
+ def match(tag)
64
+ c = PATTERN.match(tag.to_s).captures
65
+ c[0..4] << (c[5].nil? ? c[6] : c[5]) << c[7] # TODO c[7] is grandfathered, throw a NotImplemented exception here?
66
+ rescue
67
+ false
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,39 @@
1
+ # Simple Locale tag implementation that computes subtags by simply splitting
2
+ # the locale tag at '-' occurences.
3
+ module I18n
4
+ module Locale
5
+ module Tag
6
+ class Simple
7
+ class << self
8
+ def tag(tag)
9
+ new(tag)
10
+ end
11
+ end
12
+
13
+ include Parents
14
+
15
+ attr_reader :tag
16
+
17
+ def initialize(*tag)
18
+ @tag = tag.join('-').to_sym
19
+ end
20
+
21
+ def subtags
22
+ @subtags = tag.to_s.split('-').map!(&:to_s)
23
+ end
24
+
25
+ def to_sym
26
+ tag
27
+ end
28
+
29
+ def to_s
30
+ tag.to_s
31
+ end
32
+
33
+ def to_a
34
+ subtags
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module I18n
4
+ module Locale
5
+ module Tag
6
+ autoload :Parents, 'i18n/locale/tag/parents'
7
+ autoload :Rfc4646, 'i18n/locale/tag/rfc4646'
8
+ autoload :Simple, 'i18n/locale/tag/simple'
9
+
10
+ class << self
11
+ # Returns the current locale tag implementation. Defaults to +I18n::Locale::Tag::Simple+.
12
+ def implementation
13
+ @@implementation ||= Simple
14
+ end
15
+
16
+ # Sets the current locale tag implementation. Use this to set a different locale tag implementation.
17
+ def implementation=(implementation)
18
+ @@implementation = implementation
19
+ end
20
+
21
+ # Factory method for locale tags. Delegates to the current locale tag implementation.
22
+ def tag(tag)
23
+ implementation.tag(tag)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module I18n
4
+ module Locale
5
+ autoload :Fallbacks, 'i18n/locale/fallbacks'
6
+ autoload :Tag, 'i18n/locale/tag'
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module I18n
4
+ class Middleware
5
+
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ @app.call(env)
12
+ ensure
13
+ Thread.current[:i18n_config] = I18n::Config.new
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ module I18n
2
+ module Tests
3
+ module Basics
4
+ def teardown
5
+ I18n.available_locales = nil
6
+ end
7
+
8
+ test "available_locales returns the locales stored to the backend by default" do
9
+ I18n.backend.store_translations('de', :foo => 'bar')
10
+ I18n.backend.store_translations('en', :foo => 'foo')
11
+
12
+ assert I18n.available_locales.include?(:de)
13
+ assert I18n.available_locales.include?(:en)
14
+ end
15
+
16
+ test "available_locales can be set to something else independently from the actual locale data" do
17
+ I18n.backend.store_translations('de', :foo => 'bar')
18
+ I18n.backend.store_translations('en', :foo => 'foo')
19
+
20
+ I18n.available_locales = :foo
21
+ assert_equal [:foo], I18n.available_locales
22
+
23
+ I18n.available_locales = [:foo, 'bar']
24
+ assert_equal [:foo, :bar], I18n.available_locales
25
+
26
+ I18n.available_locales = nil
27
+ assert I18n.available_locales.include?(:de)
28
+ assert I18n.available_locales.include?(:en)
29
+ end
30
+
31
+ test "available_locales memoizes when set explicitely" do
32
+ I18n.backend.expects(:available_locales).never
33
+ I18n.available_locales = [:foo]
34
+ I18n.backend.store_translations('de', :bar => 'baz')
35
+ I18n.reload!
36
+ assert_equal [:foo], I18n.available_locales
37
+ end
38
+
39
+ test "available_locales delegates to the backend when not set explicitely" do
40
+ original_available_locales_value = I18n.backend.available_locales
41
+ I18n.backend.expects(:available_locales).returns(original_available_locales_value).twice
42
+ assert_equal I18n.backend.available_locales, I18n.available_locales
43
+ end
44
+
45
+ test "exists? is implemented by the backend" do
46
+ I18n.backend.store_translations(:foo, :bar => 'baz')
47
+ assert I18n.exists?(:bar, :foo)
48
+ end
49
+
50
+ test "storing a nil value as a translation removes it from the available locale data" do
51
+ I18n.backend.store_translations(:en, :to_be_deleted => 'bar')
52
+ assert_equal 'bar', I18n.t(:to_be_deleted, :default => 'baz')
53
+
54
+ I18n.cache_store.clear if I18n.respond_to?(:cache_store) && I18n.cache_store
55
+ I18n.backend.store_translations(:en, :to_be_deleted => nil)
56
+ assert_equal 'baz', I18n.t(:to_be_deleted, :default => 'baz')
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ module I18n
4
+ module Tests
5
+ module Defaults
6
+ def setup
7
+ super
8
+ I18n.backend.store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' })
9
+ end
10
+
11
+ test "defaults: given nil as a key it returns the given default" do
12
+ assert_equal 'default', I18n.t(nil, :default => 'default')
13
+ end
14
+
15
+ test "defaults: given a symbol as a default it translates the symbol" do
16
+ assert_equal 'bar', I18n.t(nil, :default => :'foo.bar')
17
+ end
18
+
19
+ test "defaults: given a symbol as a default and a scope it stays inside the scope when looking up the symbol" do
20
+ assert_equal 'bar', I18n.t(:missing, :default => :bar, :scope => :foo)
21
+ end
22
+
23
+ test "defaults: given an array as a default it returns the first match" do
24
+ assert_equal 'bar', I18n.t(:does_not_exist, :default => [:does_not_exist_2, :'foo.bar'])
25
+ end
26
+
27
+ test "defaults: given an array as a default with false it returns false" do
28
+ assert_equal false, I18n.t(:does_not_exist, :default => [false])
29
+ end
30
+
31
+ test "defaults: given false it returns false" do
32
+ assert_equal false, I18n.t(:does_not_exist, :default => false)
33
+ end
34
+
35
+ test "defaults: given nil it returns nil" do
36
+ assert_nil I18n.t(:does_not_exist, :default => nil)
37
+ end
38
+
39
+ test "defaults: given an array of missing keys it raises a MissingTranslationData exception" do
40
+ assert_raise I18n::MissingTranslationData do
41
+ I18n.t(:does_not_exist, :default => [:does_not_exist_2, :does_not_exist_3], :raise => true)
42
+ end
43
+ end
44
+
45
+ test "defaults: using a custom scope separator" do
46
+ # data must have been stored using the custom separator when using the ActiveRecord backend
47
+ I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' })
48
+ assert_equal 'bar', I18n.t(nil, :default => :'foo|bar', :separator => '|')
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,163 @@
1
+ # encoding: utf-8
2
+
3
+ module I18n
4
+ module Tests
5
+ module Interpolation
6
+ # If no interpolation parameter is not given, I18n should not alter the string.
7
+ # This behavior is due to three reasons:
8
+ #
9
+ # * Checking interpolation keys in all strings hits performance, badly;
10
+ #
11
+ # * This allows us to retrieve untouched values through I18n. For example
12
+ # I could have a middleware that returns I18n lookup results in JSON
13
+ # to be processed through Javascript. Leaving the keys untouched allows
14
+ # the interpolation to happen at the javascript level;
15
+ #
16
+ # * Security concerns: if I allow users to translate a web site, they can
17
+ # insert %{} in messages causing the I18n lookup to fail in every request.
18
+ #
19
+ test "interpolation: given no values it does not alter the string" do
20
+ assert_equal 'Hi %{name}!', interpolate(:default => 'Hi %{name}!')
21
+ end
22
+
23
+ test "interpolation: given values it interpolates them into the string" do
24
+ assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David')
25
+ end
26
+
27
+ test "interpolation: works with a pipe" do
28
+ assert_equal 'Hi david!', interpolate(:default => 'Hi %{name|lowercase}!', :'name|lowercase' => 'david')
29
+ end
30
+
31
+ test "interpolation: given a nil value it still interpolates it into the string" do
32
+ assert_equal 'Hi !', interpolate(:default => 'Hi %{name}!', :name => nil)
33
+ end
34
+
35
+ test "interpolation: given a lambda as a value it calls it if the string contains the key" do
36
+ assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => lambda { |*args| 'David' })
37
+ end
38
+
39
+ test "interpolation: given a lambda as a value it does not call it if the string does not contain the key" do
40
+ assert_nothing_raised { interpolate(:default => 'Hi!', :name => lambda { |*args| raise 'fail' }) }
41
+ end
42
+
43
+ test "interpolation: given values but missing a key it raises I18n::MissingInterpolationArgument" do
44
+ assert_raise(I18n::MissingInterpolationArgument) do
45
+ interpolate(:default => '%{foo}', :bar => 'bar')
46
+ end
47
+ end
48
+
49
+ test "interpolation: it does not raise I18n::MissingInterpolationArgument for escaped variables" do
50
+ assert_nothing_raised do
51
+ assert_equal 'Barr %{foo}', interpolate(:default => '%{bar} %%{foo}', :bar => 'Barr')
52
+ end
53
+ end
54
+
55
+ test "interpolation: it does not change the original, stored translation string" do
56
+ I18n.backend.store_translations(:en, :interpolate => 'Hi %{name}!')
57
+ assert_equal 'Hi David!', interpolate(:interpolate, :name => 'David')
58
+ assert_equal 'Hi Yehuda!', interpolate(:interpolate, :name => 'Yehuda')
59
+ end
60
+
61
+ test "interpolation: given an array interpolates each element" do
62
+ I18n.backend.store_translations(:en, :array_interpolate => ['Hi', 'Mr. %{name}', 'or sir %{name}'])
63
+ assert_equal ['Hi', 'Mr. Bartuz', 'or sir Bartuz'], interpolate(:array_interpolate, :name => 'Bartuz')
64
+ end
65
+
66
+ test "interpolation: given the translation is in utf-8 it still works" do
67
+ assert_equal 'Häi David!', interpolate(:default => 'Häi %{name}!', :name => 'David')
68
+ end
69
+
70
+ test "interpolation: given the value is in utf-8 it still works" do
71
+ assert_equal 'Hi ゆきひろ!', interpolate(:default => 'Hi %{name}!', :name => 'ゆきひろ')
72
+ end
73
+
74
+ test "interpolation: given the translation and the value are in utf-8 it still works" do
75
+ assert_equal 'こんにちは、ゆきひろさん!', interpolate(:default => 'こんにちは、%{name}さん!', :name => 'ゆきひろ')
76
+ end
77
+
78
+ if Object.const_defined?(:Encoding)
79
+ test "interpolation: given a euc-jp translation and a utf-8 value it raises Encoding::CompatibilityError" do
80
+ assert_raise(Encoding::CompatibilityError) do
81
+ interpolate(:default => euc_jp('こんにちは、%{name}さん!'), :name => 'ゆきひろ')
82
+ end
83
+ end
84
+
85
+ test "interpolation: given a utf-8 translation and a euc-jp value it raises Encoding::CompatibilityError" do
86
+ assert_raise(Encoding::CompatibilityError) do
87
+ interpolate(:default => 'こんにちは、%{name}さん!', :name => euc_jp('ゆきひろ'))
88
+ end
89
+ end
90
+
91
+ test "interpolation: ASCII strings in the backend should be encoded to UTF8 if interpolation options are in UTF8" do
92
+ I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.force_encoding("ASCII"))
93
+ result = I18n.t 'encoding', :who => "måmmå miå"
94
+ assert_equal Encoding::UTF_8, result.encoding
95
+ end
96
+
97
+ test "interpolation: UTF8 strings in the backend are still returned as UTF8 with ASCII interpolation" do
98
+ I18n.backend.store_translations 'en', 'encoding' => 'måmmå miå %{what}'
99
+ result = I18n.t 'encoding', :what => 'let me go'.force_encoding("ASCII")
100
+ assert_equal Encoding::UTF_8, result.encoding
101
+ end
102
+
103
+ test "interpolation: UTF8 strings in the backend are still returned as UTF8 even with numbers interpolation" do
104
+ I18n.backend.store_translations 'en', 'encoding' => '%{count} times: måmmå miå'
105
+ result = I18n.t 'encoding', :count => 3
106
+ assert_equal Encoding::UTF_8, result.encoding
107
+ end
108
+ end
109
+
110
+ test "interpolation: given a translations containing a reserved key it raises I18n::ReservedInterpolationKey" do
111
+ assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{exception_handler}') }
112
+ assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{default}') }
113
+ assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{separator}') }
114
+ assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{scope}') }
115
+ end
116
+
117
+ test "interpolation: deep interpolation for default string" do
118
+ assert_equal 'Hi %{name}!', interpolate(:default => 'Hi %{name}!', :deep_interpolation => true)
119
+ end
120
+
121
+ test "interpolation: deep interpolation for interpolated string" do
122
+ assert_equal 'Hi Ann!', interpolate(:default => 'Hi %{name}!', :name => 'Ann', :deep_interpolation => true)
123
+ end
124
+
125
+ test "interpolation: deep interpolation for Hash" do
126
+ people = { :people => { :ann => 'Ann is %{ann}', :john => 'John is %{john}' } }
127
+ interpolated_people = { :people => { :ann => 'Ann is good', :john => 'John is big' } }
128
+ assert_equal interpolated_people, interpolate(:default => people, :ann => 'good', :john => 'big', :deep_interpolation => true)
129
+ end
130
+
131
+ test "interpolation: deep interpolation for Array" do
132
+ people = { :people => ['Ann is %{ann}', 'John is %{john}'] }
133
+ interpolated_people = { :people => ['Ann is good', 'John is big'] }
134
+ assert_equal interpolated_people, interpolate(:default => people, :ann => 'good', :john => 'big', :deep_interpolation => true)
135
+ end
136
+
137
+ protected
138
+
139
+ def capture(stream)
140
+ begin
141
+ stream = stream.to_s
142
+ eval "$#{stream} = StringIO.new"
143
+ yield
144
+ result = eval("$#{stream}").string
145
+ ensure
146
+ eval("$#{stream} = #{stream.upcase}")
147
+ end
148
+
149
+ result
150
+ end
151
+
152
+ def euc_jp(string)
153
+ string.encode!(Encoding::EUC_JP)
154
+ end
155
+
156
+ def interpolate(*args)
157
+ options = args.last.is_a?(Hash) ? args.pop : {}
158
+ key = args.pop
159
+ I18n.backend.translate('en', key, options)
160
+ end
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ module I18n
4
+ module Tests
5
+ module Link
6
+ test "linked lookup: if a key resolves to a symbol it looks up the symbol" do
7
+ I18n.backend.store_translations 'en', {
8
+ :link => :linked,
9
+ :linked => 'linked'
10
+ }
11
+ assert_equal 'linked', I18n.backend.translate('en', :link)
12
+ end
13
+
14
+ test "linked lookup: if a key resolves to a dot-separated symbol it looks up the symbol" do
15
+ I18n.backend.store_translations 'en', {
16
+ :link => :"foo.linked",
17
+ :foo => { :linked => 'linked' }
18
+ }
19
+ assert_equal('linked', I18n.backend.translate('en', :link))
20
+ end
21
+
22
+ test "linked lookup: if a dot-separated key resolves to a symbol it looks up the symbol" do
23
+ I18n.backend.store_translations 'en', {
24
+ :foo => { :link => :linked },
25
+ :linked => 'linked'
26
+ }
27
+ assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
28
+ end
29
+
30
+ test "linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do
31
+ I18n.backend.store_translations 'en', {
32
+ :foo => { :link => :"bar.linked" },
33
+ :bar => { :linked => 'linked' }
34
+ }
35
+ assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
36
+ end
37
+
38
+ test "linked lookup: links always refer to the absolute key" do
39
+ I18n.backend.store_translations 'en', {
40
+ :foo => { :link => :linked, :linked => 'linked in foo' },
41
+ :linked => 'linked absolutely'
42
+ }
43
+ assert_equal 'linked absolutely', I18n.backend.translate('en', :link, :scope => :foo)
44
+ end
45
+
46
+ test "linked lookup: a link can resolve to a namespace in the middle of a dot-separated key" do
47
+ I18n.backend.store_translations 'en', {
48
+ :activemodel => { :errors => { :messages => { :blank => "can't be blank" } } },
49
+ :activerecord => { :errors => { :messages => :"activemodel.errors.messages" } }
50
+ }
51
+ assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
52
+ assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
53
+ end
54
+
55
+ test "linked lookup: a link can resolve with option :count" do
56
+ I18n.backend.store_translations 'en', {
57
+ :counter => :counted,
58
+ :counted => { :foo => { :one => "one", :other => "other" }, :bar => "bar" }
59
+ }
60
+ assert_equal "one", I18n.t(:'counter.foo', count: 1)
61
+ assert_equal "other", I18n.t(:'counter.foo', count: 2)
62
+ assert_equal "bar", I18n.t(:'counter.bar', count: 3)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,117 @@
1
+ # encoding: utf-8
2
+
3
+ module I18n
4
+ module Tests
5
+ module Localization
6
+ module Date
7
+ def setup
8
+ super
9
+ setup_date_translations
10
+ @date = ::Date.new(2008, 3, 1)
11
+ end
12
+
13
+ test "localize Date: given the short format it uses it" do
14
+ assert_equal '01. Mär', I18n.l(@date, :format => :short, :locale => :de)
15
+ end
16
+
17
+ test "localize Date: given the long format it uses it" do
18
+ assert_equal '01. März 2008', I18n.l(@date, :format => :long, :locale => :de)
19
+ end
20
+
21
+ test "localize Date: given the default format it uses it" do
22
+ assert_equal '01.03.2008', I18n.l(@date, :format => :default, :locale => :de)
23
+ end
24
+
25
+ test "localize Date: given a day name format it returns the correct day name" do
26
+ assert_equal 'Samstag', I18n.l(@date, :format => '%A', :locale => :de)
27
+ end
28
+
29
+ test "localize Date: given a uppercased day name format it returns the correct day name in upcase" do
30
+ assert_equal 'samstag'.upcase, I18n.l(@date, :format => '%^A', :locale => :de)
31
+ end
32
+
33
+ test "localize Date: given an abbreviated day name format it returns the correct abbreviated day name" do
34
+ assert_equal 'Sa', I18n.l(@date, :format => '%a', :locale => :de)
35
+ end
36
+
37
+ test "localize Date: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do
38
+ assert_equal 'sa'.upcase, I18n.l(@date, :format => '%^a', :locale => :de)
39
+ end
40
+
41
+ test "localize Date: given a month name format it returns the correct month name" do
42
+ assert_equal 'März', I18n.l(@date, :format => '%B', :locale => :de)
43
+ end
44
+
45
+ test "localize Date: given a uppercased month name format it returns the correct month name in upcase" do
46
+ assert_equal 'märz'.upcase, I18n.l(@date, :format => '%^B', :locale => :de)
47
+ end
48
+
49
+ test "localize Date: given an abbreviated month name format it returns the correct abbreviated month name" do
50
+ assert_equal 'Mär', I18n.l(@date, :format => '%b', :locale => :de)
51
+ end
52
+
53
+ test "localize Date: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do
54
+ assert_equal 'mär'.upcase, I18n.l(@date, :format => '%^b', :locale => :de)
55
+ end
56
+
57
+ test "localize Date: given a date format with the month name upcased it returns the correct value" do
58
+ assert_equal '1. FEBRUAR 2008', I18n.l(::Date.new(2008, 2, 1), :format => "%-d. %^B %Y", :locale => :de)
59
+ end
60
+
61
+ test "localize Date: given missing translations it returns the correct error message" do
62
+ assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@date, :format => '%b', :locale => :fr)
63
+ end
64
+
65
+ test "localize Date: given an unknown format it does not fail" do
66
+ assert_nothing_raised { I18n.l(@date, :format => '%x') }
67
+ end
68
+
69
+ test "localize Date: does not modify the options hash" do
70
+ options = { :format => '%b', :locale => :de }
71
+ assert_equal 'Mär', I18n.l(@date, **options)
72
+ assert_equal({ :format => '%b', :locale => :de }, options)
73
+ assert_nothing_raised { I18n.l(@date, **options.freeze) }
74
+ end
75
+
76
+ test "localize Date: given nil with default value it returns default" do
77
+ assert_equal 'default', I18n.l(nil, :default => 'default')
78
+ end
79
+
80
+ test "localize Date: given nil it raises I18n::ArgumentError" do
81
+ assert_raise(I18n::ArgumentError) { I18n.l(nil) }
82
+ end
83
+
84
+ test "localize Date: given a plain Object it raises I18n::ArgumentError" do
85
+ assert_raise(I18n::ArgumentError) { I18n.l(Object.new) }
86
+ end
87
+
88
+ test "localize Date: given a format is missing it raises I18n::MissingTranslationData" do
89
+ assert_raise(I18n::MissingTranslationData) { I18n.l(@date, :format => :missing) }
90
+ end
91
+
92
+ test "localize Date: it does not alter the format string" do
93
+ assert_equal '01. Februar 2009', I18n.l(::Date.parse('2009-02-01'), :format => :long, :locale => :de)
94
+ assert_equal '01. Oktober 2009', I18n.l(::Date.parse('2009-10-01'), :format => :long, :locale => :de)
95
+ end
96
+
97
+ protected
98
+
99
+ def setup_date_translations
100
+ I18n.backend.store_translations :de, {
101
+ :date => {
102
+ :formats => {
103
+ :default => "%d.%m.%Y",
104
+ :short => "%d. %b",
105
+ :long => "%d. %B %Y",
106
+ },
107
+ :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
108
+ :abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
109
+ :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
110
+ :abbr_month_names => %w(Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil)
111
+ }
112
+ }
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end