kinetic_sdk 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/GettingStarted.md +64 -0
- data/README.md +383 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/gems/kontena-websocket-client-0.1.1/Gemfile +4 -0
- data/gems/kontena-websocket-client-0.1.1/LICENSE +190 -0
- data/gems/kontena-websocket-client-0.1.1/README.md +138 -0
- data/gems/kontena-websocket-client-0.1.1/Rakefile +6 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-client.rb +45 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-em.rb +66 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.rb +161 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.sh +17 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/websocket-echo-server.go +207 -0
- data/gems/kontena-websocket-client-0.1.1/examples/websocket-echo-client.rb +80 -0
- data/gems/kontena-websocket-client-0.1.1/kontena-websocket-client.gemspec +24 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/connection.rb +119 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/version.rb +13 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client.rb +848 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb +81 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb +55 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/openssl_patch.rb +10 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena-websocket-client.rb +15 -0
- data/gems/mime-types-3.1/Code-of-Conduct.rdoc +74 -0
- data/gems/mime-types-3.1/Contributing.rdoc +130 -0
- data/gems/mime-types-3.1/History.rdoc +658 -0
- data/gems/mime-types-3.1/Licence.rdoc +25 -0
- data/gems/mime-types-3.1/Manifest.txt +31 -0
- data/gems/mime-types-3.1/README.rdoc +202 -0
- data/gems/mime-types-3.1/Rakefile +254 -0
- data/gems/mime-types-3.1/lib/mime/type/columnar.rb +55 -0
- data/gems/mime-types-3.1/lib/mime/type.rb +573 -0
- data/gems/mime-types-3.1/lib/mime/types/_columnar.rb +135 -0
- data/gems/mime-types-3.1/lib/mime/types/cache.rb +56 -0
- data/gems/mime-types-3.1/lib/mime/types/columnar.rb +1 -0
- data/gems/mime-types-3.1/lib/mime/types/container.rb +30 -0
- data/gems/mime-types-3.1/lib/mime/types/deprecations.rb +32 -0
- data/gems/mime-types-3.1/lib/mime/types/full.rb +17 -0
- data/gems/mime-types-3.1/lib/mime/types/loader.rb +148 -0
- data/gems/mime-types-3.1/lib/mime/types/logger.rb +37 -0
- data/gems/mime-types-3.1/lib/mime/types/registry.rb +81 -0
- data/gems/mime-types-3.1/lib/mime/types.rb +228 -0
- data/gems/mime-types-3.1/lib/mime-types.rb +1 -0
- data/gems/mime-types-3.1/test/bad-fixtures/malformed +9 -0
- data/gems/mime-types-3.1/test/fixture/json.json +1 -0
- data/gems/mime-types-3.1/test/fixture/old-data +9 -0
- data/gems/mime-types-3.1/test/fixture/yaml.yaml +55 -0
- data/gems/mime-types-3.1/test/minitest_helper.rb +13 -0
- data/gems/mime-types-3.1/test/test_mime_type.rb +603 -0
- data/gems/mime-types-3.1/test/test_mime_types.rb +161 -0
- data/gems/mime-types-3.1/test/test_mime_types_cache.rb +109 -0
- data/gems/mime-types-3.1/test/test_mime_types_class.rb +155 -0
- data/gems/mime-types-3.1/test/test_mime_types_lazy.rb +43 -0
- data/gems/mime-types-3.1/test/test_mime_types_loader.rb +32 -0
- data/gems/mime-types-data-3.2016.0521/Code-of-Conduct.md +75 -0
- data/gems/mime-types-data-3.2016.0521/Contributing.md +157 -0
- data/gems/mime-types-data-3.2016.0521/History.md +351 -0
- data/gems/mime-types-data-3.2016.0521/Licence.md +25 -0
- data/gems/mime-types-data-3.2016.0521/Manifest.txt +18 -0
- data/gems/mime-types-data-3.2016.0521/README.md +61 -0
- data/gems/mime-types-data-3.2016.0521/Rakefile +80 -0
- data/gems/mime-types-data-3.2016.0521/data/mime-types.json +1 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.content_type.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.docs.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.encoding.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.flags.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.friendly.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.pext.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.use_instead.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.xrefs.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/lib/mime/types/data.rb +21 -0
- data/gems/mime-types-data-3.2016.0521/lib/mime-types-data.rb +3 -0
- data/gems/multipart-post-2.0.0/Gemfile +14 -0
- data/gems/multipart-post-2.0.0/History.txt +60 -0
- data/gems/multipart-post-2.0.0/Manifest.txt +9 -0
- data/gems/multipart-post-2.0.0/README.md +77 -0
- data/gems/multipart-post-2.0.0/Rakefile +9 -0
- data/gems/multipart-post-2.0.0/lib/composite_io.rb +108 -0
- data/gems/multipart-post-2.0.0/lib/multipart_post.rb +9 -0
- data/gems/multipart-post-2.0.0/lib/multipartable.rb +29 -0
- data/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +27 -0
- data/gems/multipart-post-2.0.0/lib/parts.rb +96 -0
- data/gems/multipart-post-2.0.0/multipart-post.gemspec +22 -0
- data/gems/multipart-post-2.0.0/test/multibyte.txt +1 -0
- data/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +110 -0
- data/gems/multipart-post-2.0.0/test/test_composite_io.rb +115 -0
- data/gems/multipart-post-2.0.0/test/test_parts.rb +86 -0
- data/gems/parallel-1.12.1/MIT-LICENSE.txt +20 -0
- data/gems/parallel-1.12.1/lib/parallel/processor_count.rb +93 -0
- data/gems/parallel-1.12.1/lib/parallel/version.rb +3 -0
- data/gems/parallel-1.12.1/lib/parallel.rb +500 -0
- data/gems/ruby-progressbar-1.9.0/LICENSE.txt +19 -0
- data/gems/ruby-progressbar-1.9.0/README.md +38 -0
- data/gems/ruby-progressbar-1.9.0/Rakefile +2 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/base.rb +183 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/length.rb +99 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/running_average.rb +9 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/bar.rb +96 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/percentage.rb +29 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb +43 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/time.rb +107 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/title.rb +13 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components.rb +5 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/errors/invalid_progress_error.rb +4 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/formatter.rb +27 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/molecule.rb +59 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/string.rb +36 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format.rb +3 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/output.rb +68 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/non_tty.rb +47 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/null.rb +33 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/tty.rb +32 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/progress.rb +118 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb +25 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements.rb +1 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/throttle.rb +25 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/time.rb +30 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/timer.rb +72 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/version.rb +3 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar.rb +18 -0
- data/gems/slugify-1.0.7/README +18 -0
- data/gems/slugify-1.0.7/lib/slugify.rb +1012 -0
- data/gems/slugify-1.0.7/lib/slugify_string.rb +11 -0
- data/gems/slugify-1.0.7/tests/slugify_test.rb +116 -0
- data/gems/slugify-1.0.7/tests/string_slugify_test.rb +23 -0
- data/gems/websocket-driver-0.6.5/CHANGELOG.md +123 -0
- data/gems/websocket-driver-0.6.5/LICENSE.md +22 -0
- data/gems/websocket-driver-0.6.5/README.md +369 -0
- data/gems/websocket-driver-0.6.5/examples/tcp_server.rb +28 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/Makefile +264 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/WebsocketMaskService.java +55 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/extconf.rb +4 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.bundle +0 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.c +41 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.o +0 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/client.rb +140 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft75.rb +102 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft76.rb +96 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/event_emitter.rb +54 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/headers.rb +45 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/frame.rb +20 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/message.rb +31 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi.rb +406 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/proxy.rb +68 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/server.rb +80 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/stream_reader.rb +55 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver.rb +199 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/headers.rb +112 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/request.rb +45 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/response.rb +29 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http.rb +15 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/mask.rb +14 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/websocket_mask.rb +2 -0
- data/gems/websocket-driver-0.6.5/lib/websocket_mask.bundle +0 -0
- data/gems/websocket-driver-0.6.5-java/CHANGELOG.md +123 -0
- data/gems/websocket-driver-0.6.5-java/LICENSE.md +22 -0
- data/gems/websocket-driver-0.6.5-java/README.md +369 -0
- data/gems/websocket-driver-0.6.5-java/examples/tcp_server.rb +28 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/WebsocketMaskService.java +55 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/extconf.rb +4 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/websocket_mask.c +41 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/client.rb +140 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft75.rb +102 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft76.rb +96 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/event_emitter.rb +54 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/headers.rb +45 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/frame.rb +20 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/message.rb +31 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi.rb +406 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/proxy.rb +68 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/server.rb +80 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/stream_reader.rb +55 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver.rb +199 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/headers.rb +112 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/request.rb +45 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/response.rb +29 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http.rb +15 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/mask.rb +14 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/websocket_mask.rb +2 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket_mask.jar +0 -0
- data/gems/websocket-extensions-0.1.3/CHANGELOG.md +15 -0
- data/gems/websocket-extensions-0.1.3/LICENSE.md +20 -0
- data/gems/websocket-extensions-0.1.3/README.md +313 -0
- data/gems/websocket-extensions-0.1.3/lib/websocket/extensions/parser.rb +111 -0
- data/gems/websocket-extensions-0.1.3/lib/websocket/extensions.rb +181 -0
- data/lib/kinetic-sdk.rb +1 -0
- data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +80 -0
- data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +67 -0
- data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +69 -0
- data/lib/kinetic_sdk/discussions/discussions-sdk.rb +165 -0
- data/lib/kinetic_sdk/discussions/lib/discussions.rb +107 -0
- data/lib/kinetic_sdk/discussions/lib/invitations.rb +120 -0
- data/lib/kinetic_sdk/discussions/lib/messages.rb +190 -0
- data/lib/kinetic_sdk/discussions/lib/meta.rb +14 -0
- data/lib/kinetic_sdk/discussions/lib/participants.rb +64 -0
- data/lib/kinetic_sdk/discussions/lib/related_items.rb +54 -0
- data/lib/kinetic_sdk/discussions/lib/websockets.rb +96 -0
- data/lib/kinetic_sdk/filehub/filehub-sdk.rb +80 -0
- data/lib/kinetic_sdk/filehub/lib/access_keys.rb +67 -0
- data/lib/kinetic_sdk/filehub/lib/filestores.rb +67 -0
- data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +153 -0
- data/lib/kinetic_sdk/request_ce/lib/bridges.rb +66 -0
- data/lib/kinetic_sdk/request_ce/lib/categories.rb +34 -0
- data/lib/kinetic_sdk/request_ce/lib/datastore_form.rb +110 -0
- data/lib/kinetic_sdk/request_ce/lib/datastore_submissions.rb +157 -0
- data/lib/kinetic_sdk/request_ce/lib/form.rb +99 -0
- data/lib/kinetic_sdk/request_ce/lib/form_types.rb +51 -0
- data/lib/kinetic_sdk/request_ce/lib/jwt.rb +55 -0
- data/lib/kinetic_sdk/request_ce/lib/kapp.rb +93 -0
- data/lib/kinetic_sdk/request_ce/lib/meta.rb +14 -0
- data/lib/kinetic_sdk/request_ce/lib/oauth.rb +37 -0
- data/lib/kinetic_sdk/request_ce/lib/security_policy_definitions.rb +157 -0
- data/lib/kinetic_sdk/request_ce/lib/space.rb +89 -0
- data/lib/kinetic_sdk/request_ce/lib/submissions.rb +215 -0
- data/lib/kinetic_sdk/request_ce/lib/system_api.rb +69 -0
- data/lib/kinetic_sdk/request_ce/lib/teams.rb +113 -0
- data/lib/kinetic_sdk/request_ce/lib/users.rb +245 -0
- data/lib/kinetic_sdk/request_ce/lib/webhook_jobs.rb +142 -0
- data/lib/kinetic_sdk/request_ce/lib/webhooks.rb +192 -0
- data/lib/kinetic_sdk/request_ce/request-ce-sdk.rb +153 -0
- data/lib/kinetic_sdk/task/lib/access_keys.rb +94 -0
- data/lib/kinetic_sdk/task/lib/categories.rb +190 -0
- data/lib/kinetic_sdk/task/lib/config.rb +202 -0
- data/lib/kinetic_sdk/task/lib/engine.rb +42 -0
- data/lib/kinetic_sdk/task/lib/environment.rb +14 -0
- data/lib/kinetic_sdk/task/lib/errors.rb +165 -0
- data/lib/kinetic_sdk/task/lib/groups.rb +112 -0
- data/lib/kinetic_sdk/task/lib/handlers.rb +105 -0
- data/lib/kinetic_sdk/task/lib/health.rb +28 -0
- data/lib/kinetic_sdk/task/lib/license.rb +52 -0
- data/lib/kinetic_sdk/task/lib/policy_rules.rb +166 -0
- data/lib/kinetic_sdk/task/lib/setup.rb +56 -0
- data/lib/kinetic_sdk/task/lib/sources.rb +134 -0
- data/lib/kinetic_sdk/task/lib/tasks.rb +17 -0
- data/lib/kinetic_sdk/task/lib/trees.rb +274 -0
- data/lib/kinetic_sdk/task/lib/users.rb +75 -0
- data/lib/kinetic_sdk/task/task-sdk.rb +92 -0
- data/lib/kinetic_sdk/utils/kinetic-http-headers.rb +150 -0
- data/lib/kinetic_sdk/utils/kinetic-http-response.rb +75 -0
- data/lib/kinetic_sdk/utils/kinetic-http.rb +552 -0
- data/lib/kinetic_sdk/utils/logger.rb +70 -0
- data/lib/kinetic_sdk/utils/random.rb +30 -0
- data/lib/kinetic_sdk/version.rb +7 -0
- data/lib/kinetic_sdk.rb +57 -0
- metadata +414 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
MIME::Types::Cache = Struct.new(:version, :data) # :nodoc:
|
2
|
+
|
3
|
+
# Caching of MIME::Types registries is advisable if you will be loading
|
4
|
+
# the default registry relatively frequently. With the class methods on
|
5
|
+
# MIME::Types::Cache, any MIME::Types registry can be marshaled quickly
|
6
|
+
# and easily.
|
7
|
+
#
|
8
|
+
# The cache is invalidated on a per-data-version basis; a cache file for
|
9
|
+
# version 3.2015.1118 will not be reused with version 3.2015.1201.
|
10
|
+
class << MIME::Types::Cache
|
11
|
+
# Attempts to load the cache from the file provided as a parameter or in
|
12
|
+
# the environment variable +RUBY_MIME_TYPES_CACHE+. Returns +nil+ if the
|
13
|
+
# file does not exist, if the file cannot be loaded, or if the data in
|
14
|
+
# the cache version is different than this version.
|
15
|
+
def load(cache_file = nil)
|
16
|
+
cache_file ||= ENV['RUBY_MIME_TYPES_CACHE']
|
17
|
+
return nil unless cache_file and File.exist?(cache_file)
|
18
|
+
|
19
|
+
cache = Marshal.load(File.binread(cache_file))
|
20
|
+
if cache.version == MIME::Types::Data::VERSION
|
21
|
+
Marshal.load(cache.data)
|
22
|
+
else
|
23
|
+
MIME::Types.logger.warn <<-warning.chomp
|
24
|
+
Could not load MIME::Types cache: invalid version
|
25
|
+
warning
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
rescue => e
|
29
|
+
MIME::Types.logger.warn <<-warning.chomp
|
30
|
+
Could not load MIME::Types cache: #{e}
|
31
|
+
warning
|
32
|
+
return nil
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attempts to save the types provided to the cache file provided.
|
36
|
+
#
|
37
|
+
# If +types+ is not provided or is +nil+, the cache will contain the
|
38
|
+
# current MIME::Types default registry.
|
39
|
+
#
|
40
|
+
# If +cache_file+ is not provided or is +nil+, the cache will be written
|
41
|
+
# to the file specified in the environment variable
|
42
|
+
# +RUBY_MIME_TYPES_CACHE+. If there is no cache file specified either
|
43
|
+
# directly or through the environment, this method will return +nil+
|
44
|
+
def save(types = nil, cache_file = nil)
|
45
|
+
cache_file ||= ENV['RUBY_MIME_TYPES_CACHE']
|
46
|
+
return nil unless cache_file
|
47
|
+
|
48
|
+
types ||= MIME::Types.send(:__types__)
|
49
|
+
|
50
|
+
File.open(cache_file, 'wb') do |f|
|
51
|
+
f.write(
|
52
|
+
Marshal.dump(new(MIME::Types::Data::VERSION, Marshal.dump(types)))
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'mime/types'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
# MIME::Types requires a container Hash with a default values for keys
|
4
|
+
# resulting in an empty array (<tt>[]</tt>), but this cannot be dumped through
|
5
|
+
# Marshal because of the presence of that default Proc. This class exists
|
6
|
+
# solely to satisfy that need.
|
7
|
+
class MIME::Types::Container < Hash # :nodoc:
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
self.default_proc = ->(h, k) { h[k] = Set.new }
|
11
|
+
end
|
12
|
+
|
13
|
+
def marshal_dump
|
14
|
+
{}.merge(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
def marshal_load(hash)
|
18
|
+
self.default_proc = ->(h, k) { h[k] = Set.new }
|
19
|
+
merge!(hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
def encode_with(coder)
|
23
|
+
each { |k, v| coder[k] = v.to_a }
|
24
|
+
end
|
25
|
+
|
26
|
+
def init_with(coder)
|
27
|
+
self.default_proc = ->(h, k) { h[k] = Set.new }
|
28
|
+
coder.map.each { |k, v| self[k] = Set[*v] }
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'mime/types/logger'
|
4
|
+
|
5
|
+
# The namespace for MIME applications, tools, and libraries.
|
6
|
+
module MIME
|
7
|
+
##
|
8
|
+
class Types
|
9
|
+
# Used to mark a method as deprecated in the mime-types interface.
|
10
|
+
def self.deprecated(klass, sym, message = nil, &block) # :nodoc:
|
11
|
+
level = case klass
|
12
|
+
when Class, Module
|
13
|
+
'.'
|
14
|
+
else
|
15
|
+
klass = klass.class
|
16
|
+
'#'
|
17
|
+
end
|
18
|
+
message = case message
|
19
|
+
when :private, :protected
|
20
|
+
"and will be #{message}"
|
21
|
+
when nil
|
22
|
+
'and will be removed'
|
23
|
+
else
|
24
|
+
message
|
25
|
+
end
|
26
|
+
MIME::Types.logger.warn <<-warning.chomp
|
27
|
+
#{caller[1]}: #{klass}#{level}#{sym} is deprecated #{message}.
|
28
|
+
warning
|
29
|
+
block.call if block
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
##
|
4
|
+
module MIME; end
|
5
|
+
##
|
6
|
+
class MIME::Types; end
|
7
|
+
|
8
|
+
require 'mime/types/data'
|
9
|
+
|
10
|
+
# This class is responsible for initializing the MIME::Types registry from
|
11
|
+
# the data files supplied with the mime-types library.
|
12
|
+
#
|
13
|
+
# The Loader will use one of the following paths:
|
14
|
+
# 1. The +path+ provided in its constructor argument;
|
15
|
+
# 2. The value of ENV['RUBY_MIME_TYPES_DATA']; or
|
16
|
+
# 3. The value of MIME::Types::Data::PATH.
|
17
|
+
#
|
18
|
+
# When #load is called, the +path+ will be searched recursively for all YAML
|
19
|
+
# (.yml or .yaml) files. By convention, there is one file for each media
|
20
|
+
# type (application.yml, audio.yml, etc.), but this is not required.
|
21
|
+
class MIME::Types::Loader
|
22
|
+
# The path that will be read for the MIME::Types files.
|
23
|
+
attr_reader :path
|
24
|
+
# The MIME::Types container instance that will be loaded. If not provided
|
25
|
+
# at initialization, a new MIME::Types instance will be constructed.
|
26
|
+
attr_reader :container
|
27
|
+
|
28
|
+
# Creates a Loader object that can be used to load MIME::Types registries
|
29
|
+
# into memory, using YAML, JSON, or Columnar registry format loaders.
|
30
|
+
def initialize(path = nil, container = nil)
|
31
|
+
path = path || ENV['RUBY_MIME_TYPES_DATA'] || MIME::Types::Data::PATH
|
32
|
+
@container = container || MIME::Types.new
|
33
|
+
@path = File.expand_path(path)
|
34
|
+
# begin
|
35
|
+
# require 'mime/lazy_types'
|
36
|
+
# @container.extend(MIME::LazyTypes)
|
37
|
+
# end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Loads a MIME::Types registry from YAML files (<tt>*.yml</tt> or
|
41
|
+
# <tt>*.yaml</tt>) recursively found in +path+.
|
42
|
+
#
|
43
|
+
# It is expected that the YAML objects contained within the registry array
|
44
|
+
# will be tagged as <tt>!ruby/object:MIME::Type</tt>.
|
45
|
+
#
|
46
|
+
# Note that the YAML format is about 2½ times *slower* than the JSON format.
|
47
|
+
#
|
48
|
+
# NOTE: The purpose of this format is purely for maintenance reasons.
|
49
|
+
def load_yaml
|
50
|
+
Dir[yaml_path].sort.each do |f|
|
51
|
+
container.add(*self.class.load_from_yaml(f), :silent)
|
52
|
+
end
|
53
|
+
container
|
54
|
+
end
|
55
|
+
|
56
|
+
# Loads a MIME::Types registry from JSON files (<tt>*.json</tt>)
|
57
|
+
# recursively found in +path+.
|
58
|
+
#
|
59
|
+
# It is expected that the JSON objects will be an array of hash objects.
|
60
|
+
# The JSON format is the registry format for the MIME types registry
|
61
|
+
# shipped with the mime-types library.
|
62
|
+
def load_json
|
63
|
+
Dir[json_path].sort.each do |f|
|
64
|
+
types = self.class.load_from_json(f)
|
65
|
+
container.add(*types, :silent)
|
66
|
+
end
|
67
|
+
container
|
68
|
+
end
|
69
|
+
|
70
|
+
# Loads a MIME::Types registry from columnar files recursively found in
|
71
|
+
# +path+.
|
72
|
+
def load_columnar
|
73
|
+
require 'mime/types/columnar' unless defined?(MIME::Types::Columnar)
|
74
|
+
container.extend(MIME::Types::Columnar)
|
75
|
+
container.load_base_data(path)
|
76
|
+
|
77
|
+
container
|
78
|
+
end
|
79
|
+
|
80
|
+
# Loads a MIME::Types registry. Loads from JSON files by default
|
81
|
+
# (#load_json).
|
82
|
+
#
|
83
|
+
# This will load from columnar files (#load_columnar) if <tt>columnar:
|
84
|
+
# true</tt> is provided in +options+ and there are columnar files in +path+.
|
85
|
+
def load(options = { columnar: false })
|
86
|
+
if options[:columnar] && !Dir[columnar_path].empty?
|
87
|
+
load_columnar
|
88
|
+
else
|
89
|
+
load_json
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class << self
|
94
|
+
# Loads the default MIME::Type registry.
|
95
|
+
def load(options = { columnar: false })
|
96
|
+
new.load(options)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Loads MIME::Types from a single YAML file.
|
100
|
+
#
|
101
|
+
# It is expected that the YAML objects contained within the registry
|
102
|
+
# array will be tagged as <tt>!ruby/object:MIME::Type</tt>.
|
103
|
+
#
|
104
|
+
# Note that the YAML format is about 2½ times *slower* than the JSON
|
105
|
+
# format.
|
106
|
+
#
|
107
|
+
# NOTE: The purpose of this format is purely for maintenance reasons.
|
108
|
+
def load_from_yaml(filename)
|
109
|
+
begin
|
110
|
+
require 'psych'
|
111
|
+
rescue LoadError
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
require 'yaml'
|
115
|
+
YAML.load(read_file(filename))
|
116
|
+
end
|
117
|
+
|
118
|
+
# Loads MIME::Types from a single JSON file.
|
119
|
+
#
|
120
|
+
# It is expected that the JSON objects will be an array of hash objects.
|
121
|
+
# The JSON format is the registry format for the MIME types registry
|
122
|
+
# shipped with the mime-types library.
|
123
|
+
def load_from_json(filename)
|
124
|
+
require 'json'
|
125
|
+
JSON.parse(read_file(filename)).map { |type| MIME::Type.new(type) }
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def read_file(filename)
|
131
|
+
File.open(filename, 'r:UTF-8:-', &:read)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def yaml_path
|
138
|
+
File.join(path, '*.y{,a}ml')
|
139
|
+
end
|
140
|
+
|
141
|
+
def json_path
|
142
|
+
File.join(path, '*.json')
|
143
|
+
end
|
144
|
+
|
145
|
+
def columnar_path
|
146
|
+
File.join(path, '*.column')
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
##
|
6
|
+
module MIME
|
7
|
+
##
|
8
|
+
class Types
|
9
|
+
class << self
|
10
|
+
# Configure the MIME::Types logger. This defaults to an instance of a
|
11
|
+
# logger that passes messages (unformatted) through to Kernel#warn.
|
12
|
+
attr_accessor :logger
|
13
|
+
end
|
14
|
+
|
15
|
+
class WarnLogger < ::Logger #:nodoc:
|
16
|
+
class WarnLogDevice < ::Logger::LogDevice #:nodoc:
|
17
|
+
def initialize(*)
|
18
|
+
end
|
19
|
+
|
20
|
+
def write(m)
|
21
|
+
Kernel.warn(m)
|
22
|
+
end
|
23
|
+
|
24
|
+
def close
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(_1, _2 = nil, _3 = nil)
|
29
|
+
super nil
|
30
|
+
@logdev = WarnLogDevice.new
|
31
|
+
@formatter = ->(_s, _d, _p, m) { m }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
self.logger = WarnLogger.new(nil)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class << MIME::Types
|
2
|
+
include Enumerable
|
3
|
+
|
4
|
+
##
|
5
|
+
def new(*) # :nodoc:
|
6
|
+
super.tap do |types|
|
7
|
+
__instances__.add types
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# MIME::Types#[] against the default MIME::Types registry.
|
12
|
+
def [](type_id, complete: false, registered: false)
|
13
|
+
__types__[type_id, complete: complete, registered: registered]
|
14
|
+
end
|
15
|
+
|
16
|
+
# MIME::Types#count against the default MIME::Types registry.
|
17
|
+
def count
|
18
|
+
__types__.count
|
19
|
+
end
|
20
|
+
|
21
|
+
# MIME::Types#each against the default MIME::Types registry.
|
22
|
+
def each
|
23
|
+
if block_given?
|
24
|
+
__types__.each { |t| yield t }
|
25
|
+
else
|
26
|
+
enum_for(:each)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# MIME::Types#type_for against the default MIME::Types registry.
|
31
|
+
def type_for(filename)
|
32
|
+
__types__.type_for(filename)
|
33
|
+
end
|
34
|
+
alias_method :of, :type_for
|
35
|
+
|
36
|
+
# MIME::Types#add against the default MIME::Types registry.
|
37
|
+
def add(*types)
|
38
|
+
__types__.add(*types)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def lazy_load?
|
44
|
+
(lazy = ENV['RUBY_MIME_TYPES_LAZY_LOAD']) && (lazy != 'false')
|
45
|
+
end
|
46
|
+
|
47
|
+
def __types__
|
48
|
+
(defined?(@__types__) and @__types__) or load_default_mime_types
|
49
|
+
end
|
50
|
+
|
51
|
+
unless private_method_defined?(:load_mode)
|
52
|
+
def load_mode
|
53
|
+
{ columnar: true }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_default_mime_types(mode = load_mode)
|
58
|
+
@__types__ = MIME::Types::Cache.load
|
59
|
+
unless @__types__
|
60
|
+
@__types__ = MIME::Types::Loader.load(mode)
|
61
|
+
MIME::Types::Cache.save(@__types__)
|
62
|
+
end
|
63
|
+
@__types__
|
64
|
+
end
|
65
|
+
|
66
|
+
def __instances__
|
67
|
+
@__instances__ ||= Set.new
|
68
|
+
end
|
69
|
+
|
70
|
+
def reindex_extensions(type)
|
71
|
+
__instances__.each do |instance|
|
72
|
+
instance.send(:reindex_extensions!, type)
|
73
|
+
end
|
74
|
+
true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
class MIME::Types
|
80
|
+
load_default_mime_types(load_mode) unless lazy_load?
|
81
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
##
|
2
|
+
module MIME
|
3
|
+
##
|
4
|
+
class Types
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'mime/type'
|
9
|
+
|
10
|
+
# MIME::Types is a registry of MIME types. It is both a class (created with
|
11
|
+
# MIME::Types.new) and a default registry (loaded automatically or through
|
12
|
+
# interactions with MIME::Types.[] and MIME::Types.type_for).
|
13
|
+
#
|
14
|
+
# == The Default mime-types Registry
|
15
|
+
#
|
16
|
+
# The default mime-types registry is loaded automatically when the library
|
17
|
+
# is required (<tt>require 'mime/types'</tt>), but it may be lazily loaded
|
18
|
+
# (loaded on first use) with the use of the environment variable
|
19
|
+
# +RUBY_MIME_TYPES_LAZY_LOAD+ having any value other than +false+. The
|
20
|
+
# initial startup is about 14× faster (~10 ms vs ~140 ms), but the
|
21
|
+
# registry will be loaded at some point in the future.
|
22
|
+
#
|
23
|
+
# The default mime-types registry can also be loaded from a Marshal cache
|
24
|
+
# file specific to the version of MIME::Types being loaded. This will be
|
25
|
+
# handled automatically with the use of a file referred to in the
|
26
|
+
# environment variable +RUBY_MIME_TYPES_CACHE+. MIME::Types will attempt to
|
27
|
+
# load the registry from this cache file (MIME::Type::Cache.load); if it
|
28
|
+
# cannot be loaded (because the file does not exist, there is an error, or
|
29
|
+
# the data is for a different version of mime-types), the default registry
|
30
|
+
# will be loaded from the normal JSON version and then the cache file will
|
31
|
+
# be *written* to the location indicated by +RUBY_MIME_TYPES_CACHE+. Cache
|
32
|
+
# file loads just over 4½× faster (~30 ms vs ~140 ms).
|
33
|
+
# loads.
|
34
|
+
#
|
35
|
+
# Notes:
|
36
|
+
# * The loading of the default registry is *not* atomic; when using a
|
37
|
+
# multi-threaded environment, it is recommended that lazy loading is not
|
38
|
+
# used and mime-types is loaded as early as possible.
|
39
|
+
# * Cache files should be specified per application in a multiprocess
|
40
|
+
# environment and should be initialized during deployment or before
|
41
|
+
# forking to minimize the chance that the multiple processes will be
|
42
|
+
# trying to write to the same cache file at the same time, or that two
|
43
|
+
# applications that are on different versions of mime-types would be
|
44
|
+
# thrashing the cache.
|
45
|
+
# * Unless cache files are preinitialized, the application using the
|
46
|
+
# mime-types cache file must have read/write permission to the cache file.
|
47
|
+
#
|
48
|
+
# == Usage
|
49
|
+
# require 'mime/types'
|
50
|
+
#
|
51
|
+
# plaintext = MIME::Types['text/plain']
|
52
|
+
# print plaintext.media_type # => 'text'
|
53
|
+
# print plaintext.sub_type # => 'plain'
|
54
|
+
#
|
55
|
+
# puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
|
56
|
+
#
|
57
|
+
# puts plaintext.encoding # => 8bit
|
58
|
+
# puts plaintext.binary? # => false
|
59
|
+
# puts plaintext.ascii? # => true
|
60
|
+
# puts plaintext.obsolete? # => false
|
61
|
+
# puts plaintext.registered? # => true
|
62
|
+
# puts plaintext == 'text/plain' # => true
|
63
|
+
# puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
64
|
+
#
|
65
|
+
class MIME::Types
|
66
|
+
# The release version of Ruby MIME::Types
|
67
|
+
VERSION = MIME::Type::VERSION
|
68
|
+
|
69
|
+
include Enumerable
|
70
|
+
|
71
|
+
# Creates a new MIME::Types registry.
|
72
|
+
def initialize
|
73
|
+
@type_variants = Container.new
|
74
|
+
@extension_index = Container.new
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns the number of known type variants.
|
78
|
+
def count
|
79
|
+
@type_variants.values.inject(0) { |a, e| a + e.size }
|
80
|
+
end
|
81
|
+
|
82
|
+
def inspect # :nodoc:
|
83
|
+
"#<#{self.class}: #{count} variants, #{@extension_index.count} extensions>"
|
84
|
+
end
|
85
|
+
|
86
|
+
# Iterates through the type variants.
|
87
|
+
def each
|
88
|
+
if block_given?
|
89
|
+
@type_variants.each_value { |tv| tv.each { |t| yield t } }
|
90
|
+
else
|
91
|
+
enum_for(:each)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
@__types__ = nil
|
96
|
+
|
97
|
+
# Returns a list of MIME::Type objects, which may be empty. The optional
|
98
|
+
# flag parameters are <tt>:complete</tt> (finds only complete MIME::Type
|
99
|
+
# objects) and <tt>:registered</tt> (finds only MIME::Types that are
|
100
|
+
# registered). It is possible for multiple matches to be returned for
|
101
|
+
# either type (in the example below, 'text/plain' returns two values --
|
102
|
+
# one for the general case, and one for VMS systems).
|
103
|
+
#
|
104
|
+
# puts "\nMIME::Types['text/plain']"
|
105
|
+
# MIME::Types['text/plain'].each { |t| puts t.to_a.join(", ") }
|
106
|
+
#
|
107
|
+
# puts "\nMIME::Types[/^image/, complete: true]"
|
108
|
+
# MIME::Types[/^image/, :complete => true].each do |t|
|
109
|
+
# puts t.to_a.join(", ")
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
# If multiple type definitions are returned, returns them sorted as
|
113
|
+
# follows:
|
114
|
+
# 1. Complete definitions sort before incomplete ones;
|
115
|
+
# 2. IANA-registered definitions sort before LTSW-recorded
|
116
|
+
# definitions.
|
117
|
+
# 3. Current definitions sort before obsolete ones;
|
118
|
+
# 4. Obsolete definitions with use-instead clauses sort before those
|
119
|
+
# without;
|
120
|
+
# 5. Obsolete definitions use-instead clauses are compared.
|
121
|
+
# 6. Sort on name.
|
122
|
+
def [](type_id, complete: false, registered: false)
|
123
|
+
matches = case type_id
|
124
|
+
when MIME::Type
|
125
|
+
@type_variants[type_id.simplified]
|
126
|
+
when Regexp
|
127
|
+
match(type_id)
|
128
|
+
else
|
129
|
+
@type_variants[MIME::Type.simplified(type_id)]
|
130
|
+
end
|
131
|
+
|
132
|
+
prune_matches(matches, complete, registered).sort { |a, b|
|
133
|
+
a.priority_compare(b)
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
# Return the list of MIME::Types which belongs to the file based on its
|
138
|
+
# filename extension. If there is no extension, the filename will be used
|
139
|
+
# as the matching criteria on its own.
|
140
|
+
#
|
141
|
+
# This will always return a merged, flatten, priority sorted, unique array.
|
142
|
+
#
|
143
|
+
# puts MIME::Types.type_for('citydesk.xml')
|
144
|
+
# => [application/xml, text/xml]
|
145
|
+
# puts MIME::Types.type_for('citydesk.gif')
|
146
|
+
# => [image/gif]
|
147
|
+
# puts MIME::Types.type_for(%w(citydesk.xml citydesk.gif))
|
148
|
+
# => [application/xml, image/gif, text/xml]
|
149
|
+
def type_for(filename)
|
150
|
+
Array(filename).flat_map { |fn|
|
151
|
+
@extension_index[fn.chomp.downcase[/\.?([^.]*?)$/, 1]]
|
152
|
+
}.compact.inject(:+).sort { |a, b|
|
153
|
+
a.priority_compare(b)
|
154
|
+
}
|
155
|
+
end
|
156
|
+
alias_method :of, :type_for
|
157
|
+
|
158
|
+
# Add one or more MIME::Type objects to the set of known types. If the
|
159
|
+
# type is already known, a warning will be displayed.
|
160
|
+
#
|
161
|
+
# The last parameter may be the value <tt>:silent</tt> or +true+ which
|
162
|
+
# will suppress duplicate MIME type warnings.
|
163
|
+
def add(*types)
|
164
|
+
quiet = ((types.last == :silent) or (types.last == true))
|
165
|
+
|
166
|
+
types.each do |mime_type|
|
167
|
+
case mime_type
|
168
|
+
when true, false, nil, Symbol
|
169
|
+
nil
|
170
|
+
when MIME::Types
|
171
|
+
variants = mime_type.instance_variable_get(:@type_variants)
|
172
|
+
add(*variants.values.inject(:+).to_a, quiet)
|
173
|
+
when Array
|
174
|
+
add(*mime_type, quiet)
|
175
|
+
else
|
176
|
+
add_type(mime_type, quiet)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# Add a single MIME::Type object to the set of known types. If the +type+ is
|
182
|
+
# already known, a warning will be displayed. The +quiet+ parameter may be a
|
183
|
+
# truthy value to suppress that warning.
|
184
|
+
def add_type(type, quiet = false)
|
185
|
+
if !quiet and @type_variants[type.simplified].include?(type)
|
186
|
+
MIME::Types.logger.warn <<-warning
|
187
|
+
Type #{type} is already registered as a variant of #{type.simplified}.
|
188
|
+
warning
|
189
|
+
end
|
190
|
+
|
191
|
+
add_type_variant!(type)
|
192
|
+
index_extensions!(type)
|
193
|
+
end
|
194
|
+
|
195
|
+
private
|
196
|
+
|
197
|
+
def add_type_variant!(mime_type)
|
198
|
+
@type_variants[mime_type.simplified] << mime_type
|
199
|
+
end
|
200
|
+
|
201
|
+
def reindex_extensions!(mime_type)
|
202
|
+
return unless @type_variants[mime_type.simplified].include?(mime_type)
|
203
|
+
index_extensions!(mime_type)
|
204
|
+
end
|
205
|
+
|
206
|
+
def index_extensions!(mime_type)
|
207
|
+
mime_type.extensions.each { |ext| @extension_index[ext] << mime_type }
|
208
|
+
end
|
209
|
+
|
210
|
+
def prune_matches(matches, complete, registered)
|
211
|
+
matches.delete_if { |e| !e.complete? } if complete
|
212
|
+
matches.delete_if { |e| !e.registered? } if registered
|
213
|
+
matches
|
214
|
+
end
|
215
|
+
|
216
|
+
def match(pattern)
|
217
|
+
@type_variants.select { |k, _|
|
218
|
+
k =~ pattern
|
219
|
+
}.values.inject(:+)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
require 'mime/types/cache'
|
224
|
+
require 'mime/types/container'
|
225
|
+
require 'mime/types/loader'
|
226
|
+
require 'mime/types/logger'
|
227
|
+
require 'mime/types/_columnar'
|
228
|
+
require 'mime/types/registry'
|
@@ -0,0 +1 @@
|
|
1
|
+
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
|