mime-types 1.17.2 → 3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.autotest +35 -0
- data/.gitignore +17 -0
- data/.hoerc +20 -12
- data/Code-of-Conduct.rdoc +41 -0
- data/Contributing.rdoc +169 -0
- data/History.rdoc +531 -30
- data/Licence.rdoc +25 -0
- data/Manifest.txt +32 -34
- data/README.rdoc +198 -13
- data/Rakefile +181 -159
- data/lib/mime/type/columnar.rb +55 -0
- data/lib/mime/type.rb +566 -0
- data/lib/mime/types/cache.rb +56 -0
- data/lib/mime/types/columnar.rb +142 -0
- data/lib/mime/types/container.rb +30 -0
- data/lib/mime/types/deprecations.rb +32 -0
- data/lib/mime/types/full.rb +17 -0
- data/lib/mime/types/loader.rb +148 -0
- data/lib/mime/types/logger.rb +37 -0
- data/lib/mime/types/registry.rb +81 -0
- data/lib/mime/types.rb +199 -819
- data/lib/mime-types.rb +1 -0
- data/support/benchmarks/load.rb +65 -0
- data/support/benchmarks/load_allocations.rb +90 -0
- data/support/benchmarks/object_counts.rb +43 -0
- data/support/profile/columnar.rb +5 -0
- data/support/profile/columnar_full.rb +5 -0
- data/support/profile/full.rb +5 -0
- data/test/bad-fixtures/malformed +9 -0
- data/test/fixture/json.json +1 -0
- data/test/fixture/old-data +9 -0
- data/test/fixture/yaml.yaml +55 -0
- data/test/minitest_helper.rb +12 -0
- data/test/test_mime_type.rb +527 -242
- data/test/test_mime_types.rb +130 -68
- data/test/test_mime_types_cache.rb +100 -0
- data/test/test_mime_types_class.rb +155 -0
- data/test/test_mime_types_lazy.rb +43 -0
- data/test/test_mime_types_loader.rb +32 -0
- metadata +286 -229
- data/License.rdoc +0 -10
- data/lib/mime/types/application +0 -940
- data/lib/mime/types/application.mac +0 -2
- data/lib/mime/types/application.nonstandard +0 -114
- data/lib/mime/types/application.obsolete +0 -40
- data/lib/mime/types/audio +0 -131
- data/lib/mime/types/audio.nonstandard +0 -10
- data/lib/mime/types/audio.obsolete +0 -1
- data/lib/mime/types/image +0 -43
- data/lib/mime/types/image.nonstandard +0 -17
- data/lib/mime/types/image.obsolete +0 -5
- data/lib/mime/types/message +0 -19
- data/lib/mime/types/message.obsolete +0 -1
- data/lib/mime/types/model +0 -15
- data/lib/mime/types/multipart +0 -14
- data/lib/mime/types/multipart.nonstandard +0 -1
- data/lib/mime/types/multipart.obsolete +0 -7
- data/lib/mime/types/other.nonstandard +0 -8
- data/lib/mime/types/text +0 -54
- data/lib/mime/types/text.nonstandard +0 -5
- data/lib/mime/types/text.obsolete +0 -7
- data/lib/mime/types/text.vms +0 -1
- data/lib/mime/types/video +0 -68
- data/lib/mime/types/video.nonstandard +0 -11
- data/lib/mime/types/video.obsolete +0 -3
- data/mime-types.gemspec +0 -57
- data/type-lists/application.txt +0 -951
- data/type-lists/audio.txt +0 -132
- data/type-lists/image.txt +0 -43
- data/type-lists/message.txt +0 -20
- data/type-lists/model.txt +0 -15
- data/type-lists/multipart.txt +0 -14
- data/type-lists/text.txt +0 -57
- data/type-lists/video.txt +0 -67
data/Manifest.txt
CHANGED
@@ -1,42 +1,40 @@
|
|
1
|
+
.autotest
|
2
|
+
.gemtest
|
3
|
+
.gitignore
|
1
4
|
.hoerc
|
5
|
+
Code-of-Conduct.rdoc
|
6
|
+
Contributing.rdoc
|
2
7
|
History.rdoc
|
3
|
-
|
8
|
+
Licence.rdoc
|
4
9
|
Manifest.txt
|
5
10
|
README.rdoc
|
6
11
|
Rakefile
|
12
|
+
lib/mime-types.rb
|
13
|
+
lib/mime/type.rb
|
14
|
+
lib/mime/type/columnar.rb
|
7
15
|
lib/mime/types.rb
|
8
|
-
lib/mime/types/
|
9
|
-
lib/mime/types/
|
10
|
-
lib/mime/types/
|
11
|
-
lib/mime/types/
|
12
|
-
lib/mime/types/
|
13
|
-
lib/mime/types/
|
14
|
-
lib/mime/types/
|
15
|
-
lib/mime/types/
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
lib/mime/types/text.obsolete
|
28
|
-
lib/mime/types/text.vms
|
29
|
-
lib/mime/types/video
|
30
|
-
lib/mime/types/video.nonstandard
|
31
|
-
lib/mime/types/video.obsolete
|
32
|
-
mime-types.gemspec
|
16
|
+
lib/mime/types/cache.rb
|
17
|
+
lib/mime/types/columnar.rb
|
18
|
+
lib/mime/types/container.rb
|
19
|
+
lib/mime/types/deprecations.rb
|
20
|
+
lib/mime/types/full.rb
|
21
|
+
lib/mime/types/loader.rb
|
22
|
+
lib/mime/types/logger.rb
|
23
|
+
lib/mime/types/registry.rb
|
24
|
+
support/benchmarks/load.rb
|
25
|
+
support/benchmarks/load_allocations.rb
|
26
|
+
support/benchmarks/object_counts.rb
|
27
|
+
support/profile/columnar.rb
|
28
|
+
support/profile/columnar_full.rb
|
29
|
+
support/profile/full.rb
|
30
|
+
test/bad-fixtures/malformed
|
31
|
+
test/fixture/json.json
|
32
|
+
test/fixture/old-data
|
33
|
+
test/fixture/yaml.yaml
|
34
|
+
test/minitest_helper.rb
|
33
35
|
test/test_mime_type.rb
|
34
36
|
test/test_mime_types.rb
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
type-lists/model.txt
|
40
|
-
type-lists/multipart.txt
|
41
|
-
type-lists/text.txt
|
42
|
-
type-lists/video.txt
|
37
|
+
test/test_mime_types_cache.rb
|
38
|
+
test/test_mime_types_class.rb
|
39
|
+
test/test_mime_types_lazy.rb
|
40
|
+
test/test_mime_types_loader.rb
|
data/README.rdoc
CHANGED
@@ -1,19 +1,204 @@
|
|
1
|
-
=
|
1
|
+
= mime-types for Ruby
|
2
|
+
|
3
|
+
home :: https://github.com/mime-types/ruby-mime-types/
|
4
|
+
code :: https://github.com/mime-types/ruby-mime-types/
|
5
|
+
bugs :: https://github.com/mime-types/ruby-mime-types/issues
|
6
|
+
rdoc :: http://rdoc.info/gems/mime-types/
|
7
|
+
continuous integration :: {<img src="https://travis-ci.org/mime-types/ruby-mime-types.png" />}[https://travis-ci.org/mime-types/ruby-mime-types]
|
8
|
+
test coverage :: {<img src="https://coveralls.io/repos/mime-types/ruby-mime-types/badge.png" alt="Coverage Status" />}[https://coveralls.io/r/mime-types/ruby-mime-types]
|
2
9
|
|
3
10
|
== Description
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
12
|
+
The mime-types library provides a library and registry for information about
|
13
|
+
MIME content type definitions. It can be used to determine defined filename
|
14
|
+
extensions for MIME types, or to use filename extensions to look up the likely
|
15
|
+
MIME type definitions.
|
16
|
+
|
17
|
+
Version 3.0 is a major release that requires Ruby 2.0 compatibility and removes
|
18
|
+
deprecated functions. The columnar registry format introduced in 2.6 has been
|
19
|
+
made the primary format; the registry data has been extracted from this library
|
20
|
+
and put into {mime-types-data}[https://github.com/mime-types/mime-types-data].
|
21
|
+
Additionally, mime-types is now licensed exclusively under the MIT licence and
|
22
|
+
there is a code of conduct in effect. There are a number of other smaller
|
23
|
+
changes described in the History file.
|
24
|
+
|
25
|
+
=== About MIME Media Types
|
26
|
+
|
27
|
+
MIME content types are used in MIME-compliant communications, as in e-mail or
|
28
|
+
HTTP traffic, to indicate the type of content which is transmitted. The
|
29
|
+
mime-types library provides the ability for detailed information about MIME
|
30
|
+
entities (provided as an enumerable collection of MIME::Type objects) to be
|
31
|
+
determined and used. There are many types defined by RFCs and vendors, so the
|
32
|
+
list is long but by definition incomplete; don't hesitate to add additional
|
33
|
+
type definitions. MIME type definitions found in mime-types are from RFCs, W3C
|
34
|
+
recommendations, the {IANA Media Types
|
35
|
+
registry}[https://www.iana.org/assignments/media-types/media-types.xhtml], and
|
36
|
+
user contributions. It conforms to RFCs 2045 and 2231.
|
37
|
+
|
38
|
+
=== mime-types 1.x End of Life
|
39
|
+
|
40
|
+
mime-types 1.x is no longer supported as of 2015-10-27.
|
41
|
+
|
42
|
+
=== mime-types 2.x End of Life
|
43
|
+
|
44
|
+
mime-types 2.x is supported as 2.99.x receiving quarterly updates of the IANA
|
45
|
+
registry and security updates for two years. It will reach full end of life on
|
46
|
+
2017-11-21.
|
47
|
+
|
48
|
+
=== mime-types 3.x
|
49
|
+
|
50
|
+
Users are encouraged to upgrade to mime-types 3.x as soon as is practical.
|
51
|
+
mime-types 3.x requires Ruby 2.0 compatibility and a simpler licensing scheme.
|
52
|
+
|
53
|
+
== Synopsis
|
54
|
+
|
55
|
+
MIME types are used in MIME entities, as in email or HTTP traffic. It is useful
|
56
|
+
at times to have information available about MIME types (or, inversely, about
|
57
|
+
files). A MIME::Type stores the known information about one MIME type.
|
58
|
+
|
59
|
+
require 'mime/types'
|
60
|
+
|
61
|
+
plaintext = MIME::Types['text/plain'] # => [ text/plain ]
|
62
|
+
text = plaintext.first
|
63
|
+
puts text.media_type # => 'text'
|
64
|
+
puts text.sub_type # => 'plain'
|
65
|
+
|
66
|
+
puts text.extensions.join(' ') # => 'txt asc c cc h hh cpp hpp dat hlp'
|
67
|
+
puts text.preferred_extension # => 'txt'
|
68
|
+
puts text.friendly # => 'Text Document'
|
69
|
+
puts text.i18n_key # => 'text.plain'
|
70
|
+
|
71
|
+
puts text.encoding # => quoted-printable
|
72
|
+
puts text.default_encoding # => quoted-printable
|
73
|
+
puts text.binary? # => false
|
74
|
+
puts text.ascii? # => true
|
75
|
+
puts text.obsolete? # => false
|
76
|
+
puts text.registered? # => true
|
77
|
+
puts text.complete? # => true
|
78
|
+
|
79
|
+
puts text # => 'text/plain'
|
80
|
+
|
81
|
+
puts text == 'text/plain' # => true
|
82
|
+
puts 'text/plain' == text # => true
|
83
|
+
puts text == 'text/x-plain' # => false
|
84
|
+
puts 'text/x-plain' == text # => false
|
85
|
+
|
86
|
+
puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
87
|
+
puts MIME::Type.i18n_key('x-appl/x-zip') # => 'appl.zip'
|
88
|
+
|
89
|
+
puts text.like?('text/x-plain') # => true
|
90
|
+
puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
|
91
|
+
|
92
|
+
puts text.xrefs.inspect # => { "rfc" => [ "rfc2046", "rfc3676", "rfc5147" ] }
|
93
|
+
puts text.xref_urls # => [ "http://www.iana.org/go/rfc2046",
|
94
|
+
# "http://www.iana.org/go/rfc3676",
|
95
|
+
# "http://www.iana.org/go/rfc5147" ]
|
96
|
+
|
97
|
+
xtext = MIME::Type.new('x-text/x-plain')
|
98
|
+
puts xtext.media_type # => 'text'
|
99
|
+
puts xtext.raw_media_type # => 'x-text'
|
100
|
+
puts xtext.sub_type # => 'plain'
|
101
|
+
puts xtext.raw_sub_type # => 'x-plain'
|
102
|
+
puts xtext.complete? # => false
|
103
|
+
|
104
|
+
puts MIME::Types.any? { |type| type.content_type == 'text/plain' } # => true
|
105
|
+
puts MIME::Types.all?(&:registered?) # => false
|
106
|
+
|
107
|
+
# Various string representations of MIME types
|
108
|
+
qcelp = MIME::Types['audio/QCELP'].first # => audio/QCELP
|
109
|
+
puts qcelp.content_type # => 'audio/QCELP'
|
110
|
+
puts qcelp.simplified # => 'audio/qcelp'
|
111
|
+
|
112
|
+
xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
|
113
|
+
puts xwingz.content_type # => 'application/x-Wingz'
|
114
|
+
puts xwingz.simplified # => 'application/wingz'
|
115
|
+
|
116
|
+
=== Columnar Store
|
117
|
+
|
118
|
+
mime-types uses as its primary registry storage format a columnar storage
|
119
|
+
format reducing the default memory footprint. This is done by selectively
|
120
|
+
loading the data on a per-attribute basis. When the registry is first loaded
|
121
|
+
from the columnar store, only the canonical MIME content type and known
|
122
|
+
extensions and the MIME type will be connected to its loading registry. When
|
123
|
+
other data about the type is required (including +preferred_extension+,
|
124
|
+
<tt>obsolete?</tt>, and <tt>registered?</tt>) that data is loaded from its own
|
125
|
+
column file for all types in the registry.
|
126
|
+
|
127
|
+
The load of any column data is performed with a Mutex to ensure that types are
|
128
|
+
updated safely in a multithreaded environment. Benchmarks show that while
|
129
|
+
columnar data loading is slower than the JSON store, it cuts the memory use by
|
130
|
+
a third over the JSON store.
|
131
|
+
|
132
|
+
If you prefer to load all the data at once, this can be specified in your
|
133
|
+
application Gemfile as:
|
134
|
+
|
135
|
+
gem 'mime-types', require: 'mime/types/full'
|
136
|
+
|
137
|
+
Projects that do not use Bundler should +require+ the same:
|
138
|
+
|
139
|
+
require 'mime/types/full'
|
140
|
+
|
141
|
+
Libraries that use mime-types are discouraged from choosing the JSON store.
|
142
|
+
|
143
|
+
For applications and clients that used mime-types 2.6 when the columnar store
|
144
|
+
was introduced, the require used previously will still work through at least
|
145
|
+
{version
|
146
|
+
4}[https://github.com/mime-types/ruby-mime-types/pull/96#issuecomment-100725400]
|
147
|
+
and possibly beyond; it is effectively an empty operation. You are recommended
|
148
|
+
to change your Gemfile as soon as is practical.
|
149
|
+
|
150
|
+
require 'mime/types/columnar'
|
151
|
+
|
152
|
+
Note that MIME::Type::Columnar and MIME::Types::Columnar are considered private
|
153
|
+
variant implementations of MIME::Type and MIME::Types and the specific
|
154
|
+
implementation should not be relied upon by consumers of the mime-types
|
155
|
+
library. Instead, depend on the public implementations (MIME::Type and
|
156
|
+
MIME::Types) only.
|
157
|
+
|
158
|
+
=== Cached Storage
|
159
|
+
|
160
|
+
mime-types supports a cache of MIME types using <tt>Marshal.dump</tt>. The
|
161
|
+
cache is invalidated for each version of the mime-types-data gem so that data
|
162
|
+
version 3.2015.1201 will not be reused with data version 3.2016.0101. If the
|
163
|
+
environment variable +RUBY_MIME_TYPES_CACHE+ is set to a cache file, mime-types
|
164
|
+
will attempt to load the MIME type registry from the cache file. If it cannot,
|
165
|
+
it will load the types normally and then saves the registry to the cache file.
|
166
|
+
|
167
|
+
The caching works with both full stores and columnar stores. Only the data that
|
168
|
+
has been loaded prior to saving the cache will be stored.
|
169
|
+
|
170
|
+
== mime-types Modified Semantic Versioning
|
171
|
+
|
172
|
+
The mime-types library has one version number, but this single version number
|
173
|
+
tracks both API changes and registry data changes; this is not wholly
|
174
|
+
compatible with all aspects of {Semantic Versioning}[http://semver.org/];
|
175
|
+
removing a MIME type from the registry *could* be considered a breaking change
|
176
|
+
under some interpretations of semantic versioning (as lookups for that
|
177
|
+
particular type would no longer work by default).
|
178
|
+
|
179
|
+
mime-types uses a modified semantic versioning scheme. Given the version
|
180
|
+
MAJOR.MINOR:
|
181
|
+
|
182
|
+
1. If an incompatible API (code) change is made, the MAJOR version will be
|
183
|
+
incremented, MINOR will be set to zero, and PATCH will be reset to the
|
184
|
+
implied zero.
|
185
|
+
|
186
|
+
2. If an API (code) feature is added that does not break compatibilty OR if
|
187
|
+
there are MIME types added, removed, or changed in the registry, the MINOR
|
188
|
+
version will be incremented and PATCH will be reset to the implied zero.
|
189
|
+
|
190
|
+
3. If there is a bugfix to a feature added in the most recent MAJOR.MINOR
|
191
|
+
release, OR if purely typographical errors are fixed in MIME types, the
|
192
|
+
implied PATCH value will be incremented resulting in MAJOR.MINOR.PATCH.
|
193
|
+
|
194
|
+
In practical terms, there should be a MINOR release roughly monthly to track
|
195
|
+
updated or changed MIME types from the official IANA registry. This does not
|
196
|
+
indicate when new API features have been added, but all minor versions of
|
197
|
+
mime-types 2.x will be backwards compatible; the interfaces marked deprecated
|
198
|
+
will be removed in mime-types 3.x.
|
8
199
|
|
9
|
-
|
10
|
-
Perl by Mark Overmeer, copyright 2001 - 2009. As of version 1.15, the data
|
11
|
-
format for the MIME::Type list has changed and the synchronization will no
|
12
|
-
longer happen.
|
200
|
+
:include: Code-of-Conduct.rdoc
|
13
201
|
|
14
|
-
|
15
|
-
GitHub:: http://github.com/halostatue/mime-types/
|
16
|
-
Copyright:: 2002 - 2011, Austin Ziegler
|
17
|
-
Based in part on prior work copyright Mark Overmeer
|
202
|
+
:include: Contributing.rdoc
|
18
203
|
|
19
|
-
:include:
|
204
|
+
:include: Licence.rdoc
|
data/Rakefile
CHANGED
@@ -2,197 +2,219 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'hoe'
|
5
|
+
require 'rake/clean'
|
5
6
|
|
6
7
|
Hoe.plugin :doofus
|
7
|
-
Hoe.plugin :
|
8
|
-
Hoe.plugin :rubyforge
|
8
|
+
Hoe.plugin :gemspec2
|
9
9
|
Hoe.plugin :git
|
10
10
|
Hoe.plugin :minitest
|
11
|
+
Hoe.plugin :travis
|
12
|
+
Hoe.plugin :email unless ENV['CI'] or ENV['TRAVIS']
|
11
13
|
|
12
14
|
spec = Hoe.spec 'mime-types' do
|
13
|
-
|
15
|
+
developer('Austin Ziegler', 'halostatue@gmail.com')
|
16
|
+
self.need_tar = true
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
self.url = "http://mime-types.rubyforge.org/"
|
18
|
-
self.remote_rdoc_dir = 'rdoc'
|
19
|
-
self.rsync_args << ' --exclude=statsvn/'
|
18
|
+
require_ruby_version '>= 2.0'
|
20
19
|
|
21
20
|
self.history_file = 'History.rdoc'
|
22
21
|
self.readme_file = 'README.rdoc'
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
|
23
|
+
license 'MIT'
|
24
|
+
|
25
|
+
extra_deps << ['mime-types-data', '~> 3.2015']
|
26
|
+
|
27
|
+
extra_dev_deps << ['hoe-doofus', '~> 1.0']
|
28
|
+
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
29
|
+
extra_dev_deps << ['hoe-git', '~> 1.6']
|
30
|
+
extra_dev_deps << ['hoe-rubygems', '~> 1.0']
|
31
|
+
extra_dev_deps << ['hoe-travis', '~> 1.2']
|
32
|
+
extra_dev_deps << ['minitest', '~> 5.4']
|
33
|
+
extra_dev_deps << ['minitest-autotest', '~> 1.0']
|
34
|
+
extra_dev_deps << ['minitest-focus', '~> 1.0']
|
35
|
+
extra_dev_deps << ['minitest-bonus-assertions', '~> 2.0']
|
36
|
+
extra_dev_deps << ['rake', '~> 10.0']
|
37
|
+
extra_dev_deps << ['fivemat', '~> 1.3' ]
|
38
|
+
extra_dev_deps << ['minitest-rg', '~> 5.2']
|
39
|
+
|
40
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0')
|
41
|
+
extra_dev_deps << ['simplecov', '~> 0.7']
|
42
|
+
# if ENV['CI'] or ENV['TRAVIS']
|
43
|
+
# extra_dev_deps << ['coveralls', '~> 0.8']
|
44
|
+
# end
|
45
|
+
end
|
31
46
|
end
|
32
47
|
|
33
|
-
namespace :
|
34
|
-
|
35
|
-
|
36
|
-
|
48
|
+
namespace :benchmark do
|
49
|
+
task :support do
|
50
|
+
%w(lib support).each { |path|
|
51
|
+
$LOAD_PATH.unshift(File.join(Rake.application.original_dir, path))
|
52
|
+
}
|
53
|
+
end
|
37
54
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
55
|
+
desc 'Benchmark Load Times'
|
56
|
+
task :load, [ :repeats ] => 'benchmark:support' do |_, args|
|
57
|
+
require 'benchmarks/load'
|
58
|
+
Benchmarks::Load.report(
|
59
|
+
File.join(Rake.application.original_dir, 'lib'),
|
60
|
+
args.repeats
|
61
|
+
)
|
62
|
+
end
|
44
63
|
|
45
|
-
|
64
|
+
desc 'Allocation counts'
|
65
|
+
task :allocations, [ :top_x, :mime_types_only ] => 'benchmark:support' do |_, args|
|
66
|
+
require 'benchmarks/load_allocations'
|
67
|
+
Benchmarks::LoadAllocations.report(
|
68
|
+
top_x: args.top_x,
|
69
|
+
mime_types_only: args.mime_types_only
|
70
|
+
)
|
71
|
+
end
|
46
72
|
|
47
|
-
|
48
|
-
|
49
|
-
require '
|
73
|
+
desc 'Columnar allocation counts'
|
74
|
+
task 'allocations:columnar', [ :top_x, :mime_types_only ] => 'benchmark:support' do |_, args|
|
75
|
+
require 'benchmarks/load_allocations'
|
76
|
+
Benchmarks::LoadAllocations.report(
|
77
|
+
columnar: true,
|
78
|
+
top_x: args.top_x,
|
79
|
+
mime_types_only: args.mime_types_only
|
80
|
+
)
|
81
|
+
end
|
50
82
|
|
51
|
-
|
52
|
-
|
83
|
+
desc 'Columnar allocation counts (full load)'
|
84
|
+
task 'allocations:columnar:full', [ :top_x, :mime_types_only ] => 'benchmark:support' do |_, args|
|
85
|
+
require 'benchmarks/load_allocations'
|
86
|
+
Benchmarks::LoadAllocations.report(
|
87
|
+
columnar: true,
|
88
|
+
top_x: args.top_x,
|
89
|
+
mime_types_only: args.mime_types_only,
|
90
|
+
full: true
|
91
|
+
)
|
92
|
+
end
|
53
93
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
94
|
+
desc 'Object counts'
|
95
|
+
task objects: 'benchmark:support' do
|
96
|
+
require 'benchmarks/object_counts'
|
97
|
+
Benchmarks::ObjectCounts.report
|
98
|
+
end
|
59
99
|
|
60
|
-
|
61
|
-
|
62
|
-
|
100
|
+
desc 'Columnar object counts'
|
101
|
+
task 'objects:columnar' => 'benchmark:support' do
|
102
|
+
require 'benchmarks/object_counts'
|
103
|
+
Benchmarks::ObjectCounts.report(columnar: true)
|
104
|
+
end
|
63
105
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
106
|
+
desc 'Columnar object counts (full load)'
|
107
|
+
task 'objects:columnar:full' => 'benchmark:support' do
|
108
|
+
require 'benchmarks/object_counts'
|
109
|
+
Benchmarks::ObjectCounts.report(columnar: true, full: true)
|
110
|
+
end
|
111
|
+
end
|
71
112
|
|
72
|
-
|
73
|
-
|
113
|
+
namespace :profile do
|
114
|
+
directory 'tmp/profile'
|
115
|
+
|
116
|
+
CLEAN.add 'tmp'
|
117
|
+
|
118
|
+
def ruby_prof(script)
|
119
|
+
require 'pathname'
|
120
|
+
output = Pathname('tmp/profile').join(script)
|
121
|
+
output.mkpath
|
122
|
+
script = Pathname('support/profile').join("#{script}.rb")
|
123
|
+
|
124
|
+
args = [
|
125
|
+
'-W0',
|
126
|
+
'-Ilib',
|
127
|
+
'-S', 'ruby-prof',
|
128
|
+
'-R', 'mime/types',
|
129
|
+
'-s', 'self',
|
130
|
+
'-p', 'multi',
|
131
|
+
'-f', "#{output}",
|
132
|
+
script.to_s
|
133
|
+
]
|
134
|
+
ruby args.join(' ')
|
135
|
+
end
|
74
136
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@url = File.join(INDEX, @type)
|
79
|
-
end
|
137
|
+
task full: 'tmp/profile' do
|
138
|
+
ruby_prof 'full'
|
139
|
+
end
|
80
140
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
attr_reader :html
|
141
|
+
task columnar: :support do
|
142
|
+
ruby_prof 'columnar'
|
143
|
+
end
|
85
144
|
|
86
|
-
|
87
|
-
|
88
|
-
|
145
|
+
task 'columnar:full' => :support do
|
146
|
+
ruby_prof 'columnar_full'
|
147
|
+
end
|
148
|
+
end
|
89
149
|
|
90
|
-
|
91
|
-
|
92
|
-
|
150
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0')
|
151
|
+
namespace :test do
|
152
|
+
# Coveralls needs to be disabled for now because it transitively depends on
|
153
|
+
# an earlier version of mime-types.
|
154
|
+
# if ENV['CI'] or ENV['TRAVIS']
|
155
|
+
# task :coveralls do
|
156
|
+
# spec.test_prelude = [
|
157
|
+
# 'require "psych"',
|
158
|
+
# 'require "simplecov"',
|
159
|
+
# 'require "coveralls"',
|
160
|
+
# 'SimpleCov.formatter = Coveralls::SimpleCov::Formatter',
|
161
|
+
# 'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
|
162
|
+
# 'gem "minitest"'
|
163
|
+
# ].join('; ')
|
164
|
+
# Rake::Task['test'].execute
|
165
|
+
# end
|
166
|
+
|
167
|
+
# Rake::Task['travis'].prerequisites.replace(%w(test:coveralls))
|
168
|
+
# end
|
169
|
+
|
170
|
+
desc 'Run test coverage'
|
171
|
+
task :coverage do
|
172
|
+
spec.test_prelude = [
|
173
|
+
'require "simplecov"',
|
174
|
+
'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
|
175
|
+
'gem "minitest"'
|
176
|
+
].join('; ')
|
177
|
+
Rake::Task['test'].execute
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
93
181
|
|
94
|
-
|
95
|
-
|
96
|
-
|
182
|
+
namespace :convert do
|
183
|
+
namespace :docs do
|
184
|
+
task :setup do
|
185
|
+
gem 'rdoc'
|
186
|
+
require 'rdoc/rdoc'
|
187
|
+
@doc_converter ||= RDoc::Markup::ToMarkdown.new
|
188
|
+
end
|
97
189
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# How many <td> children does the first node have?
|
102
|
-
node_count = nodes.first.children.select { |n| n.elem? }.size
|
103
|
-
|
104
|
-
if node_count == 1
|
105
|
-
# The title node doesn't have what we expect. Let's try it based
|
106
|
-
# on the first real node.
|
107
|
-
node_count = nodes.first.next.children.select { |n| n.elem? }.size
|
108
|
-
end
|
109
|
-
|
110
|
-
@mime_types = nodes.map do |node|
|
111
|
-
next if node == nodes.first
|
112
|
-
elems = node.children.select { |n| n.elem? }
|
113
|
-
next if elems.size.zero?
|
114
|
-
|
115
|
-
raise "size mismatch #{elems.size} != #{node_count}" if node_count != elems.size
|
116
|
-
|
117
|
-
case elems.size
|
118
|
-
when 3
|
119
|
-
subtype_index = 1
|
120
|
-
refnode_index = 2
|
121
|
-
when 4
|
122
|
-
subtype_index = 1
|
123
|
-
refnode_index = 3
|
124
|
-
else
|
125
|
-
raise "Unknown element size."
|
126
|
-
end
|
127
|
-
|
128
|
-
subtype = elems[subtype_index].content.chomp.strip
|
129
|
-
refnodes = elems[refnode_index].children.select { |n| n.elem? }.map { |ref|
|
130
|
-
case ref['href']
|
131
|
-
when CONTACT_PEOPLE
|
132
|
-
tag = CGI::unescape($1).chomp.strip
|
133
|
-
if tag == ref.content
|
134
|
-
"[#{ref.content}]"
|
135
|
-
else
|
136
|
-
"[#{ref.content}=#{tag}]"
|
137
|
-
end
|
138
|
-
when RFC_EDITOR, IETF_RFC, IETF_RFC_TOOLS
|
139
|
-
"RFC#$1"
|
140
|
-
when %r{(https?://.*)}
|
141
|
-
"{#{ref.content}=#$1}"
|
142
|
-
else
|
143
|
-
ref
|
144
|
-
end
|
145
|
-
}
|
146
|
-
refs = refnodes.join(',')
|
147
|
-
|
148
|
-
"#@type/#{subtype} 'IANA,#{refs}"
|
149
|
-
end.compact
|
150
|
-
|
151
|
-
@mime_types
|
152
|
-
end
|
190
|
+
FileList['*.rdoc'].each do |name|
|
191
|
+
rdoc = "#{name}.rdoc"
|
192
|
+
mark = "#{name}.md"
|
153
193
|
|
154
|
-
|
155
|
-
|
194
|
+
file mark => [ rdoc, :setup ] do |t|
|
195
|
+
puts "#{rdoc} => #{mark}"
|
196
|
+
File.open(t.name, 'wb') { |target|
|
197
|
+
target.write @doc_converter.convert(IO.read(t.prerequisites.first))
|
198
|
+
}
|
156
199
|
end
|
157
|
-
end
|
158
200
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
require 'fileutils'
|
163
|
-
FileUtils.mkdir_p destination
|
164
|
-
Dir.chdir destination do
|
165
|
-
IANAParser.types.values.sort.each do |parser|
|
166
|
-
next if parser.name == "example" or parser.name == "mime"
|
167
|
-
puts "Downloading #{parser.name} from #{parser.url}"
|
168
|
-
parser.download
|
169
|
-
|
170
|
-
if :html == save_type || :both == save_type
|
171
|
-
puts "Saving #{parser.name}.html"
|
172
|
-
parser.save_html
|
173
|
-
end
|
174
|
-
|
175
|
-
puts "Parsing #{parser.name} HTML"
|
176
|
-
parser.parse
|
177
|
-
|
178
|
-
if :text == save_type || :both == save_type
|
179
|
-
puts "Saving #{parser.name}.txt"
|
180
|
-
parser.save_text
|
181
|
-
end
|
182
|
-
end
|
201
|
+
CLEAN.add mark
|
202
|
+
|
203
|
+
task run: [ mark ]
|
183
204
|
end
|
184
205
|
end
|
185
206
|
|
186
|
-
desc
|
187
|
-
task :
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
207
|
+
desc 'Convert documentation from RDoc to Markdown'
|
208
|
+
task docs: 'convert:docs:run'
|
209
|
+
end
|
210
|
+
|
211
|
+
task :console do
|
212
|
+
arguments = %w(pry)
|
213
|
+
arguments.push(*spec.spec.require_paths.map { |dir| "-I#{dir}" })
|
214
|
+
arguments.push("-r#{spec.spec.name.gsub('-', File::SEPARATOR)}")
|
215
|
+
unless system(*arguments)
|
216
|
+
error "Command failed: #{show_command}"
|
217
|
+
abort
|
196
218
|
end
|
197
219
|
end
|
198
220
|
|