mime-types 2.99.3 → 3.3.1
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 +5 -5
- data/{Code-of-Conduct.rdoc → Code-of-Conduct.md} +19 -20
- data/Contributing.md +143 -0
- data/History.md +240 -0
- data/{Licence.rdoc → Licence.md} +4 -18
- data/Manifest.txt +8 -25
- data/README.rdoc +62 -73
- data/Rakefile +175 -58
- data/lib/mime-types.rb +1 -1
- data/lib/mime/type.rb +213 -424
- data/lib/mime/type/columnar.rb +29 -62
- data/lib/mime/types.rb +46 -141
- data/lib/mime/types/_columnar.rb +136 -0
- data/lib/mime/types/cache.rb +51 -73
- data/lib/mime/types/columnar.rb +2 -147
- data/lib/mime/types/container.rb +96 -0
- data/lib/mime/types/deprecations.rb +4 -25
- data/lib/mime/types/full.rb +19 -0
- data/lib/mime/types/loader.rb +12 -141
- data/lib/mime/types/logger.rb +5 -1
- data/lib/mime/types/registry.rb +90 -0
- data/test/minitest_helper.rb +5 -13
- data/test/test_mime_type.rb +470 -456
- data/test/test_mime_types.rb +135 -87
- data/test/test_mime_types_cache.rb +82 -54
- data/test/test_mime_types_class.rb +118 -98
- data/test/test_mime_types_lazy.rb +26 -24
- data/test/test_mime_types_loader.rb +6 -33
- metadata +107 -64
- data/Contributing.rdoc +0 -170
- data/History-Types.rdoc +0 -454
- data/History.rdoc +0 -590
- data/data/mime-types.json +0 -1
- data/data/mime.content_type.column +0 -1980
- data/data/mime.docs.column +0 -1980
- data/data/mime.encoding.column +0 -1980
- data/data/mime.friendly.column +0 -1980
- data/data/mime.obsolete.column +0 -1980
- data/data/mime.registered.column +0 -1980
- data/data/mime.signature.column +0 -1980
- data/data/mime.use_instead.column +0 -1980
- data/data/mime.xrefs.column +0 -1980
- data/docs/COPYING.txt +0 -339
- data/docs/artistic.txt +0 -127
- data/lib/mime/types/loader_path.rb +0 -15
- data/support/apache_mime_types.rb +0 -108
- data/support/benchmarks/load.rb +0 -64
- data/support/benchmarks/load_allocations.rb +0 -83
- data/support/benchmarks/object_counts.rb +0 -41
- data/support/convert.rb +0 -158
- data/support/convert/columnar.rb +0 -88
- data/support/iana_registry.rb +0 -172
data/{Licence.rdoc → Licence.md}
RENAMED
@@ -1,18 +1,10 @@
|
|
1
|
-
|
1
|
+
## Licence
|
2
2
|
|
3
|
-
|
4
|
-
your option, a later version), the Perl Artistic License, or the MIT License.
|
5
|
-
The licence preferred by me is the MIT licence.
|
3
|
+
* Copyright 2003–2019 Austin Ziegler and contributors.
|
6
4
|
|
7
|
-
The
|
8
|
-
Artistic Licence and the GNU GPL ("the same terms as Perl itself") and given
|
9
|
-
that the Ruby implementation originally hewed pretty closely to the Perl
|
10
|
-
version, I chose to maintain the additional licensing terms.
|
5
|
+
The software in this repository is made available under the MIT license.
|
11
6
|
|
12
|
-
|
13
|
-
* Adapted from MIME::Types (Perl) by Mark Overmeer.
|
14
|
-
|
15
|
-
=== MIT License
|
7
|
+
### MIT License
|
16
8
|
|
17
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
18
10
|
this software and associated documentation files (the "Software"), to deal in
|
@@ -31,9 +23,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
23
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
32
24
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
33
25
|
SOFTWARE.
|
34
|
-
|
35
|
-
=== Perl Artistic License (version 2)
|
36
|
-
See the file docs/artistic.txt in the main distribution.
|
37
|
-
|
38
|
-
=== GNU GPL version 2
|
39
|
-
See the file docs/COPYING.txt in the main distribution.
|
data/Manifest.txt
CHANGED
@@ -1,40 +1,23 @@
|
|
1
|
-
Code-of-Conduct.
|
2
|
-
Contributing.
|
3
|
-
History
|
4
|
-
|
5
|
-
Licence.rdoc
|
1
|
+
Code-of-Conduct.md
|
2
|
+
Contributing.md
|
3
|
+
History.md
|
4
|
+
Licence.md
|
6
5
|
Manifest.txt
|
7
6
|
README.rdoc
|
8
7
|
Rakefile
|
9
|
-
data/mime-types.json
|
10
|
-
data/mime.content_type.column
|
11
|
-
data/mime.docs.column
|
12
|
-
data/mime.encoding.column
|
13
|
-
data/mime.friendly.column
|
14
|
-
data/mime.obsolete.column
|
15
|
-
data/mime.registered.column
|
16
|
-
data/mime.signature.column
|
17
|
-
data/mime.use_instead.column
|
18
|
-
data/mime.xrefs.column
|
19
|
-
docs/COPYING.txt
|
20
|
-
docs/artistic.txt
|
21
8
|
lib/mime-types.rb
|
22
9
|
lib/mime/type.rb
|
23
10
|
lib/mime/type/columnar.rb
|
24
11
|
lib/mime/types.rb
|
12
|
+
lib/mime/types/_columnar.rb
|
25
13
|
lib/mime/types/cache.rb
|
26
14
|
lib/mime/types/columnar.rb
|
15
|
+
lib/mime/types/container.rb
|
27
16
|
lib/mime/types/deprecations.rb
|
17
|
+
lib/mime/types/full.rb
|
28
18
|
lib/mime/types/loader.rb
|
29
|
-
lib/mime/types/loader_path.rb
|
30
19
|
lib/mime/types/logger.rb
|
31
|
-
|
32
|
-
support/benchmarks/load.rb
|
33
|
-
support/benchmarks/load_allocations.rb
|
34
|
-
support/benchmarks/object_counts.rb
|
35
|
-
support/convert.rb
|
36
|
-
support/convert/columnar.rb
|
37
|
-
support/iana_registry.rb
|
20
|
+
lib/mime/types/registry.rb
|
38
21
|
test/bad-fixtures/malformed
|
39
22
|
test/fixture/json.json
|
40
23
|
test/fixture/old-data
|
data/README.rdoc
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
= mime-types
|
1
|
+
= mime-types for Ruby
|
2
2
|
|
3
3
|
home :: https://github.com/mime-types/ruby-mime-types/
|
4
4
|
code :: https://github.com/mime-types/ruby-mime-types/
|
5
5
|
bugs :: https://github.com/mime-types/ruby-mime-types/issues
|
6
6
|
rdoc :: http://rdoc.info/gems/mime-types/
|
7
|
-
|
8
|
-
|
7
|
+
clog :: https://github.com/mime-types/ruby-mime-types/blob/master/History.md
|
8
|
+
continuous integration :: {<img src="https://travis-ci.org/mime-types/ruby-mime-types.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/mime-types/ruby-mime-types]
|
9
|
+
test coverage :: {<img src="https://coveralls.io/repos/mime-types/ruby-mime-types/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/mime-types/ruby-mime-types?branch=master]
|
9
10
|
|
10
11
|
== Description
|
11
12
|
|
@@ -14,19 +15,13 @@ MIME content type definitions. It can be used to determine defined filename
|
|
14
15
|
extensions for MIME types, or to use filename extensions to look up the likely
|
15
16
|
MIME type definitions.
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
registered MIME media types plus any security updates that may be required.
|
25
|
-
|
26
|
-
If the loss of the deprecated data matters, be sure to set your dependency
|
27
|
-
appropriately:
|
28
|
-
|
29
|
-
gem 'mime-types', '~> 2.6, < 2.99'
|
18
|
+
Version 3.0 is a major release that requires Ruby 2.0 compatibility and removes
|
19
|
+
deprecated functions. The columnar registry format introduced in 2.6 has been
|
20
|
+
made the primary format; the registry data has been extracted from this library
|
21
|
+
and put into {mime-types-data}[https://github.com/mime-types/mime-types-data].
|
22
|
+
Additionally, mime-types is now licensed exclusively under the MIT licence and
|
23
|
+
there is a code of conduct in effect. There are a number of other smaller
|
24
|
+
changes described in the History file.
|
30
25
|
|
31
26
|
=== About MIME Media Types
|
32
27
|
|
@@ -41,17 +36,6 @@ recommendations, the {IANA Media Types
|
|
41
36
|
registry}[https://www.iana.org/assignments/media-types/media-types.xhtml], and
|
42
37
|
user contributions. It conforms to RFCs 2045 and 2231.
|
43
38
|
|
44
|
-
=== mime-types 1.x End of Life
|
45
|
-
|
46
|
-
mime-types 1.x has reached end of life and is no longer supported as of
|
47
|
-
2015-10-27 and will receive no updates at all.
|
48
|
-
|
49
|
-
=== mime-types 2.x End of Life
|
50
|
-
|
51
|
-
mime-types 2.x is supported as 2.99.x receiving quarterly updates of the IANA
|
52
|
-
registry and security updates for two years. It will reach full end of life on
|
53
|
-
2017-11-21.
|
54
|
-
|
55
39
|
=== mime-types 3.x
|
56
40
|
|
57
41
|
Users are encouraged to upgrade to mime-types 3.x as soon as is practical.
|
@@ -90,8 +74,8 @@ files). A MIME::Type stores the known information about one MIME type.
|
|
90
74
|
puts text == 'text/x-plain' # => false
|
91
75
|
puts 'text/x-plain' == text # => false
|
92
76
|
|
93
|
-
puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
94
|
-
puts MIME::Type.i18n_key('x-appl/x-zip') # => 'appl.zip'
|
77
|
+
puts MIME::Type.simplified('x-appl/x-zip') # => 'x-appl/x-zip'
|
78
|
+
puts MIME::Type.i18n_key('x-appl/x-zip') # => 'x-appl.x-zip'
|
95
79
|
|
96
80
|
puts text.like?('text/x-plain') # => true
|
97
81
|
puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
|
@@ -118,54 +102,61 @@ files). A MIME::Type stores the known information about one MIME type.
|
|
118
102
|
|
119
103
|
xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
|
120
104
|
puts xwingz.content_type # => 'application/x-Wingz'
|
121
|
-
puts xwingz.simplified # => 'application/wingz'
|
105
|
+
puts xwingz.simplified # => 'application/x-wingz'
|
122
106
|
|
123
107
|
=== Columnar Store
|
124
108
|
|
125
|
-
mime-types
|
126
|
-
the default memory footprint.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
109
|
+
mime-types uses as its primary registry storage format a columnar storage
|
110
|
+
format reducing the default memory footprint. This is done by selectively
|
111
|
+
loading the data on a per-attribute basis. When the registry is first loaded
|
112
|
+
from the columnar store, only the canonical MIME content type and known
|
113
|
+
extensions and the MIME type will be connected to its loading registry. When
|
114
|
+
other data about the type is required (including +preferred_extension+,
|
115
|
+
<tt>obsolete?</tt>, and <tt>registered?</tt>) that data is loaded from its own
|
116
|
+
column file for all types in the registry.
|
133
117
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
118
|
+
The load of any column data is performed with a Mutex to ensure that types are
|
119
|
+
updated safely in a multithreaded environment. Benchmarks show that while
|
120
|
+
columnar data loading is slower than the JSON store, it cuts the memory use by
|
121
|
+
a third over the JSON store.
|
138
122
|
|
139
|
-
|
123
|
+
If you prefer to load all the data at once, this can be specified in your
|
124
|
+
application Gemfile as:
|
140
125
|
|
141
|
-
|
142
|
-
behaviour to applications are encouraged to require this directly, but only if
|
143
|
-
you specify a dependency on mime-types 2.6.
|
126
|
+
gem 'mime-types', require: 'mime/types/full'
|
144
127
|
|
145
|
-
|
128
|
+
Projects that do not use Bundler should +require+ the same:
|
129
|
+
|
130
|
+
require 'mime/types/full'
|
146
131
|
|
147
|
-
|
148
|
-
|
132
|
+
Libraries that use mime-types are discouraged from choosing the JSON store.
|
133
|
+
|
134
|
+
For applications and clients that used mime-types 2.6 when the columnar store
|
135
|
+
was introduced, the require used previously will still work through at least
|
136
|
+
{version
|
149
137
|
4}[https://github.com/mime-types/ruby-mime-types/pull/96#issuecomment-100725400]
|
150
|
-
and possibly beyond.
|
138
|
+
and possibly beyond; it is effectively an empty operation. You are recommended
|
139
|
+
to change your Gemfile as soon as is practical.
|
140
|
+
|
141
|
+
require 'mime/types/columnar'
|
151
142
|
|
152
|
-
Note that
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
143
|
+
Note that MIME::Type::Columnar and MIME::Types::Columnar are considered private
|
144
|
+
variant implementations of MIME::Type and MIME::Types and the specific
|
145
|
+
implementation should not be relied upon by consumers of the mime-types
|
146
|
+
library. Instead, depend on the public implementations (MIME::Type and
|
147
|
+
MIME::Types) only.
|
157
148
|
|
158
149
|
=== Cached Storage
|
159
150
|
|
160
|
-
|
161
|
-
|
162
|
-
|
151
|
+
mime-types supports a cache of MIME types using <tt>Marshal.dump</tt>. The
|
152
|
+
cache is invalidated for each version of the mime-types-data gem so that data
|
153
|
+
version 3.2015.1201 will not be reused with data version 3.2016.0101. If the
|
163
154
|
environment variable +RUBY_MIME_TYPES_CACHE+ is set to a cache file, mime-types
|
164
155
|
will attempt to load the MIME type registry from the cache file. If it cannot,
|
165
156
|
it will load the types normally and then saves the registry to the cache file.
|
166
157
|
|
167
|
-
The
|
168
|
-
|
158
|
+
The caching works with both full stores and columnar stores. Only the data that
|
159
|
+
has been loaded prior to saving the cache will be stored.
|
169
160
|
|
170
161
|
== mime-types Modified Semantic Versioning
|
171
162
|
|
@@ -183,22 +174,20 @@ MAJOR.MINOR:
|
|
183
174
|
incremented, MINOR will be set to zero, and PATCH will be reset to the
|
184
175
|
implied zero.
|
185
176
|
|
186
|
-
2. If an API (code) feature is added that does not break
|
187
|
-
|
188
|
-
version will be incremented and PATCH will be reset to the implied zero.
|
177
|
+
2. If an API (code) feature is added that does not break compatibility, the
|
178
|
+
MINOR version will be incremented and PATCH will be reset to the implied zero.
|
189
179
|
|
190
180
|
3. If there is a bugfix to a feature added in the most recent MAJOR.MINOR
|
191
|
-
release,
|
192
|
-
|
181
|
+
release, the implied PATCH value will be incremented resulting in
|
182
|
+
MAJOR.MINOR.PATCH.
|
193
183
|
|
194
|
-
In practical terms, there
|
195
|
-
|
196
|
-
|
197
|
-
mime-types
|
198
|
-
will be removed in mime-types 3.x.
|
184
|
+
In practical terms, there will be fewer releases of mime-types focussing on
|
185
|
+
features because of the existence of the [mime-types-data][] gem, and if
|
186
|
+
features are marked deprecated in the course of mime-types 3.x, they will not
|
187
|
+
be removed until mime-types 4.x or possibly later.
|
199
188
|
|
200
|
-
|
189
|
+
{Code of Conduct}[Code-of-Conduct_md.html]
|
201
190
|
|
202
|
-
|
191
|
+
{Contributing}[Contributing_md.html]
|
203
192
|
|
204
|
-
|
193
|
+
{Licence}[Licence_md.html]
|
data/Rakefile
CHANGED
@@ -15,13 +15,14 @@ spec = Hoe.spec 'mime-types' do
|
|
15
15
|
developer('Austin Ziegler', 'halostatue@gmail.com')
|
16
16
|
self.need_tar = true
|
17
17
|
|
18
|
-
require_ruby_version '>=
|
18
|
+
require_ruby_version '>= 2.0'
|
19
19
|
|
20
|
-
self.history_file = 'History.
|
20
|
+
self.history_file = 'History.md'
|
21
21
|
self.readme_file = 'README.rdoc'
|
22
|
-
self.extra_rdoc_files = FileList['*.rdoc'].to_a
|
23
22
|
|
24
|
-
|
23
|
+
license 'MIT'
|
24
|
+
|
25
|
+
extra_deps << ['mime-types-data', '~> 3.2015']
|
25
26
|
|
26
27
|
extra_dev_deps << ['hoe-doofus', '~> 1.0']
|
27
28
|
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
@@ -31,28 +32,29 @@ spec = Hoe.spec 'mime-types' do
|
|
31
32
|
extra_dev_deps << ['minitest', '~> 5.4']
|
32
33
|
extra_dev_deps << ['minitest-autotest', '~> 1.0']
|
33
34
|
extra_dev_deps << ['minitest-focus', '~> 1.0']
|
34
|
-
extra_dev_deps << ['
|
35
|
-
extra_dev_deps << ['
|
35
|
+
extra_dev_deps << ['minitest-bonus-assertions', '~> 3.0']
|
36
|
+
extra_dev_deps << ['minitest-hooks', '~> 1.4']
|
37
|
+
extra_dev_deps << ['rake', '>= 10.0', '< 13.0']
|
38
|
+
extra_dev_deps << ['fivemat', '~> 1.3']
|
36
39
|
extra_dev_deps << ['minitest-rg', '~> 5.2']
|
37
|
-
end
|
38
|
-
|
39
|
-
task :support do
|
40
|
-
%w(lib support).each { |path|
|
41
|
-
$LOAD_PATH.unshift(File.join(Rake.application.original_dir, path))
|
42
|
-
}
|
43
|
-
end
|
44
40
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0')
|
42
|
+
extra_dev_deps << ['simplecov', '~> 0.7']
|
43
|
+
# if ENV['CI'] or ENV['TRAVIS']
|
44
|
+
# extra_dev_deps << ['coveralls', '~> 0.8']
|
45
|
+
# end
|
50
46
|
end
|
51
47
|
end
|
52
48
|
|
53
49
|
namespace :benchmark do
|
50
|
+
task :support do
|
51
|
+
%w(lib support).each { |path|
|
52
|
+
$LOAD_PATH.unshift(File.join(Rake.application.original_dir, path))
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
54
56
|
desc 'Benchmark Load Times'
|
55
|
-
task :load, [
|
57
|
+
task :load, [:repeats] => 'benchmark:support' do |_, args|
|
56
58
|
require 'benchmarks/load'
|
57
59
|
Benchmarks::Load.report(
|
58
60
|
File.join(Rake.application.original_dir, 'lib'),
|
@@ -61,7 +63,7 @@ namespace :benchmark do
|
|
61
63
|
end
|
62
64
|
|
63
65
|
desc 'Allocation counts'
|
64
|
-
task :allocations, [
|
66
|
+
task :allocations, [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
|
65
67
|
require 'benchmarks/load_allocations'
|
66
68
|
Benchmarks::LoadAllocations.report(
|
67
69
|
top_x: args.top_x,
|
@@ -70,7 +72,7 @@ namespace :benchmark do
|
|
70
72
|
end
|
71
73
|
|
72
74
|
desc 'Columnar allocation counts'
|
73
|
-
task 'allocations:columnar', [
|
75
|
+
task 'allocations:columnar', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
|
74
76
|
require 'benchmarks/load_allocations'
|
75
77
|
Benchmarks::LoadAllocations.report(
|
76
78
|
columnar: true,
|
@@ -79,30 +81,132 @@ namespace :benchmark do
|
|
79
81
|
)
|
80
82
|
end
|
81
83
|
|
84
|
+
desc 'Columnar allocation counts (full load)'
|
85
|
+
task 'allocations:columnar:full', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
|
86
|
+
require 'benchmarks/load_allocations'
|
87
|
+
Benchmarks::LoadAllocations.report(
|
88
|
+
columnar: true,
|
89
|
+
top_x: args.top_x,
|
90
|
+
mime_types_only: args.mime_types_only,
|
91
|
+
full: true
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'Memory profiler'
|
96
|
+
task :memory, [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
|
97
|
+
require 'benchmarks/memory_profiler'
|
98
|
+
Benchmarks::ProfileMemory.report(
|
99
|
+
mime_types_only: args.mime_types_only,
|
100
|
+
top_x: args.top_x
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
desc 'Columnar memory profiler'
|
105
|
+
task 'memory:columnar', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
|
106
|
+
require 'benchmarks/memory_profiler'
|
107
|
+
Benchmarks::ProfileMemory.report(
|
108
|
+
columnar: true,
|
109
|
+
mime_types_only: args.mime_types_only,
|
110
|
+
top_x: args.top_x
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
desc 'Columnar allocation counts (full load)'
|
115
|
+
task 'memory:columnar:full', [:top_x, :mime_types_only] => 'benchmark:support' do |_, args|
|
116
|
+
require 'benchmarks/memory_profiler'
|
117
|
+
Benchmarks::ProfileMemory.report(
|
118
|
+
columnar: true,
|
119
|
+
full: true,
|
120
|
+
top_x: args.top_x,
|
121
|
+
mime_types_only: args.mime_types_only
|
122
|
+
)
|
123
|
+
end
|
124
|
+
|
82
125
|
desc 'Object counts'
|
83
|
-
task objects: :support do
|
126
|
+
task objects: 'benchmark:support' do
|
84
127
|
require 'benchmarks/object_counts'
|
85
128
|
Benchmarks::ObjectCounts.report
|
86
129
|
end
|
87
130
|
|
88
131
|
desc 'Columnar object counts'
|
89
|
-
task 'objects:columnar' => :support do
|
132
|
+
task 'objects:columnar' => 'benchmark:support' do
|
90
133
|
require 'benchmarks/object_counts'
|
91
134
|
Benchmarks::ObjectCounts.report(columnar: true)
|
92
135
|
end
|
136
|
+
|
137
|
+
desc 'Columnar object counts (full load)'
|
138
|
+
task 'objects:columnar:full' => 'benchmark:support' do
|
139
|
+
require 'benchmarks/object_counts'
|
140
|
+
Benchmarks::ObjectCounts.report(columnar: true, full: true)
|
141
|
+
end
|
93
142
|
end
|
94
143
|
|
95
|
-
namespace :
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
144
|
+
namespace :profile do
|
145
|
+
directory 'tmp/profile'
|
146
|
+
|
147
|
+
CLEAN.add 'tmp'
|
148
|
+
|
149
|
+
def ruby_prof(script)
|
150
|
+
require 'pathname'
|
151
|
+
output = Pathname('tmp/profile').join(script)
|
152
|
+
output.mkpath
|
153
|
+
script = Pathname('support/profile').join("#{script}.rb")
|
154
|
+
|
155
|
+
args = [
|
156
|
+
'-W0',
|
157
|
+
'-Ilib',
|
158
|
+
'-S', 'ruby-prof',
|
159
|
+
'-R', 'mime/types',
|
160
|
+
'-s', 'self',
|
161
|
+
'-p', 'multi',
|
162
|
+
'-f', output.to_s,
|
163
|
+
script.to_s
|
164
|
+
]
|
165
|
+
ruby args.join(' ')
|
100
166
|
end
|
101
167
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
168
|
+
task full: 'tmp/profile' do
|
169
|
+
ruby_prof 'full'
|
170
|
+
end
|
171
|
+
|
172
|
+
task columnar: :support do
|
173
|
+
ruby_prof 'columnar'
|
174
|
+
end
|
175
|
+
|
176
|
+
task 'columnar:full' => :support do
|
177
|
+
ruby_prof 'columnar_full'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.0')
|
182
|
+
namespace :test do
|
183
|
+
# Coveralls needs to be disabled for now because it transitively depends on
|
184
|
+
# an earlier version of mime-types.
|
185
|
+
# if ENV['CI'] or ENV['TRAVIS']
|
186
|
+
# task :coveralls do
|
187
|
+
# spec.test_prelude = [
|
188
|
+
# 'require "psych"',
|
189
|
+
# 'require "simplecov"',
|
190
|
+
# 'require "coveralls"',
|
191
|
+
# 'SimpleCov.formatter = Coveralls::SimpleCov::Formatter',
|
192
|
+
# 'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
|
193
|
+
# 'gem "minitest"'
|
194
|
+
# ].join('; ')
|
195
|
+
# Rake::Task['test'].execute
|
196
|
+
# end
|
197
|
+
|
198
|
+
# Rake::Task['travis'].prerequisites.replace(%w(test:coveralls))
|
199
|
+
# end
|
200
|
+
|
201
|
+
desc 'Run test coverage'
|
202
|
+
task :coverage do
|
203
|
+
spec.test_prelude = [
|
204
|
+
'require "simplecov"',
|
205
|
+
'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
|
206
|
+
'gem "minitest"'
|
207
|
+
].join('; ')
|
208
|
+
Rake::Task['test'].execute
|
209
|
+
end
|
106
210
|
end
|
107
211
|
end
|
108
212
|
|
@@ -114,11 +218,11 @@ namespace :convert do
|
|
114
218
|
@doc_converter ||= RDoc::Markup::ToMarkdown.new
|
115
219
|
end
|
116
220
|
|
117
|
-
|
118
|
-
rdoc =
|
119
|
-
mark = "#{name}.md"
|
221
|
+
FileList['*.rdoc'].each do |name|
|
222
|
+
rdoc = name
|
223
|
+
mark = "#{File.basename(name, '.rdoc')}.md"
|
120
224
|
|
121
|
-
file mark => [
|
225
|
+
file mark => [rdoc, :setup] do |t|
|
122
226
|
puts "#{rdoc} => #{mark}"
|
123
227
|
File.open(t.name, 'wb') { |target|
|
124
228
|
target.write @doc_converter.convert(IO.read(t.prerequisites.first))
|
@@ -127,41 +231,54 @@ namespace :convert do
|
|
127
231
|
|
128
232
|
CLEAN.add mark
|
129
233
|
|
130
|
-
task run: [
|
234
|
+
task run: [mark]
|
131
235
|
end
|
132
236
|
end
|
133
237
|
|
134
238
|
desc 'Convert documentation from RDoc to Markdown'
|
135
239
|
task docs: 'convert:docs:run'
|
240
|
+
end
|
136
241
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
require 'convert'
|
141
|
-
Convert.from_yaml_to_json(args)
|
142
|
-
end
|
242
|
+
task 'deps:top', [:number] do |_, args|
|
243
|
+
require 'net/http'
|
244
|
+
require 'json'
|
143
245
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
246
|
+
def rubygems_get(gem_name: '', endpoint: '')
|
247
|
+
path = File.join('/api/v1/gems/', gem_name, endpoint).chomp('/') + '.json'
|
248
|
+
Net::HTTP.start('rubygems.org', use_ssl: true) do |http|
|
249
|
+
JSON.parse(http.get(path).body)
|
148
250
|
end
|
149
251
|
end
|
150
252
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
253
|
+
results = rubygems_get(
|
254
|
+
gem_name: 'mime-types',
|
255
|
+
endpoint: 'reverse_dependencies'
|
256
|
+
)
|
257
|
+
|
258
|
+
weighted_results = {}
|
259
|
+
results.each do |name|
|
260
|
+
begin
|
261
|
+
weighted_results[name] = rubygems_get(gem_name: name)['downloads']
|
262
|
+
rescue => e
|
263
|
+
puts "#{name} #{e.message}"
|
156
264
|
end
|
157
265
|
end
|
158
|
-
end
|
159
266
|
|
160
|
-
|
161
|
-
|
267
|
+
weighted_results.sort { |(_k1, v1), (_k2, v2)|
|
268
|
+
v2 <=> v1
|
269
|
+
}.first(args.number || 50).each_with_index do |(k, v), i|
|
270
|
+
puts "#{i}) #{k}: #{v}"
|
271
|
+
end
|
272
|
+
end
|
162
273
|
|
163
|
-
|
164
|
-
|
165
|
-
|
274
|
+
task :console do
|
275
|
+
arguments = %w(pry)
|
276
|
+
arguments.push(*spec.spec.require_paths.map { |dir| "-I#{dir}" })
|
277
|
+
arguments.push("-r#{spec.spec.name.gsub('-', File::SEPARATOR)}")
|
278
|
+
unless system(*arguments)
|
279
|
+
error "Command failed: #{show_command}"
|
280
|
+
abort
|
281
|
+
end
|
282
|
+
end
|
166
283
|
|
167
284
|
# vim: syntax=ruby
|