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,169 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
4
+ require "minitest_helper"
5
+
6
+ describe MIME::Types do
7
+ def mime_types
8
+ @mime_types ||= MIME::Types.new.tap { |mt|
9
+ mt.add MIME::Type.new(["text/plain", %w[txt]]),
10
+ MIME::Type.new(["image/jpeg", %w[jpg jpeg]]),
11
+ MIME::Type.new("application/x-wordperfect6.1"),
12
+ MIME::Type.new(
13
+ "content-type" => "application/x-www-form-urlencoded",
14
+ "registered" => true
15
+ ),
16
+ MIME::Type.new(["application/x-gzip", %w[gz]]),
17
+ MIME::Type.new(
18
+ "content-type" => "application/gzip",
19
+ "extensions" => "gz",
20
+ "registered" => true
21
+ )
22
+ }
23
+ end
24
+
25
+ describe "is enumerable" do
26
+ it "correctly uses an Enumerable method like #any?" do
27
+ assert(mime_types.any? { |type| type.content_type == "text/plain" })
28
+ end
29
+
30
+ it "implements each with no parameters to return an Enumerator" do
31
+ assert_kind_of Enumerator, mime_types.each
32
+ assert_kind_of Enumerator, mime_types.map
33
+ end
34
+
35
+ it "will create a lazy enumerator" do
36
+ assert_kind_of Enumerator::Lazy, mime_types.lazy
37
+ assert_kind_of Enumerator::Lazy, mime_types.map.lazy
38
+ end
39
+
40
+ it "is countable with an enumerator" do
41
+ assert_equal 6, mime_types.each.count
42
+ assert_equal 6, mime_types.lazy.count
43
+ end
44
+ end
45
+
46
+ describe "#[]" do
47
+ it "can be searched with a MIME::Type" do
48
+ text_plain = MIME::Type.new("text/plain")
49
+ assert_includes mime_types[text_plain], "text/plain"
50
+ assert_equal 1, mime_types[text_plain].size
51
+ end
52
+
53
+ it "can be searched with a regular expression" do
54
+ assert_includes mime_types[/plain$/], "text/plain"
55
+ assert_equal 1, mime_types[/plain$/].size
56
+ end
57
+
58
+ it "sorts by priority with multiple matches" do
59
+ assert_equal %w[application/gzip application/x-gzip], mime_types[/gzip$/]
60
+ assert_equal 2, mime_types[/gzip$/].size
61
+ end
62
+
63
+ it "can be searched with a string" do
64
+ assert_includes mime_types["text/plain"], "text/plain"
65
+ assert_equal 1, mime_types["text/plain"].size
66
+ end
67
+
68
+ it "can be searched with the complete flag" do
69
+ assert_empty mime_types[
70
+ "application/x-www-form-urlencoded",
71
+ complete: true
72
+ ]
73
+ assert_includes mime_types["text/plain", complete: true], "text/plain"
74
+ assert_equal 1, mime_types["text/plain", complete: true].size
75
+ end
76
+
77
+ it "can be searched with the registered flag" do
78
+ assert_empty mime_types["application/x-wordperfect6.1", registered: true]
79
+ refute_empty mime_types[
80
+ "application/x-www-form-urlencoded",
81
+ registered: true
82
+ ]
83
+ refute_empty mime_types[/gzip/, registered: true]
84
+ refute_equal mime_types[/gzip/], mime_types[/gzip/, registered: true]
85
+ end
86
+
87
+ it "properly returns an empty result on a regular expression miss" do
88
+ assert_empty mime_types[/^foo/]
89
+ assert_empty mime_types[/^foo/, registered: true]
90
+ assert_empty mime_types[/^foo/, complete: true]
91
+ end
92
+ end
93
+
94
+ describe "#add" do
95
+ let(:eruby) { MIME::Type.new("application/x-eruby") }
96
+ let(:jinja) { MIME::Type.new("application/jinja2") }
97
+
98
+ it "successfully adds a new type" do
99
+ mime_types.add(eruby)
100
+ assert_equal mime_types["application/x-eruby"], [eruby]
101
+ end
102
+
103
+ it "complains about adding a duplicate type" do
104
+ mime_types.add(eruby)
105
+ assert_output "", /is already registered as a variant/ do
106
+ mime_types.add(eruby)
107
+ end
108
+ assert_equal mime_types["application/x-eruby"], [eruby]
109
+ end
110
+
111
+ it "does not complain about adding a duplicate type when quiet" do
112
+ mime_types.add(eruby)
113
+ assert_output "", "" do
114
+ mime_types.add(eruby, :silent)
115
+ end
116
+ assert_equal mime_types["application/x-eruby"], [eruby]
117
+ end
118
+
119
+ it "successfully adds from an array" do
120
+ mime_types.add([eruby, jinja])
121
+ assert_equal mime_types["application/x-eruby"], [eruby]
122
+ assert_equal mime_types["application/jinja2"], [jinja]
123
+ end
124
+
125
+ it "successfully adds from another MIME::Types" do
126
+ mt = MIME::Types.new
127
+ mt.add(mime_types)
128
+ assert_equal mime_types.count, mt.count
129
+
130
+ mime_types.each do |type|
131
+ assert_equal mt[type.content_type], [type]
132
+ end
133
+ end
134
+ end
135
+
136
+ describe "#type_for" do
137
+ it "finds all types for a given extension" do
138
+ assert_equal %w[application/gzip application/x-gzip],
139
+ mime_types.type_for("gz")
140
+ end
141
+
142
+ it "separates the extension from filenames" do
143
+ assert_equal %w[image/jpeg], mime_types.of(["foo.jpeg", "bar.jpeg"])
144
+ end
145
+
146
+ it "finds multiple extensions" do
147
+ assert_equal %w[image/jpeg text/plain],
148
+ mime_types.type_for(%w[foo.txt foo.jpeg])
149
+ end
150
+
151
+ it "does not find unknown extensions" do
152
+ keys = mime_types.instance_variable_get(:@extension_index).keys
153
+ assert_empty mime_types.type_for("zzz")
154
+ assert_equal keys, mime_types.instance_variable_get(:@extension_index).keys
155
+ end
156
+
157
+ it "modifying type extensions causes reindexing" do
158
+ plain_text = mime_types["text/plain"].first
159
+ plain_text.add_extensions("xtxt")
160
+ assert_includes mime_types.type_for("xtxt"), "text/plain"
161
+ end
162
+ end
163
+
164
+ describe "#count" do
165
+ it "can count the number of types inside" do
166
+ assert_equal 6, mime_types.count
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
4
+ require "minitest_helper"
5
+
6
+ MUTEX = Mutex.new
7
+
8
+ describe MIME::Types::Cache do
9
+ include Minitest::Hooks
10
+
11
+ def around
12
+ require "fileutils"
13
+
14
+ MUTEX.synchronize do
15
+ @cache_file = File.expand_path("../cache.tst", __FILE__)
16
+ ENV["RUBY_MIME_TYPES_CACHE"] = @cache_file
17
+ clear_cache_file
18
+
19
+ super
20
+
21
+ clear_cache_file
22
+ ENV.delete("RUBY_MIME_TYPES_CACHE")
23
+ end
24
+ end
25
+
26
+ def reset_mime_types
27
+ MIME::Types.instance_variable_set(:@__types__, nil)
28
+ MIME::Types.send(:load_default_mime_types)
29
+ end
30
+
31
+ def clear_cache_file
32
+ FileUtils.rm @cache_file if File.exist? @cache_file
33
+ end
34
+
35
+ describe ".load" do
36
+ it "does not use cache when RUBY_MIME_TYPES_CACHE is unset" do
37
+ ENV.delete("RUBY_MIME_TYPES_CACHE")
38
+ assert_nil MIME::Types::Cache.load
39
+ end
40
+
41
+ it "does not use cache when missing" do
42
+ assert_nil MIME::Types::Cache.load
43
+ end
44
+
45
+ it "registers the data to be updated by #add_extensions" do
46
+ MIME::Types::Cache.save
47
+ reset_mime_types
48
+ assert_equal([], MIME::Types.type_for("foo.additional"))
49
+ html = MIME::Types["text/html"][0]
50
+ html.add_extensions("additional")
51
+ assert_equal([html], MIME::Types.type_for("foo.additional"))
52
+ end
53
+
54
+ it "outputs an error when there is an invalid version" do
55
+ v = MIME::Types::Data::VERSION
56
+ MIME::Types::Data.send(:remove_const, :VERSION)
57
+ MIME::Types::Data.const_set(:VERSION, "0.0")
58
+ MIME::Types::Cache.save
59
+ MIME::Types::Data.send(:remove_const, :VERSION)
60
+ MIME::Types::Data.const_set(:VERSION, v)
61
+ MIME::Types.instance_variable_set(:@__types__, nil)
62
+ assert_output "", /MIME::Types cache: invalid version/ do
63
+ MIME::Types["text/html"]
64
+ end
65
+ end
66
+
67
+ it "outputs an error when there is a marshal file incompatibility" do
68
+ MIME::Types::Cache.save
69
+ data = File.binread(@cache_file).reverse
70
+ File.open(@cache_file, "wb") { |f| f.write(data) }
71
+ MIME::Types.instance_variable_set(:@__types__, nil)
72
+ assert_output "", /incompatible marshal file format/ do
73
+ MIME::Types["text/html"]
74
+ end
75
+ end
76
+ end
77
+
78
+ describe ".save" do
79
+ it "does not create cache when RUBY_MIME_TYPES_CACHE is unset" do
80
+ ENV.delete("RUBY_MIME_TYPES_CACHE")
81
+ assert_nil MIME::Types::Cache.save
82
+ end
83
+
84
+ it "creates the cache " do
85
+ assert_equal(false, File.exist?(@cache_file))
86
+ MIME::Types::Cache.save
87
+ assert_equal(true, File.exist?(@cache_file))
88
+ end
89
+
90
+ it "uses the cache" do
91
+ MIME::Types["text/html"].first.add_extensions("hex")
92
+ MIME::Types::Cache.save
93
+ MIME::Types.instance_variable_set(:@__types__, nil)
94
+
95
+ assert_includes MIME::Types["text/html"].first.extensions, "hex"
96
+
97
+ reset_mime_types
98
+ end
99
+ end
100
+ end
101
+
102
+ describe MIME::Types::Container do
103
+ it "marshals and unmarshals correctly" do
104
+ container = MIME::Types::Container.new
105
+ container.add("xyz", "abc")
106
+
107
+ # default proc should return Set[]
108
+ assert_equal(Set[], container["abc"])
109
+ assert_equal(Set["abc"], container["xyz"])
110
+
111
+ marshalled = Marshal.dump(container)
112
+ loaded_container = Marshal.load(marshalled)
113
+
114
+ # default proc should still return Set[]
115
+ assert_equal(Set[], loaded_container["abc"])
116
+ assert_equal(Set["abc"], container["xyz"])
117
+ end
118
+ end
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
4
+ require "minitest_helper"
5
+
6
+ describe MIME::Types, "registry" do
7
+ def setup
8
+ MIME::Types.send(:load_default_mime_types)
9
+ end
10
+
11
+ describe "is enumerable" do
12
+ it "correctly uses an Enumerable method like #any?" do
13
+ assert(MIME::Types.any? { |type| type.content_type == "text/plain" })
14
+ end
15
+
16
+ it "implements each with no parameters to return an Enumerator" do
17
+ assert_kind_of Enumerator, MIME::Types.each
18
+ assert_kind_of Enumerator, MIME::Types.map
19
+ end
20
+
21
+ it "will create a lazy enumerator" do
22
+ assert_kind_of Enumerator::Lazy, MIME::Types.lazy
23
+ assert_kind_of Enumerator::Lazy, MIME::Types.map.lazy
24
+ end
25
+
26
+ it "is countable with an enumerator" do
27
+ assert MIME::Types.each.count > 999
28
+ assert MIME::Types.lazy.count > 999
29
+ end
30
+ end
31
+
32
+ describe ".[]" do
33
+ it "can be searched with a MIME::Type" do
34
+ text_plain = MIME::Type.new("text/plain")
35
+ assert_includes MIME::Types[text_plain], "text/plain"
36
+ assert_equal 1, MIME::Types[text_plain].size
37
+ end
38
+
39
+ it "can be searched with a regular expression" do
40
+ assert_includes MIME::Types[/plain$/], "text/plain"
41
+ assert_equal 1, MIME::Types[/plain$/].size
42
+ end
43
+
44
+ it "sorts by priority with multiple matches" do
45
+ types = MIME::Types[/gzip$/].select { |t|
46
+ %w[application/gzip application/x-gzip multipart/x-gzip].include?(t)
47
+ }
48
+ # This is this way because of a new type ending with gzip that only
49
+ # appears in some data files.
50
+ assert_equal %w[application/gzip application/x-gzip multipart/x-gzip], types
51
+ assert_equal 3, types.size
52
+ end
53
+
54
+ it "can be searched with a string" do
55
+ assert_includes MIME::Types["text/plain"], "text/plain"
56
+ assert_equal 1, MIME::Types["text/plain"].size
57
+ end
58
+
59
+ it "can be searched with the complete flag" do
60
+ assert_empty MIME::Types[
61
+ "application/x-www-form-urlencoded",
62
+ complete: true
63
+ ]
64
+ assert_includes MIME::Types["text/plain", complete: true], "text/plain"
65
+ assert_equal 1, MIME::Types["text/plain", complete: true].size
66
+ end
67
+
68
+ it "can be searched with the registered flag" do
69
+ assert_empty MIME::Types["application/x-wordperfect6.1", registered: true]
70
+ refute_empty MIME::Types[
71
+ "application/x-www-form-urlencoded",
72
+ registered: true
73
+ ]
74
+ refute_empty MIME::Types[/gzip/, registered: true]
75
+ refute_equal MIME::Types[/gzip/], MIME::Types[/gzip/, registered: true]
76
+ end
77
+ end
78
+
79
+ describe ".type_for" do
80
+ it "finds all types for a given extension" do
81
+ assert_equal %w[application/gzip application/x-gzip],
82
+ MIME::Types.type_for("gz")
83
+ end
84
+
85
+ it "separates the extension from filenames" do
86
+ assert_equal %w[image/jpeg], MIME::Types.of(["foo.jpeg", "bar.jpeg"])
87
+ end
88
+
89
+ it "finds multiple extensions" do
90
+ assert_equal %w[image/jpeg text/plain],
91
+ MIME::Types.type_for(%w[foo.txt foo.jpeg])
92
+ end
93
+
94
+ it "does not find unknown extensions" do
95
+ assert_empty MIME::Types.type_for("zzz")
96
+ end
97
+
98
+ it "modifying type extensions causes reindexing" do
99
+ plain_text = MIME::Types["text/plain"].first
100
+ plain_text.add_extensions("xtxt")
101
+ assert_includes MIME::Types.type_for("xtxt"), "text/plain"
102
+ end
103
+ end
104
+
105
+ describe ".count" do
106
+ it "can count the number of types inside" do
107
+ assert MIME::Types.count > 999
108
+ end
109
+ end
110
+
111
+ describe ".add" do
112
+ def setup
113
+ MIME::Types.instance_variable_set(:@__types__, nil)
114
+ MIME::Types.send(:load_default_mime_types)
115
+ end
116
+
117
+ let(:eruby) { MIME::Type.new("application/x-eruby") }
118
+ let(:jinja) { MIME::Type.new("application/jinja2") }
119
+
120
+ it "successfully adds a new type" do
121
+ MIME::Types.add(eruby)
122
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
123
+ end
124
+
125
+ it "complains about adding a duplicate type" do
126
+ MIME::Types.add(eruby)
127
+ assert_output "", /is already registered as a variant/ do
128
+ MIME::Types.add(eruby)
129
+ end
130
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
131
+ end
132
+
133
+ it "does not complain about adding a duplicate type when quiet" do
134
+ MIME::Types.add(eruby)
135
+ assert_silent do
136
+ MIME::Types.add(eruby, :silent)
137
+ end
138
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
139
+ end
140
+
141
+ it "successfully adds from an array" do
142
+ MIME::Types.add([eruby, jinja])
143
+ assert_equal MIME::Types["application/x-eruby"], [eruby]
144
+ assert_equal MIME::Types["application/jinja2"], [jinja]
145
+ end
146
+
147
+ it "successfully adds from another MIME::Types" do
148
+ old_count = MIME::Types.count
149
+
150
+ mt = MIME::Types.new
151
+ mt.add(eruby)
152
+
153
+ MIME::Types.add(mt)
154
+ assert_equal old_count + 1, MIME::Types.count
155
+
156
+ assert_equal MIME::Types[eruby.content_type], [eruby]
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
4
+ require "minitest_helper"
5
+
6
+ describe MIME::Types, "lazy loading" do
7
+ def setup
8
+ ENV["RUBY_MIME_TYPES_LAZY_LOAD"] = "true"
9
+ end
10
+
11
+ def teardown
12
+ reset_mime_types
13
+ ENV.delete("RUBY_MIME_TYPES_LAZY_LOAD")
14
+ end
15
+
16
+ def reset_mime_types
17
+ MIME::Types.instance_variable_set(:@__types__, nil)
18
+ MIME::Types.send(:load_default_mime_types)
19
+ end
20
+
21
+ describe ".lazy_load?" do
22
+ it "is true when RUBY_MIME_TYPES_LAZY_LOAD is set" do
23
+ assert_output "", /RUBY_MIME_TYPES_LAZY_LOAD/ do
24
+ assert_equal true, MIME::Types.send(:lazy_load?)
25
+ end
26
+ end
27
+
28
+ it "is nil when RUBY_MIME_TYPES_LAZY_LOAD is unset" do
29
+ ENV["RUBY_MIME_TYPES_LAZY_LOAD"] = nil
30
+ assert_output "", "" do
31
+ assert_nil MIME::Types.send(:lazy_load?)
32
+ end
33
+ end
34
+
35
+ it "is false when RUBY_MIME_TYPES_LAZY_LOAD is false" do
36
+ ENV["RUBY_MIME_TYPES_LAZY_LOAD"] = "false"
37
+ assert_output "", /RUBY_MIME_TYPES_LAZY_LOAD/ do
38
+ assert_equal false, MIME::Types.send(:lazy_load?)
39
+ end
40
+ end
41
+ end
42
+
43
+ it "loads lazily when RUBY_MIME_TYPES_LAZY_LOAD is set" do
44
+ MIME::Types.instance_variable_set(:@__types__, nil)
45
+ assert_nil MIME::Types.instance_variable_get(:@__types__)
46
+ refute_nil MIME::Types["text/html"].first
47
+ refute_nil MIME::Types.instance_variable_get(:@__types__)
48
+ end
49
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
4
+ require "minitest_helper"
5
+
6
+ describe MIME::Types::Loader do
7
+ def setup
8
+ @path = File.expand_path("../fixture", __FILE__)
9
+ @loader = MIME::Types::Loader.new(@path)
10
+ @bad_path = File.expand_path("../bad-fixtures", __FILE__)
11
+ end
12
+
13
+ def assert_correctly_loaded(types)
14
+ assert_includes(types, "application/1d-interleaved-parityfec")
15
+ assert_equal(%w[webm], types["audio/webm"].first.extensions)
16
+ refute(types["audio/webm"].first.registered?)
17
+
18
+ assert_equal("Fixes a bug with IE6 and progressive JPEGs",
19
+ types["image/pjpeg"].first.docs)
20
+
21
+ assert(types["audio/vnd.qcelp"].first.obsolete?)
22
+ assert_equal("audio/QCELP", types["audio/vnd.qcelp"].first.use_instead)
23
+ end
24
+
25
+ it "loads YAML files correctly" do
26
+ assert_correctly_loaded @loader.load_yaml
27
+ end
28
+
29
+ it "loads JSON files correctly" do
30
+ assert_correctly_loaded @loader.load_json
31
+ end
32
+ end
@@ -0,0 +1,75 @@
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, gender identity and expression, level of
9
+ experience, nationality, personal appearance, race, religion, or sexual identity
10
+ 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 reject
41
+ comments, commits, code, wiki edits, issues, and other contributions that are
42
+ not aligned to this Code of Conduct, or to ban temporarily or permanently any
43
+ contributor for other behaviors that they deem inappropriate, threatening,
44
+ 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
62
+ incident. Further details of specific enforcement policies may be posted
63
+ separately.
64
+
65
+ Project maintainers who do not follow or enforce the Code of Conduct in good
66
+ faith may face temporary or permanent repercussions as determined by other
67
+ members of the project's leadership.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72
+ available at [http://contributor-covenant.org/version/1/4][version]
73
+
74
+ [homepage]: http://contributor-covenant.org
75
+ [version]: http://contributor-covenant.org/version/1/4/