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,233 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ module MIME
5
+ ##
6
+ class Types
7
+ end
8
+ end
9
+
10
+ require "mime/type"
11
+
12
+ # MIME::Types is a registry of MIME types. It is both a class (created with
13
+ # MIME::Types.new) and a default registry (loaded automatically or through
14
+ # interactions with MIME::Types.[] and MIME::Types.type_for).
15
+ #
16
+ # == The Default mime-types Registry
17
+ #
18
+ # The default mime-types registry is loaded automatically when the library
19
+ # is required (<tt>require 'mime/types'</tt>), but it may be lazily loaded
20
+ # (loaded on first use) with the use of the environment variable
21
+ # +RUBY_MIME_TYPES_LAZY_LOAD+ having any value other than +false+. The
22
+ # initial startup is about 14× faster (~10 ms vs ~140 ms), but the
23
+ # registry will be loaded at some point in the future.
24
+ #
25
+ # The default mime-types registry can also be loaded from a Marshal cache
26
+ # file specific to the version of MIME::Types being loaded. This will be
27
+ # handled automatically with the use of a file referred to in the
28
+ # environment variable +RUBY_MIME_TYPES_CACHE+. MIME::Types will attempt to
29
+ # load the registry from this cache file (MIME::Type::Cache.load); if it
30
+ # cannot be loaded (because the file does not exist, there is an error, or
31
+ # the data is for a different version of mime-types), the default registry
32
+ # will be loaded from the normal JSON version and then the cache file will
33
+ # be *written* to the location indicated by +RUBY_MIME_TYPES_CACHE+. Cache
34
+ # file loads just over 4½× faster (~30 ms vs ~140 ms).
35
+ # loads.
36
+ #
37
+ # Notes:
38
+ # * The loading of the default registry is *not* atomic; when using a
39
+ # multi-threaded environment, it is recommended that lazy loading is not
40
+ # used and mime-types is loaded as early as possible.
41
+ # * Cache files should be specified per application in a multiprocess
42
+ # environment and should be initialized during deployment or before
43
+ # forking to minimize the chance that the multiple processes will be
44
+ # trying to write to the same cache file at the same time, or that two
45
+ # applications that are on different versions of mime-types would be
46
+ # thrashing the cache.
47
+ # * Unless cache files are preinitialized, the application using the
48
+ # mime-types cache file must have read/write permission to the cache file.
49
+ #
50
+ # == Usage
51
+ # require 'mime/types'
52
+ #
53
+ # plaintext = MIME::Types['text/plain']
54
+ # print plaintext.media_type # => 'text'
55
+ # print plaintext.sub_type # => 'plain'
56
+ #
57
+ # puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
58
+ #
59
+ # puts plaintext.encoding # => 8bit
60
+ # puts plaintext.binary? # => false
61
+ # puts plaintext.ascii? # => true
62
+ # puts plaintext.obsolete? # => false
63
+ # puts plaintext.registered? # => true
64
+ # puts plaintext.provisional? # => false
65
+ # puts plaintext == 'text/plain' # => true
66
+ # puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
67
+ #
68
+ class MIME::Types
69
+ # The release version of Ruby MIME::Types
70
+ VERSION = MIME::Type::VERSION
71
+
72
+ include Enumerable
73
+
74
+ # Creates a new MIME::Types registry.
75
+ def initialize
76
+ @type_variants = Container.new
77
+ @extension_index = Container.new
78
+ end
79
+
80
+ # Returns the number of known type variants.
81
+ def count
82
+ @type_variants.values.inject(0) { |a, e| a + e.size }
83
+ end
84
+
85
+ def inspect # :nodoc:
86
+ "#<#{self.class}: #{count} variants, #{@extension_index.count} extensions>"
87
+ end
88
+
89
+ # Iterates through the type variants.
90
+ def each
91
+ if block_given?
92
+ @type_variants.each_value { |tv| tv.each { |t| yield t } }
93
+ else
94
+ enum_for(:each)
95
+ end
96
+ end
97
+
98
+ @__types__ = nil
99
+
100
+ # Returns a list of MIME::Type objects, which may be empty. The optional
101
+ # flag parameters are <tt>:complete</tt> (finds only complete MIME::Type
102
+ # objects) and <tt>:registered</tt> (finds only MIME::Types that are
103
+ # registered). It is possible for multiple matches to be returned for
104
+ # either type (in the example below, 'text/plain' returns two values --
105
+ # one for the general case, and one for VMS systems).
106
+ #
107
+ # puts "\nMIME::Types['text/plain']"
108
+ # MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
109
+ #
110
+ # puts "\nMIME::Types[/^image/, complete: true]"
111
+ # MIME::Types[/^image/, :complete => true].each do |t|
112
+ # puts t.to_a.join(", ")
113
+ # end
114
+ #
115
+ # If multiple type definitions are returned, returns them sorted as
116
+ # follows:
117
+ # 1. Complete definitions sort before incomplete ones;
118
+ # 2. IANA-registered definitions sort before LTSW-recorded
119
+ # definitions.
120
+ # 3. Current definitions sort before obsolete ones;
121
+ # 4. Obsolete definitions with use-instead clauses sort before those
122
+ # without;
123
+ # 5. Obsolete definitions use-instead clauses are compared.
124
+ # 6. Sort on name.
125
+ def [](type_id, complete: false, registered: false)
126
+ matches =
127
+ case type_id
128
+ when MIME::Type
129
+ @type_variants[type_id.simplified]
130
+ when Regexp
131
+ match(type_id)
132
+ else
133
+ @type_variants[MIME::Type.simplified(type_id)]
134
+ end
135
+
136
+ prune_matches(matches, complete, registered).sort { |a, b|
137
+ a.priority_compare(b)
138
+ }
139
+ end
140
+
141
+ # Return the list of MIME::Types which belongs to the file based on its
142
+ # filename extension. If there is no extension, the filename will be used
143
+ # as the matching criteria on its own.
144
+ #
145
+ # This will always return a merged, flatten, priority sorted, unique array.
146
+ #
147
+ # puts MIME::Types.type_for('citydesk.xml')
148
+ # => [application/xml, text/xml]
149
+ # puts MIME::Types.type_for('citydesk.gif')
150
+ # => [image/gif]
151
+ # puts MIME::Types.type_for(%w(citydesk.xml citydesk.gif))
152
+ # => [application/xml, image/gif, text/xml]
153
+ def type_for(filename)
154
+ Array(filename).flat_map { |fn|
155
+ @extension_index[fn.chomp.downcase[/\.?([^.]*?)$/, 1]]
156
+ }.compact.inject(Set.new, :+).sort { |a, b|
157
+ a.priority_compare(b)
158
+ }
159
+ end
160
+ alias_method :of, :type_for
161
+
162
+ # Add one or more MIME::Type objects to the set of known types. If the
163
+ # type is already known, a warning will be displayed.
164
+ #
165
+ # The last parameter may be the value <tt>:silent</tt> or +true+ which
166
+ # will suppress duplicate MIME type warnings.
167
+ def add(*types)
168
+ quiet = ((types.last == :silent) || (types.last == true))
169
+
170
+ types.each do |mime_type|
171
+ case mime_type
172
+ when true, false, nil, Symbol
173
+ nil
174
+ when MIME::Types
175
+ variants = mime_type.instance_variable_get(:@type_variants)
176
+ add(*variants.values.inject(Set.new, :+).to_a, quiet)
177
+ when Array
178
+ add(*mime_type, quiet)
179
+ else
180
+ add_type(mime_type, quiet)
181
+ end
182
+ end
183
+ end
184
+
185
+ # Add a single MIME::Type object to the set of known types. If the +type+ is
186
+ # already known, a warning will be displayed. The +quiet+ parameter may be a
187
+ # truthy value to suppress that warning.
188
+ def add_type(type, quiet = false)
189
+ if !quiet && @type_variants[type.simplified].include?(type)
190
+ MIME::Types.logger.warn <<-WARNING.chomp.strip
191
+ Type #{type} is already registered as a variant of #{type.simplified}.
192
+ WARNING
193
+ end
194
+
195
+ add_type_variant!(type)
196
+ index_extensions!(type)
197
+ end
198
+
199
+ private
200
+
201
+ def add_type_variant!(mime_type)
202
+ @type_variants.add(mime_type.simplified, mime_type)
203
+ end
204
+
205
+ def reindex_extensions!(mime_type)
206
+ return unless @type_variants[mime_type.simplified].include?(mime_type)
207
+
208
+ index_extensions!(mime_type)
209
+ end
210
+
211
+ def index_extensions!(mime_type)
212
+ mime_type.extensions.each { |ext| @extension_index.add(ext, mime_type) }
213
+ end
214
+
215
+ def prune_matches(matches, complete, registered)
216
+ matches.delete_if { |e| !e.complete? } if complete
217
+ matches.delete_if { |e| !e.registered? } if registered
218
+ matches
219
+ end
220
+
221
+ def match(pattern)
222
+ @type_variants.select { |k, _|
223
+ k =~ pattern
224
+ }.values.inject(Set.new, :+)
225
+ end
226
+ end
227
+
228
+ require "mime/types/cache"
229
+ require "mime/types/container"
230
+ require "mime/types/loader"
231
+ require "mime/types/logger"
232
+ require "mime/types/_columnar"
233
+ require "mime/types/registry"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/types"
@@ -0,0 +1,9 @@
1
+ !application.smil @smi,smil :8bit 'IANA,RFC4536 =use-instead:application/smil+xml
2
+ !audio/vnd.qcelp @qcp 'IANA,RFC3625 =use-instead:audio/QCELP
3
+ *!image/bmp @bmp =use-instead:image/x-bmp
4
+ *application/acad 'LTSW
5
+ *audio/webm @webm '{WebM=http://www.webmproject.org/code/specs/container/}
6
+ *image/pjpeg :base64 =Fixes a bug with IE6 and progressive JPEGs
7
+ application/1d-interleaved-parityfec 'IANA,RFC6015
8
+ audio/1d-interleaved-parityfec 'IANA,RFC6015
9
+ mac:application/x-apple-diskimage @dmg
@@ -0,0 +1 @@
1
+ [{"content-type":"application/smil","encoding":"8bit","extensions":["smi","smil"],"obsolete":true,"use-instead":"application/smil+xml","registered":true},{"content-type":"audio/vnd.qcelp","encoding":"base64","extensions":["qcp"],"obsolete":true,"use-instead":"audio/QCELP","registered":true},{"content-type":"image/bmp","encoding":"base64","extensions":["bmp"],"obsolete":true,"use-instead":"image/x-bmp","registered":false},{"content-type":"application/acad","encoding":"base64","registered":false},{"content-type":"audio/webm","encoding":"base64","extensions":["webm"],"registered":false},{"content-type":"image/pjpeg","docs":"Fixes a bug with IE6 and progressive JPEGs","encoding":"base64","registered":false},{"content-type":"application/1d-interleaved-parityfec","encoding":"base64","registered":true},{"content-type":"audio/1d-interleaved-parityfec","encoding":"base64","registered":true},{"content-type":"application/x-apple-diskimage","encoding":"base64","extensions":["dmg"],"registered":false}]
@@ -0,0 +1,9 @@
1
+ !application/smil @smi,smil :8bit 'IANA,RFC4536 =use-instead:application/smil+xml
2
+ !audio/vnd.qcelp @qcp 'IANA,RFC3625 =use-instead:audio/QCELP
3
+ *!image/bmp @bmp =use-instead:image/x-bmp
4
+ *application/acad 'LTSW
5
+ *audio/webm @webm '{WebM=http://www.webmproject.org/code/specs/container/}
6
+ *image/pjpeg :base64 =Fixes a bug with IE6 and progressive JPEGs
7
+ application/1d-interleaved-parityfec 'IANA,RFC6015
8
+ audio/1d-interleaved-parityfec 'IANA,RFC6015
9
+ mac:application/x-apple-diskimage @dmg
@@ -0,0 +1,55 @@
1
+ ---
2
+ - !ruby/object:MIME::Type
3
+ content-type: application/smil
4
+ encoding: 8bit
5
+ extensions:
6
+ - smi
7
+ - smil
8
+ obsolete: true
9
+ use-instead: application/smil+xml
10
+ registered: true
11
+ - !ruby/object:MIME::Type
12
+ content-type: audio/vnd.qcelp
13
+ encoding: base64
14
+ extensions:
15
+ - qcp
16
+ obsolete: true
17
+ use-instead: audio/QCELP
18
+ registered: true
19
+ - !ruby/object:MIME::Type
20
+ content-type: image/bmp
21
+ encoding: base64
22
+ extensions:
23
+ - bmp
24
+ obsolete: true
25
+ use-instead: image/x-bmp
26
+ registered: false
27
+ - !ruby/object:MIME::Type
28
+ content-type: application/acad
29
+ encoding: base64
30
+ registered: false
31
+ - !ruby/object:MIME::Type
32
+ content-type: audio/webm
33
+ encoding: base64
34
+ extensions:
35
+ - webm
36
+ registered: false
37
+ - !ruby/object:MIME::Type
38
+ content-type: image/pjpeg
39
+ docs: Fixes a bug with IE6 and progressive JPEGs
40
+ encoding: base64
41
+ registered: false
42
+ - !ruby/object:MIME::Type
43
+ content-type: application/1d-interleaved-parityfec
44
+ encoding: base64
45
+ registered: true
46
+ - !ruby/object:MIME::Type
47
+ content-type: audio/1d-interleaved-parityfec
48
+ encoding: base64
49
+ registered: true
50
+ - !ruby/object:MIME::Type
51
+ content-type: application/x-apple-diskimage
52
+ encoding: base64
53
+ extensions:
54
+ - dmg
55
+ registered: false
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mime/type"
4
+ require "fileutils"
5
+
6
+ gem "minitest"
7
+ require "minitest/focus"
8
+ require "minitest-bonus-assertions"
9
+ require "minitest/hooks"
10
+
11
+ ENV["RUBY_MIME_TYPES_LAZY_LOAD"] = "yes"