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,634 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
module MIME
|
5
|
+
end
|
6
|
+
|
7
|
+
# The definition of one MIME content-type.
|
8
|
+
#
|
9
|
+
# == Usage
|
10
|
+
# require 'mime/types'
|
11
|
+
#
|
12
|
+
# plaintext = MIME::Types['text/plain'] # => [ text/plain ]
|
13
|
+
# text = plaintext.first
|
14
|
+
# puts text.media_type # => 'text'
|
15
|
+
# puts text.sub_type # => 'plain'
|
16
|
+
#
|
17
|
+
# puts text.extensions.join(' ') # => 'txt asc c cc h hh cpp hpp dat hlp'
|
18
|
+
# puts text.preferred_extension # => 'txt'
|
19
|
+
# puts text.friendly # => 'Text Document'
|
20
|
+
# puts text.i18n_key # => 'text.plain'
|
21
|
+
#
|
22
|
+
# puts text.encoding # => quoted-printable
|
23
|
+
# puts text.default_encoding # => quoted-printable
|
24
|
+
# puts text.binary? # => false
|
25
|
+
# puts text.ascii? # => true
|
26
|
+
# puts text.obsolete? # => false
|
27
|
+
# puts text.registered? # => true
|
28
|
+
# puts text.provisional? # => false
|
29
|
+
# puts text.complete? # => true
|
30
|
+
#
|
31
|
+
# puts text # => 'text/plain'
|
32
|
+
#
|
33
|
+
# puts text == 'text/plain' # => true
|
34
|
+
# puts 'text/plain' == text # => true
|
35
|
+
# puts text == 'text/x-plain' # => false
|
36
|
+
# puts 'text/x-plain' == text # => false
|
37
|
+
#
|
38
|
+
# puts MIME::Type.simplified('x-appl/x-zip') # => 'x-appl/x-zip'
|
39
|
+
# puts MIME::Type.i18n_key('x-appl/x-zip') # => 'x-appl.x-zip'
|
40
|
+
#
|
41
|
+
# puts text.like?('text/x-plain') # => true
|
42
|
+
# puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
|
43
|
+
#
|
44
|
+
# puts text.xrefs.inspect # => { "rfc" => [ "rfc2046", "rfc3676", "rfc5147" ] }
|
45
|
+
# puts text.xref_urls # => [ "http://www.iana.org/go/rfc2046",
|
46
|
+
# # "http://www.iana.org/go/rfc3676",
|
47
|
+
# # "http://www.iana.org/go/rfc5147" ]
|
48
|
+
#
|
49
|
+
# xtext = MIME::Type.new('x-text/x-plain')
|
50
|
+
# puts xtext.media_type # => 'text'
|
51
|
+
# puts xtext.raw_media_type # => 'x-text'
|
52
|
+
# puts xtext.sub_type # => 'plain'
|
53
|
+
# puts xtext.raw_sub_type # => 'x-plain'
|
54
|
+
# puts xtext.complete? # => false
|
55
|
+
#
|
56
|
+
# puts MIME::Types.any? { |type| type.content_type == 'text/plain' } # => true
|
57
|
+
# puts MIME::Types.all?(&:registered?) # => false
|
58
|
+
#
|
59
|
+
# # Various string representations of MIME types
|
60
|
+
# qcelp = MIME::Types['audio/QCELP'].first # => audio/QCELP
|
61
|
+
# puts qcelp.content_type # => 'audio/QCELP'
|
62
|
+
# puts qcelp.simplified # => 'audio/qcelp'
|
63
|
+
#
|
64
|
+
# xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
|
65
|
+
# puts xwingz.content_type # => 'application/x-Wingz'
|
66
|
+
# puts xwingz.simplified # => 'application/x-wingz'
|
67
|
+
class MIME::Type
|
68
|
+
# Reflects a MIME content-type specification that is not correctly
|
69
|
+
# formatted (it isn't +type+/+subtype+).
|
70
|
+
class InvalidContentType < ArgumentError
|
71
|
+
# :stopdoc:
|
72
|
+
def initialize(type_string)
|
73
|
+
@type_string = type_string
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_s
|
77
|
+
"Invalid Content-Type #{@type_string.inspect}"
|
78
|
+
end
|
79
|
+
# :startdoc:
|
80
|
+
end
|
81
|
+
|
82
|
+
# Reflects an unsupported MIME encoding.
|
83
|
+
class InvalidEncoding < ArgumentError
|
84
|
+
# :stopdoc:
|
85
|
+
def initialize(encoding)
|
86
|
+
@encoding = encoding
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_s
|
90
|
+
"Invalid Encoding #{@encoding.inspect}"
|
91
|
+
end
|
92
|
+
# :startdoc:
|
93
|
+
end
|
94
|
+
|
95
|
+
# The released version of the mime-types library.
|
96
|
+
VERSION = "3.4.1"
|
97
|
+
|
98
|
+
include Comparable
|
99
|
+
|
100
|
+
# :stopdoc:
|
101
|
+
# TODO verify mime-type character restrictions; I am pretty sure that this is
|
102
|
+
# too wide open.
|
103
|
+
MEDIA_TYPE_RE = %r{([-\w.+]+)/([-\w.+]*)}.freeze
|
104
|
+
I18N_RE = /[^[:alnum:]]/.freeze
|
105
|
+
BINARY_ENCODINGS = %w[base64 8bit].freeze
|
106
|
+
ASCII_ENCODINGS = %w[7bit quoted-printable].freeze
|
107
|
+
# :startdoc:
|
108
|
+
|
109
|
+
private_constant :MEDIA_TYPE_RE, :I18N_RE, :BINARY_ENCODINGS,
|
110
|
+
:ASCII_ENCODINGS
|
111
|
+
|
112
|
+
# Builds a MIME::Type object from the +content_type+, a MIME Content Type
|
113
|
+
# value (e.g., 'text/plain' or 'application/x-eruby'). The constructed object
|
114
|
+
# is yielded to an optional block for additional configuration, such as
|
115
|
+
# associating extensions and encoding information.
|
116
|
+
#
|
117
|
+
# * When provided a Hash or a MIME::Type, the MIME::Type will be
|
118
|
+
# constructed with #init_with.
|
119
|
+
# * When provided an Array, the MIME::Type will be constructed using
|
120
|
+
# the first element as the content type and the remaining flattened
|
121
|
+
# elements as extensions.
|
122
|
+
# * Otherwise, the content_type will be used as a string.
|
123
|
+
#
|
124
|
+
# Yields the newly constructed +self+ object.
|
125
|
+
def initialize(content_type) # :yields: self
|
126
|
+
@friendly = {}
|
127
|
+
@obsolete = @registered = @provisional = false
|
128
|
+
@preferred_extension = @docs = @use_instead = nil
|
129
|
+
self.extensions = []
|
130
|
+
|
131
|
+
case content_type
|
132
|
+
when Hash
|
133
|
+
init_with(content_type)
|
134
|
+
when Array
|
135
|
+
self.content_type = content_type.shift
|
136
|
+
self.extensions = content_type.flatten
|
137
|
+
when MIME::Type
|
138
|
+
init_with(content_type.to_h)
|
139
|
+
else
|
140
|
+
self.content_type = content_type
|
141
|
+
end
|
142
|
+
|
143
|
+
self.encoding ||= :default
|
144
|
+
self.xrefs ||= {}
|
145
|
+
|
146
|
+
yield self if block_given?
|
147
|
+
end
|
148
|
+
|
149
|
+
# Indicates that a MIME type is like another type. This differs from
|
150
|
+
# <tt>==</tt> because <tt>x-</tt> prefixes are removed for this comparison.
|
151
|
+
def like?(other)
|
152
|
+
other =
|
153
|
+
if other.respond_to?(:simplified)
|
154
|
+
MIME::Type.simplified(other.simplified, remove_x_prefix: true)
|
155
|
+
else
|
156
|
+
MIME::Type.simplified(other.to_s, remove_x_prefix: true)
|
157
|
+
end
|
158
|
+
MIME::Type.simplified(simplified, remove_x_prefix: true) == other
|
159
|
+
end
|
160
|
+
|
161
|
+
# Compares the +other+ MIME::Type against the exact content type or the
|
162
|
+
# simplified type (the simplified type will be used if comparing against
|
163
|
+
# something that can be treated as a String with #to_s). In comparisons, this
|
164
|
+
# is done against the lowercase version of the MIME::Type.
|
165
|
+
def <=>(other)
|
166
|
+
if other.nil?
|
167
|
+
-1
|
168
|
+
elsif other.respond_to?(:simplified)
|
169
|
+
simplified <=> other.simplified
|
170
|
+
else
|
171
|
+
filtered = "silent" if other == :silent
|
172
|
+
filtered ||= "true" if other == true
|
173
|
+
filtered ||= other.to_s
|
174
|
+
|
175
|
+
simplified <=> MIME::Type.simplified(filtered)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# Compares the +other+ MIME::Type based on how reliable it is before doing a
|
180
|
+
# normal <=> comparison. Used by MIME::Types#[] to sort types. The
|
181
|
+
# comparisons involved are:
|
182
|
+
#
|
183
|
+
# 1. self.simplified <=> other.simplified (ensures that we
|
184
|
+
# don't try to compare different types)
|
185
|
+
# 2. IANA-registered definitions < other definitions.
|
186
|
+
# 3. Complete definitions < incomplete definitions.
|
187
|
+
# 4. Current definitions < obsolete definitions.
|
188
|
+
# 5. Obselete with use-instead names < obsolete without.
|
189
|
+
# 6. Obsolete use-instead definitions are compared.
|
190
|
+
#
|
191
|
+
# While this method is public, its use is strongly discouraged by consumers
|
192
|
+
# of mime-types. In mime-types 3, this method is likely to see substantial
|
193
|
+
# revision and simplification to ensure current registered content types sort
|
194
|
+
# before unregistered or obsolete content types.
|
195
|
+
def priority_compare(other)
|
196
|
+
pc = simplified <=> other.simplified
|
197
|
+
if pc.zero? || !(extensions & other.extensions).empty?
|
198
|
+
pc =
|
199
|
+
if (reg = registered?) != other.registered?
|
200
|
+
reg ? -1 : 1 # registered < unregistered
|
201
|
+
elsif (comp = complete?) != other.complete?
|
202
|
+
comp ? -1 : 1 # complete < incomplete
|
203
|
+
elsif (obs = obsolete?) != other.obsolete?
|
204
|
+
obs ? 1 : -1 # current < obsolete
|
205
|
+
elsif obs && ((ui = use_instead) != (oui = other.use_instead))
|
206
|
+
if ui.nil?
|
207
|
+
1
|
208
|
+
elsif oui.nil?
|
209
|
+
-1
|
210
|
+
else
|
211
|
+
ui <=> oui
|
212
|
+
end
|
213
|
+
else
|
214
|
+
0
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
pc
|
219
|
+
end
|
220
|
+
|
221
|
+
# Returns +true+ if the +other+ object is a MIME::Type and the content types
|
222
|
+
# match.
|
223
|
+
def eql?(other)
|
224
|
+
other.is_a?(MIME::Type) && (self == other)
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the whole MIME content-type string.
|
228
|
+
#
|
229
|
+
# The content type is a presentation value from the MIME type registry and
|
230
|
+
# should not be used for comparison. The case of the content type is
|
231
|
+
# preserved, and extension markers (<tt>x-</tt>) are kept.
|
232
|
+
#
|
233
|
+
# text/plain => text/plain
|
234
|
+
# x-chemical/x-pdb => x-chemical/x-pdb
|
235
|
+
# audio/QCELP => audio/QCELP
|
236
|
+
attr_reader :content_type
|
237
|
+
# A simplified form of the MIME content-type string, suitable for
|
238
|
+
# case-insensitive comparison, with the content_type converted to lowercase.
|
239
|
+
#
|
240
|
+
# text/plain => text/plain
|
241
|
+
# x-chemical/x-pdb => x-chemical/x-pdb
|
242
|
+
# audio/QCELP => audio/qcelp
|
243
|
+
attr_reader :simplified
|
244
|
+
# Returns the media type of the simplified MIME::Type.
|
245
|
+
#
|
246
|
+
# text/plain => text
|
247
|
+
# x-chemical/x-pdb => x-chemical
|
248
|
+
# audio/QCELP => audio
|
249
|
+
attr_reader :media_type
|
250
|
+
# Returns the media type of the unmodified MIME::Type.
|
251
|
+
#
|
252
|
+
# text/plain => text
|
253
|
+
# x-chemical/x-pdb => x-chemical
|
254
|
+
# audio/QCELP => audio
|
255
|
+
attr_reader :raw_media_type
|
256
|
+
# Returns the sub-type of the simplified MIME::Type.
|
257
|
+
#
|
258
|
+
# text/plain => plain
|
259
|
+
# x-chemical/x-pdb => pdb
|
260
|
+
# audio/QCELP => QCELP
|
261
|
+
attr_reader :sub_type
|
262
|
+
# Returns the media type of the unmodified MIME::Type.
|
263
|
+
#
|
264
|
+
# text/plain => plain
|
265
|
+
# x-chemical/x-pdb => x-pdb
|
266
|
+
# audio/QCELP => qcelp
|
267
|
+
attr_reader :raw_sub_type
|
268
|
+
|
269
|
+
##
|
270
|
+
# The list of extensions which are known to be used for this MIME::Type.
|
271
|
+
# Non-array values will be coerced into an array with #to_a. Array values
|
272
|
+
# will be flattened, +nil+ values removed, and made unique.
|
273
|
+
#
|
274
|
+
# :attr_accessor: extensions
|
275
|
+
def extensions
|
276
|
+
@extensions.to_a
|
277
|
+
end
|
278
|
+
|
279
|
+
##
|
280
|
+
def extensions=(value) # :nodoc:
|
281
|
+
@extensions = Set[*Array(value).flatten.compact].freeze
|
282
|
+
MIME::Types.send(:reindex_extensions, self)
|
283
|
+
end
|
284
|
+
|
285
|
+
# Merge the +extensions+ provided into this MIME::Type. The extensions added
|
286
|
+
# will be merged uniquely.
|
287
|
+
def add_extensions(*extensions)
|
288
|
+
self.extensions += extensions
|
289
|
+
end
|
290
|
+
|
291
|
+
##
|
292
|
+
# The preferred extension for this MIME type. If one is not set and there are
|
293
|
+
# exceptions defined, the first extension will be used.
|
294
|
+
#
|
295
|
+
# When setting #preferred_extensions, if #extensions does not contain this
|
296
|
+
# extension, this will be added to #xtensions.
|
297
|
+
#
|
298
|
+
# :attr_accessor: preferred_extension
|
299
|
+
|
300
|
+
##
|
301
|
+
def preferred_extension
|
302
|
+
@preferred_extension || extensions.first
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
def preferred_extension=(value) # :nodoc:
|
307
|
+
add_extensions(value) if value
|
308
|
+
@preferred_extension = value
|
309
|
+
end
|
310
|
+
|
311
|
+
##
|
312
|
+
# The encoding (+7bit+, +8bit+, <tt>quoted-printable</tt>, or +base64+)
|
313
|
+
# required to transport the data of this content type safely across a
|
314
|
+
# network, which roughly corresponds to Content-Transfer-Encoding. A value of
|
315
|
+
# +nil+ or <tt>:default</tt> will reset the #encoding to the
|
316
|
+
# #default_encoding for the MIME::Type. Raises ArgumentError if the encoding
|
317
|
+
# provided is invalid.
|
318
|
+
#
|
319
|
+
# If the encoding is not provided on construction, this will be either
|
320
|
+
# 'quoted-printable' (for text/* media types) and 'base64' for eveything
|
321
|
+
# else.
|
322
|
+
#
|
323
|
+
# :attr_accessor: encoding
|
324
|
+
|
325
|
+
##
|
326
|
+
attr_reader :encoding
|
327
|
+
|
328
|
+
##
|
329
|
+
def encoding=(enc) # :nodoc:
|
330
|
+
if enc.nil? || (enc == :default)
|
331
|
+
@encoding = default_encoding
|
332
|
+
elsif BINARY_ENCODINGS.include?(enc) || ASCII_ENCODINGS.include?(enc)
|
333
|
+
@encoding = enc
|
334
|
+
else
|
335
|
+
fail InvalidEncoding, enc
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
# Returns the default encoding for the MIME::Type based on the media type.
|
340
|
+
def default_encoding
|
341
|
+
@media_type == "text" ? "quoted-printable" : "base64"
|
342
|
+
end
|
343
|
+
|
344
|
+
##
|
345
|
+
# Returns the media type or types that should be used instead of this media
|
346
|
+
# type, if it is obsolete. If there is no replacement media type, or it is
|
347
|
+
# not obsolete, +nil+ will be returned.
|
348
|
+
#
|
349
|
+
# :attr_accessor: use_instead
|
350
|
+
|
351
|
+
##
|
352
|
+
def use_instead
|
353
|
+
obsolete? ? @use_instead : nil
|
354
|
+
end
|
355
|
+
|
356
|
+
##
|
357
|
+
attr_writer :use_instead
|
358
|
+
|
359
|
+
# Returns +true+ if the media type is obsolete.
|
360
|
+
attr_accessor :obsolete
|
361
|
+
alias_method :obsolete?, :obsolete
|
362
|
+
|
363
|
+
# The documentation for this MIME::Type.
|
364
|
+
attr_accessor :docs
|
365
|
+
|
366
|
+
# A friendly short description for this MIME::Type.
|
367
|
+
#
|
368
|
+
# call-seq:
|
369
|
+
# text_plain.friendly # => "Text File"
|
370
|
+
# text_plain.friendly('en') # => "Text File"
|
371
|
+
def friendly(lang = "en")
|
372
|
+
@friendly ||= {}
|
373
|
+
|
374
|
+
case lang
|
375
|
+
when String, Symbol
|
376
|
+
@friendly[lang.to_s]
|
377
|
+
when Array
|
378
|
+
@friendly.update(Hash[*lang])
|
379
|
+
when Hash
|
380
|
+
@friendly.update(lang)
|
381
|
+
else
|
382
|
+
fail ArgumentError,
|
383
|
+
"Expected a language or translation set, not #{lang.inspect}"
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
# A key suitable for use as a lookup key for translations, such as with
|
388
|
+
# the I18n library.
|
389
|
+
#
|
390
|
+
# call-seq:
|
391
|
+
# text_plain.i18n_key # => "text.plain"
|
392
|
+
# 3gpp_xml.i18n_key # => "application.vnd-3gpp-bsf-xml"
|
393
|
+
# # from application/vnd.3gpp.bsf+xml
|
394
|
+
# x_msword.i18n_key # => "application.word"
|
395
|
+
# # from application/x-msword
|
396
|
+
attr_reader :i18n_key
|
397
|
+
|
398
|
+
##
|
399
|
+
# The cross-references list for this MIME::Type.
|
400
|
+
#
|
401
|
+
# :attr_accessor: xrefs
|
402
|
+
|
403
|
+
##
|
404
|
+
attr_reader :xrefs
|
405
|
+
|
406
|
+
##
|
407
|
+
def xrefs=(xrefs) # :nodoc:
|
408
|
+
@xrefs = MIME::Types::Container.new(xrefs)
|
409
|
+
end
|
410
|
+
|
411
|
+
# The decoded cross-reference URL list for this MIME::Type.
|
412
|
+
def xref_urls
|
413
|
+
xrefs.flat_map { |type, values|
|
414
|
+
name = :"xref_url_for_#{type.tr("-", "_")}"
|
415
|
+
respond_to?(name, true) && xref_map(values, name) || values.to_a
|
416
|
+
}
|
417
|
+
end
|
418
|
+
|
419
|
+
# Indicates whether the MIME type has been registered with IANA.
|
420
|
+
attr_accessor :registered
|
421
|
+
alias_method :registered?, :registered
|
422
|
+
|
423
|
+
# Indicates whether the MIME type's registration with IANA is provisional.
|
424
|
+
attr_accessor :provisional
|
425
|
+
|
426
|
+
# Indicates whether the MIME type's registration with IANA is provisional.
|
427
|
+
def provisional?
|
428
|
+
registered? && @provisional
|
429
|
+
end
|
430
|
+
|
431
|
+
# MIME types can be specified to be sent across a network in particular
|
432
|
+
# formats. This method returns +true+ when the MIME::Type encoding is set
|
433
|
+
# to <tt>base64</tt>.
|
434
|
+
def binary?
|
435
|
+
BINARY_ENCODINGS.include?(encoding)
|
436
|
+
end
|
437
|
+
|
438
|
+
# MIME types can be specified to be sent across a network in particular
|
439
|
+
# formats. This method returns +false+ when the MIME::Type encoding is
|
440
|
+
# set to <tt>base64</tt>.
|
441
|
+
def ascii?
|
442
|
+
ASCII_ENCODINGS.include?(encoding)
|
443
|
+
end
|
444
|
+
|
445
|
+
# Indicateswhether the MIME type is declared as a signature type.
|
446
|
+
attr_accessor :signature
|
447
|
+
alias_method :signature?, :signature
|
448
|
+
|
449
|
+
# Returns +true+ if the MIME::Type specifies an extension list,
|
450
|
+
# indicating that it is a complete MIME::Type.
|
451
|
+
def complete?
|
452
|
+
!@extensions.empty?
|
453
|
+
end
|
454
|
+
|
455
|
+
# Returns the MIME::Type as a string.
|
456
|
+
def to_s
|
457
|
+
content_type
|
458
|
+
end
|
459
|
+
|
460
|
+
# Returns the MIME::Type as a string for implicit conversions. This allows
|
461
|
+
# MIME::Type objects to appear on either side of a comparison.
|
462
|
+
#
|
463
|
+
# 'text/plain' == MIME::Type.new('text/plain')
|
464
|
+
def to_str
|
465
|
+
content_type
|
466
|
+
end
|
467
|
+
|
468
|
+
# Converts the MIME::Type to a JSON string.
|
469
|
+
def to_json(*args)
|
470
|
+
require "json"
|
471
|
+
to_h.to_json(*args)
|
472
|
+
end
|
473
|
+
|
474
|
+
# Converts the MIME::Type to a hash. The output of this method can also be
|
475
|
+
# used to initialize a MIME::Type.
|
476
|
+
def to_h
|
477
|
+
encode_with({})
|
478
|
+
end
|
479
|
+
|
480
|
+
# Populates the +coder+ with attributes about this record for
|
481
|
+
# serialization. The structure of +coder+ should match the structure used
|
482
|
+
# with #init_with.
|
483
|
+
#
|
484
|
+
# This method should be considered a private implementation detail.
|
485
|
+
def encode_with(coder)
|
486
|
+
coder["content-type"] = @content_type
|
487
|
+
coder["docs"] = @docs unless @docs.nil? || @docs.empty?
|
488
|
+
coder["friendly"] = @friendly unless @friendly.nil? || @friendly.empty?
|
489
|
+
coder["encoding"] = @encoding
|
490
|
+
coder["extensions"] = @extensions.to_a unless @extensions.empty?
|
491
|
+
coder["preferred-extension"] = @preferred_extension if @preferred_extension
|
492
|
+
if obsolete?
|
493
|
+
coder["obsolete"] = obsolete?
|
494
|
+
coder["use-instead"] = use_instead if use_instead
|
495
|
+
end
|
496
|
+
unless xrefs.empty?
|
497
|
+
{}.tap do |hash|
|
498
|
+
xrefs.each do |k, v|
|
499
|
+
hash[k] = v.to_a.sort
|
500
|
+
end
|
501
|
+
coder["xrefs"] = hash
|
502
|
+
end
|
503
|
+
end
|
504
|
+
coder["registered"] = registered?
|
505
|
+
coder["provisional"] = provisional? if provisional?
|
506
|
+
coder["signature"] = signature? if signature?
|
507
|
+
coder
|
508
|
+
end
|
509
|
+
|
510
|
+
# Initialize an empty object from +coder+, which must contain the
|
511
|
+
# attributes necessary for initializing an empty object.
|
512
|
+
#
|
513
|
+
# This method should be considered a private implementation detail.
|
514
|
+
def init_with(coder)
|
515
|
+
self.content_type = coder["content-type"]
|
516
|
+
self.docs = coder["docs"] || ""
|
517
|
+
self.encoding = coder["encoding"]
|
518
|
+
self.extensions = coder["extensions"] || []
|
519
|
+
self.preferred_extension = coder["preferred-extension"]
|
520
|
+
self.obsolete = coder["obsolete"] || false
|
521
|
+
self.registered = coder["registered"] || false
|
522
|
+
self.provisional = coder["provisional"] || false
|
523
|
+
self.signature = coder["signature"]
|
524
|
+
self.xrefs = coder["xrefs"] || {}
|
525
|
+
self.use_instead = coder["use-instead"]
|
526
|
+
|
527
|
+
friendly(coder["friendly"] || {})
|
528
|
+
end
|
529
|
+
|
530
|
+
def inspect # :nodoc:
|
531
|
+
# We are intentionally lying here because MIME::Type::Columnar is an
|
532
|
+
# implementation detail.
|
533
|
+
"#<MIME::Type: #{self}>"
|
534
|
+
end
|
535
|
+
|
536
|
+
class << self
|
537
|
+
# MIME media types are case-insensitive, but are typically presented in a
|
538
|
+
# case-preserving format in the type registry. This method converts
|
539
|
+
# +content_type+ to lowercase.
|
540
|
+
#
|
541
|
+
# In previous versions of mime-types, this would also remove any extension
|
542
|
+
# prefix (<tt>x-</tt>). This is no longer default behaviour, but may be
|
543
|
+
# provided by providing a truth value to +remove_x_prefix+.
|
544
|
+
def simplified(content_type, remove_x_prefix: false)
|
545
|
+
simplify_matchdata(match(content_type), remove_x_prefix)
|
546
|
+
end
|
547
|
+
|
548
|
+
# Converts a provided +content_type+ into a translation key suitable for
|
549
|
+
# use with the I18n library.
|
550
|
+
def i18n_key(content_type)
|
551
|
+
simplify_matchdata(match(content_type), joiner: ".") { |e|
|
552
|
+
e.gsub!(I18N_RE, "-")
|
553
|
+
}
|
554
|
+
end
|
555
|
+
|
556
|
+
# Return a +MatchData+ object of the +content_type+ against pattern of
|
557
|
+
# media types.
|
558
|
+
def match(content_type)
|
559
|
+
case content_type
|
560
|
+
when MatchData
|
561
|
+
content_type
|
562
|
+
else
|
563
|
+
MEDIA_TYPE_RE.match(content_type)
|
564
|
+
end
|
565
|
+
end
|
566
|
+
|
567
|
+
private
|
568
|
+
|
569
|
+
def simplify_matchdata(matchdata, remove_x = false, joiner: "/")
|
570
|
+
return nil unless matchdata
|
571
|
+
|
572
|
+
matchdata.captures.map { |e|
|
573
|
+
e.downcase!
|
574
|
+
e.sub!(/^x-/, "") if remove_x
|
575
|
+
yield e if block_given?
|
576
|
+
e
|
577
|
+
}.join(joiner)
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
581
|
+
private
|
582
|
+
|
583
|
+
def content_type=(type_string)
|
584
|
+
match = MEDIA_TYPE_RE.match(type_string)
|
585
|
+
fail InvalidContentType, type_string if match.nil?
|
586
|
+
|
587
|
+
@content_type = intern_string(type_string)
|
588
|
+
@raw_media_type, @raw_sub_type = match.captures
|
589
|
+
@simplified = intern_string(MIME::Type.simplified(match))
|
590
|
+
@i18n_key = intern_string(MIME::Type.i18n_key(match))
|
591
|
+
@media_type, @sub_type = MEDIA_TYPE_RE.match(@simplified).captures
|
592
|
+
|
593
|
+
@raw_media_type = intern_string(@raw_media_type)
|
594
|
+
@raw_sub_type = intern_string(@raw_sub_type)
|
595
|
+
@media_type = intern_string(@media_type)
|
596
|
+
@sub_type = intern_string(@sub_type)
|
597
|
+
end
|
598
|
+
|
599
|
+
if String.method_defined?(:-@)
|
600
|
+
def intern_string(string)
|
601
|
+
-string
|
602
|
+
end
|
603
|
+
else
|
604
|
+
# MRI 2.2 and older don't have a method for string interning,
|
605
|
+
# so we simply freeze them for keeping a similar interface
|
606
|
+
def intern_string(string)
|
607
|
+
string.freeze
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
611
|
+
def xref_map(values, helper)
|
612
|
+
values.map { |value| send(helper, value) }
|
613
|
+
end
|
614
|
+
|
615
|
+
def xref_url_for_rfc(value)
|
616
|
+
"http://www.iana.org/go/%s" % value
|
617
|
+
end
|
618
|
+
|
619
|
+
def xref_url_for_draft(value)
|
620
|
+
"http://www.iana.org/go/%s" % value.sub(/\ARFC/, "draft")
|
621
|
+
end
|
622
|
+
|
623
|
+
def xref_url_for_rfc_errata(value)
|
624
|
+
"http://www.rfc-editor.org/errata_search.php?eid=%s" % value
|
625
|
+
end
|
626
|
+
|
627
|
+
def xref_url_for_person(value)
|
628
|
+
"http://www.iana.org/assignments/media-types/media-types.xhtml#%s" % value
|
629
|
+
end
|
630
|
+
|
631
|
+
def xref_url_for_template(value)
|
632
|
+
"http://www.iana.org/assignments/media-types/%s" % value
|
633
|
+
end
|
634
|
+
end
|