vagrant-unbundled 2.2.18.0 → 2.2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +6 -6
- data/contrib/zsh/generate_zsh_completion.rb +2 -2
- data/lib/vagrant/errors.rb +8 -0
- data/plugins/commands/upload/command.rb +1 -1
- data/plugins/guests/atomic/guest.rb +1 -1
- data/plugins/guests/coreos/cap/configure_networks.rb +65 -0
- data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +6 -3
- data/plugins/guests/suse/cap/halt.rb +5 -1
- data/plugins/guests/windows/cap/rsync.rb +5 -1
- data/plugins/hosts/darwin/cap/path.rb +4 -0
- data/plugins/hosts/darwin/cap/version.rb +23 -0
- data/plugins/hosts/darwin/plugin.rb +5 -0
- data/plugins/hosts/windows/cap/ssh.rb +1 -1
- data/plugins/providers/virtualbox/action/network.rb +39 -2
- data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +5 -3
- data/plugins/provisioners/chef/cap/linux/chef_installed.rb +5 -3
- data/plugins/provisioners/chef/cap/omnios/chef_installed.rb +7 -5
- data/plugins/provisioners/chef/cap/windows/chef_installed.rb +3 -2
- data/templates/locales/en.yml +25 -0
- data/vagrant.gemspec +1 -1
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTING.md +23 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTORS.md +140 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/README.md +492 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/data/cacert.pem +3232 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/excon.gemspec +45 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/connection.rb +599 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/constants.rb +172 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/error.rb +229 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/extensions/uri.rb +34 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/headers.rb +85 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/base.rb +31 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/capture_cookies.rb +32 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/decompress.rb +44 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/escape_path.rb +12 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/expects.rb +25 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/idempotent.rb +57 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/instrumentor.rb +49 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/mock.rb +61 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/redirect_follower.rb +87 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/response_parser.rb +16 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/pretty_printer.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/response.rb +234 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/socket.rb +297 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/ssl_socket.rb +194 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/exec.rb +26 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/puma.rb +23 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/unicorn.rb +40 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/webrick.rb +26 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/server.rb +106 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/unix_socket.rb +42 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/utils.rb +143 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/version.rb +4 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon.rb +255 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/README.md +122 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/base.rb +289 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache.rb +113 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache_file.rb +36 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cascade.rb +56 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/chain.rb +130 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/fallbacks.rb +97 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/flatten.rb +118 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/gettext.rb +85 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/interpolation_compiler.rb +123 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/key_value.rb +206 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/memoize.rb +54 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/metadata.rb +71 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/pluralization.rb +55 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/simple.rb +108 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/transliterator.rb +108 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/config.rb +165 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/core_ext/hash.rb +59 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/exceptions.rb +111 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/helpers.rb +75 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/po_parser.rb +329 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext.rb +28 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/interpolate/ruby.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/fallbacks.rb +99 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/parents.rb +24 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/rfc4646.rb +74 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/simple.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag.rb +28 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale.rb +8 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/middleware.rb +17 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/basics.rb +60 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/defaults.rb +52 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/interpolation.rb +163 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/link.rb +66 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date.rb +117 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date_time.rb +103 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/procs.rb +117 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/time.rb +103 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization.rb +19 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/lookup.rb +81 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/pluralization.rb +35 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/procs.rb +60 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests.rb +14 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/version.rb +5 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n.rb +415 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Code-of-Conduct.md +73 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Contributing.md +132 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/History.md +269 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Licence.md +25 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Manifest.txt +31 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/README.rdoc +194 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Rakefile +270 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb +57 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type.rb +634 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/_columnar.rb +137 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/cache.rb +58 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/columnar.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/container.rb +96 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/deprecations.rb +36 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/full.rb +19 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/loader.rb +159 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/logger.rb +37 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/registry.rb +90 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types.rb +233 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime-types.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/bad-fixtures/malformed +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/json.json +1 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/old-data +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/yaml.yaml +55 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/minitest_helper.rb +11 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_type.rb +621 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types.rb +169 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_cache.rb +118 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_class.rb +159 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_lazy.rb +49 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_loader.rb +32 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Code-of-Conduct.md +75 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Contributing.md +241 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/History.md +494 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Licence.md +24 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Manifest.txt +34 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/README.md +73 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Rakefile +155 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/content_type_mime.db +878 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/ext_mime.db +1198 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime-types.json +1 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.content_type.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.docs.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.encoding.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.flags.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.friendly.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.pext.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.use_instead.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.xrefs.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime/types/data.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime-types-data.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/application.yaml +17254 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/audio.yaml +1716 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/chemical.yaml +71 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/conference.yaml +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/drawing.yaml +15 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/font.yaml +65 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/image.yaml +1251 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/message.yaml +200 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/model.yaml +390 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/multipart.yaml +179 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/provisional-standard-types.yaml +129 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/text.yaml +1166 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/video.yaml +1121 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/world.yaml +8 -0
- data/vendor/bundle/ruby/3.0.0/specifications/excon-0.89.0.gemspec +58 -0
- data/vendor/bundle/ruby/3.0.0/specifications/i18n-1.8.11.gemspec +32 -0
- data/vendor/bundle/ruby/3.0.0/specifications/mime-types-3.4.1.gemspec +63 -0
- data/vendor/bundle/ruby/3.0.0/specifications/mime-types-data-3.2021.1115.gemspec +54 -0
- data/version.txt +1 -1
- metadata +157 -4
@@ -0,0 +1,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,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
|