mime-types 2.99.3 → 3.4.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} +29 -30
- data/Contributing.md +132 -0
- data/History.md +269 -0
- data/{Licence.rdoc → Licence.md} +4 -18
- data/Manifest.txt +8 -25
- data/README.rdoc +63 -73
- data/Rakefile +200 -97
- data/lib/mime/type/columnar.rb +30 -63
- data/lib/mime/type.rb +294 -458
- data/lib/mime/types/_columnar.rb +137 -0
- data/lib/mime/types/cache.rb +52 -74
- data/lib/mime/types/columnar.rb +2 -147
- data/lib/mime/types/container.rb +96 -0
- data/lib/mime/types/deprecations.rb +17 -34
- data/lib/mime/types/full.rb +19 -0
- data/lib/mime/types/loader.rb +36 -152
- data/lib/mime/types/logger.rb +7 -5
- data/lib/mime/types/registry.rb +90 -0
- data/lib/mime/types.rb +55 -148
- data/lib/mime-types.rb +2 -2
- data/test/minitest_helper.rb +8 -18
- data/test/test_mime_type.rb +489 -464
- data/test/test_mime_types.rb +139 -91
- data/test/test_mime_types_cache.rb +85 -57
- data/test/test_mime_types_class.rb +120 -100
- data/test/test_mime_types_lazy.rb +30 -28
- data/test/test_mime_types_loader.rb +18 -45
- metadata +92 -77
- 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/columnar.rb +0 -88
- data/support/convert.rb +0 -158
- data/support/iana_registry.rb +0 -172
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.
|
@@ -81,6 +65,7 @@ files). A MIME::Type stores the known information about one MIME type.
|
|
81
65
|
puts text.ascii? # => true
|
82
66
|
puts text.obsolete? # => false
|
83
67
|
puts text.registered? # => true
|
68
|
+
puts text.provisional? # => false
|
84
69
|
puts text.complete? # => true
|
85
70
|
|
86
71
|
puts text # => 'text/plain'
|
@@ -90,8 +75,8 @@ files). A MIME::Type stores the known information about one MIME type.
|
|
90
75
|
puts text == 'text/x-plain' # => false
|
91
76
|
puts 'text/x-plain' == text # => false
|
92
77
|
|
93
|
-
puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
|
94
|
-
puts MIME::Type.i18n_key('x-appl/x-zip') # => 'appl.zip'
|
78
|
+
puts MIME::Type.simplified('x-appl/x-zip') # => 'x-appl/x-zip'
|
79
|
+
puts MIME::Type.i18n_key('x-appl/x-zip') # => 'x-appl.x-zip'
|
95
80
|
|
96
81
|
puts text.like?('text/x-plain') # => true
|
97
82
|
puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
|
@@ -118,54 +103,61 @@ files). A MIME::Type stores the known information about one MIME type.
|
|
118
103
|
|
119
104
|
xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
|
120
105
|
puts xwingz.content_type # => 'application/x-Wingz'
|
121
|
-
puts xwingz.simplified # => 'application/wingz'
|
106
|
+
puts xwingz.simplified # => 'application/x-wingz'
|
122
107
|
|
123
108
|
=== Columnar Store
|
124
109
|
|
125
|
-
mime-types
|
126
|
-
the default memory footprint.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
110
|
+
mime-types uses as its primary registry storage format a columnar storage
|
111
|
+
format reducing the default memory footprint. This is done by selectively
|
112
|
+
loading the data on a per-attribute basis. When the registry is first loaded
|
113
|
+
from the columnar store, only the canonical MIME content type and known
|
114
|
+
extensions and the MIME type will be connected to its loading registry. When
|
115
|
+
other data about the type is required (including +preferred_extension+,
|
116
|
+
<tt>obsolete?</tt>, and <tt>registered?</tt>) that data is loaded from its own
|
117
|
+
column file for all types in the registry.
|
133
118
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
119
|
+
The load of any column data is performed with a Mutex to ensure that types are
|
120
|
+
updated safely in a multithreaded environment. Benchmarks show that while
|
121
|
+
columnar data loading is slower than the JSON store, it cuts the memory use by
|
122
|
+
a third over the JSON store.
|
138
123
|
|
139
|
-
|
124
|
+
If you prefer to load all the data at once, this can be specified in your
|
125
|
+
application Gemfile as:
|
140
126
|
|
141
|
-
|
142
|
-
behaviour to applications are encouraged to require this directly, but only if
|
143
|
-
you specify a dependency on mime-types 2.6.
|
127
|
+
gem 'mime-types', require: 'mime/types/full'
|
144
128
|
|
145
|
-
|
129
|
+
Projects that do not use Bundler should +require+ the same:
|
130
|
+
|
131
|
+
require 'mime/types/full'
|
146
132
|
|
147
|
-
|
148
|
-
|
133
|
+
Libraries that use mime-types are discouraged from choosing the JSON store.
|
134
|
+
|
135
|
+
For applications and clients that used mime-types 2.6 when the columnar store
|
136
|
+
was introduced, the require used previously will still work through at least
|
137
|
+
{version
|
149
138
|
4}[https://github.com/mime-types/ruby-mime-types/pull/96#issuecomment-100725400]
|
150
|
-
and possibly beyond.
|
139
|
+
and possibly beyond; it is effectively an empty operation. You are recommended
|
140
|
+
to change your Gemfile as soon as is practical.
|
141
|
+
|
142
|
+
require 'mime/types/columnar'
|
151
143
|
|
152
|
-
Note that
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
144
|
+
Note that MIME::Type::Columnar and MIME::Types::Columnar are considered private
|
145
|
+
variant implementations of MIME::Type and MIME::Types and the specific
|
146
|
+
implementation should not be relied upon by consumers of the mime-types
|
147
|
+
library. Instead, depend on the public implementations (MIME::Type and
|
148
|
+
MIME::Types) only.
|
157
149
|
|
158
150
|
=== Cached Storage
|
159
151
|
|
160
|
-
|
161
|
-
|
162
|
-
|
152
|
+
mime-types supports a cache of MIME types using <tt>Marshal.dump</tt>. The
|
153
|
+
cache is invalidated for each version of the mime-types-data gem so that data
|
154
|
+
version 3.2015.1201 will not be reused with data version 3.2016.0101. If the
|
163
155
|
environment variable +RUBY_MIME_TYPES_CACHE+ is set to a cache file, mime-types
|
164
156
|
will attempt to load the MIME type registry from the cache file. If it cannot,
|
165
157
|
it will load the types normally and then saves the registry to the cache file.
|
166
158
|
|
167
|
-
The
|
168
|
-
|
159
|
+
The caching works with both full stores and columnar stores. Only the data that
|
160
|
+
has been loaded prior to saving the cache will be stored.
|
169
161
|
|
170
162
|
== mime-types Modified Semantic Versioning
|
171
163
|
|
@@ -183,22 +175,20 @@ MAJOR.MINOR:
|
|
183
175
|
incremented, MINOR will be set to zero, and PATCH will be reset to the
|
184
176
|
implied zero.
|
185
177
|
|
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.
|
178
|
+
2. If an API (code) feature is added that does not break compatibility, the
|
179
|
+
MINOR version will be incremented and PATCH will be reset to the implied zero.
|
189
180
|
|
190
181
|
3. If there is a bugfix to a feature added in the most recent MAJOR.MINOR
|
191
|
-
release,
|
192
|
-
|
182
|
+
release, the implied PATCH value will be incremented resulting in
|
183
|
+
MAJOR.MINOR.PATCH.
|
193
184
|
|
194
|
-
In practical terms, there
|
195
|
-
|
196
|
-
|
197
|
-
mime-types
|
198
|
-
will be removed in mime-types 3.x.
|
185
|
+
In practical terms, there will be fewer releases of mime-types focussing on
|
186
|
+
features because of the existence of the [mime-types-data][] gem, and if
|
187
|
+
features are marked deprecated in the course of mime-types 3.x, they will not
|
188
|
+
be removed until mime-types 4.x or possibly later.
|
199
189
|
|
200
|
-
|
190
|
+
{Code of Conduct}[Code-of-Conduct_md.html]
|
201
191
|
|
202
|
-
|
192
|
+
{Contributing}[Contributing_md.html]
|
203
193
|
|
204
|
-
|
194
|
+
{Licence}[Licence_md.html]
|
data/Rakefile
CHANGED
@@ -1,77 +1,108 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
require "rake/clean"
|
6
|
+
|
7
|
+
# This is required until https://github.com/seattlerb/hoe/issues/112 is fixed
|
8
|
+
class Hoe
|
9
|
+
def with_config
|
10
|
+
config = Hoe::DEFAULT_CONFIG
|
11
|
+
|
12
|
+
rc = File.expand_path("~/.hoerc")
|
13
|
+
homeconfig = load_config(rc)
|
14
|
+
config = config.merge(homeconfig)
|
15
|
+
|
16
|
+
localconfig = load_config(File.expand_path(File.join(Dir.pwd, ".hoerc")))
|
17
|
+
config = config.merge(localconfig)
|
18
|
+
|
19
|
+
yield config, rc
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_config(name)
|
23
|
+
File.exist?(name) ? safe_load_yaml(name) : {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def safe_load_yaml(name)
|
27
|
+
return safe_load_yaml_file(name) if YAML.respond_to?(:safe_load_file)
|
28
|
+
|
29
|
+
data = IO.binread(name)
|
30
|
+
YAML.safe_load(data, permitted_classes: [Regexp])
|
31
|
+
rescue
|
32
|
+
YAML.safe_load(data, [Regexp])
|
33
|
+
end
|
34
|
+
|
35
|
+
def safe_load_yaml_file(name)
|
36
|
+
YAML.safe_load_file(name, permitted_classes: [Regexp])
|
37
|
+
rescue
|
38
|
+
YAML.safe_load_file(name, [Regexp])
|
39
|
+
end
|
40
|
+
end
|
6
41
|
|
7
42
|
Hoe.plugin :doofus
|
8
43
|
Hoe.plugin :gemspec2
|
9
44
|
Hoe.plugin :git
|
10
45
|
Hoe.plugin :minitest
|
11
|
-
Hoe.plugin :
|
12
|
-
Hoe.plugin :email unless ENV['CI'] or ENV['TRAVIS']
|
46
|
+
Hoe.plugin :email unless ENV["CI"]
|
13
47
|
|
14
|
-
spec = Hoe.spec
|
15
|
-
developer(
|
48
|
+
spec = Hoe.spec "mime-types" do
|
49
|
+
developer("Austin Ziegler", "halostatue@gmail.com")
|
16
50
|
self.need_tar = true
|
17
51
|
|
18
|
-
require_ruby_version
|
19
|
-
|
20
|
-
self.history_file = 'History.rdoc'
|
21
|
-
self.readme_file = 'README.rdoc'
|
22
|
-
self.extra_rdoc_files = FileList['*.rdoc'].to_a
|
23
|
-
|
24
|
-
self.licenses = ['MIT', 'Artistic-2.0', 'GPL-2.0']
|
25
|
-
|
26
|
-
extra_dev_deps << ['hoe-doofus', '~> 1.0']
|
27
|
-
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
28
|
-
extra_dev_deps << ['hoe-git', '~> 1.6']
|
29
|
-
extra_dev_deps << ['hoe-rubygems', '~> 1.0']
|
30
|
-
extra_dev_deps << ['hoe-travis', '~> 1.2']
|
31
|
-
extra_dev_deps << ['minitest', '~> 5.4']
|
32
|
-
extra_dev_deps << ['minitest-autotest', '~> 1.0']
|
33
|
-
extra_dev_deps << ['minitest-focus', '~> 1.0']
|
34
|
-
extra_dev_deps << ['rake', '~> 10.0']
|
35
|
-
extra_dev_deps << ['fivemat', '~> 1.3' ]
|
36
|
-
extra_dev_deps << ['minitest-rg', '~> 5.2']
|
37
|
-
end
|
52
|
+
require_ruby_version ">= 2.0"
|
38
53
|
|
39
|
-
|
40
|
-
|
41
|
-
$LOAD_PATH.unshift(File.join(Rake.application.original_dir, path))
|
42
|
-
}
|
43
|
-
end
|
54
|
+
self.history_file = "History.md"
|
55
|
+
self.readme_file = "README.rdoc"
|
44
56
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
license "MIT"
|
58
|
+
|
59
|
+
extra_deps << ["mime-types-data", "~> 3.2015"]
|
60
|
+
|
61
|
+
extra_dev_deps << ["hoe-doofus", "~> 1.0"]
|
62
|
+
extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
|
63
|
+
extra_dev_deps << ["hoe-git", "~> 1.6"]
|
64
|
+
extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
|
65
|
+
extra_dev_deps << ["standard", "~> 1.0"]
|
66
|
+
extra_dev_deps << ["minitest", "~> 5.4"]
|
67
|
+
extra_dev_deps << ["minitest-autotest", "~> 1.0"]
|
68
|
+
extra_dev_deps << ["minitest-focus", "~> 1.0"]
|
69
|
+
extra_dev_deps << ["minitest-bonus-assertions", "~> 3.0"]
|
70
|
+
extra_dev_deps << ["minitest-hooks", "~> 1.4"]
|
71
|
+
extra_dev_deps << ["rake", ">= 10.0", "< 14.0"]
|
72
|
+
|
73
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.0")
|
74
|
+
extra_dev_deps << ["simplecov", "~> 0.7"]
|
50
75
|
end
|
51
76
|
end
|
52
77
|
|
53
78
|
namespace :benchmark do
|
54
|
-
|
55
|
-
|
56
|
-
|
79
|
+
task :support do
|
80
|
+
%w[lib support].each { |path|
|
81
|
+
$LOAD_PATH.unshift(File.join(Rake.application.original_dir, path))
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
desc "Benchmark Load Times"
|
86
|
+
task :load, [:repeats] => "benchmark:support" do |_, args|
|
87
|
+
require "benchmarks/load"
|
57
88
|
Benchmarks::Load.report(
|
58
|
-
File.join(Rake.application.original_dir,
|
89
|
+
File.join(Rake.application.original_dir, "lib"),
|
59
90
|
args.repeats
|
60
91
|
)
|
61
92
|
end
|
62
93
|
|
63
|
-
desc
|
64
|
-
task :allocations, [
|
65
|
-
require
|
94
|
+
desc "Allocation counts"
|
95
|
+
task :allocations, [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
|
96
|
+
require "benchmarks/load_allocations"
|
66
97
|
Benchmarks::LoadAllocations.report(
|
67
98
|
top_x: args.top_x,
|
68
99
|
mime_types_only: args.mime_types_only
|
69
100
|
)
|
70
101
|
end
|
71
102
|
|
72
|
-
desc
|
73
|
-
task
|
74
|
-
require
|
103
|
+
desc "Columnar allocation counts"
|
104
|
+
task "allocations:columnar", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
|
105
|
+
require "benchmarks/load_allocations"
|
75
106
|
Benchmarks::LoadAllocations.report(
|
76
107
|
columnar: true,
|
77
108
|
top_x: args.top_x,
|
@@ -79,89 +110,161 @@ namespace :benchmark do
|
|
79
110
|
)
|
80
111
|
end
|
81
112
|
|
82
|
-
desc
|
83
|
-
task
|
84
|
-
require
|
113
|
+
desc "Columnar allocation counts (full load)"
|
114
|
+
task "allocations:columnar:full", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
|
115
|
+
require "benchmarks/load_allocations"
|
116
|
+
Benchmarks::LoadAllocations.report(
|
117
|
+
columnar: true,
|
118
|
+
top_x: args.top_x,
|
119
|
+
mime_types_only: args.mime_types_only,
|
120
|
+
full: true
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
desc "Memory profiler"
|
125
|
+
task :memory, [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
|
126
|
+
require "benchmarks/memory_profiler"
|
127
|
+
Benchmarks::ProfileMemory.report(
|
128
|
+
mime_types_only: args.mime_types_only,
|
129
|
+
top_x: args.top_x
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
desc "Columnar memory profiler"
|
134
|
+
task "memory:columnar", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
|
135
|
+
require "benchmarks/memory_profiler"
|
136
|
+
Benchmarks::ProfileMemory.report(
|
137
|
+
columnar: true,
|
138
|
+
mime_types_only: args.mime_types_only,
|
139
|
+
top_x: args.top_x
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
desc "Columnar allocation counts (full load)"
|
144
|
+
task "memory:columnar:full", [:top_x, :mime_types_only] => "benchmark:support" do |_, args|
|
145
|
+
require "benchmarks/memory_profiler"
|
146
|
+
Benchmarks::ProfileMemory.report(
|
147
|
+
columnar: true,
|
148
|
+
full: true,
|
149
|
+
top_x: args.top_x,
|
150
|
+
mime_types_only: args.mime_types_only
|
151
|
+
)
|
152
|
+
end
|
153
|
+
|
154
|
+
desc "Object counts"
|
155
|
+
task objects: "benchmark:support" do
|
156
|
+
require "benchmarks/object_counts"
|
85
157
|
Benchmarks::ObjectCounts.report
|
86
158
|
end
|
87
159
|
|
88
|
-
desc
|
89
|
-
task
|
90
|
-
require
|
160
|
+
desc "Columnar object counts"
|
161
|
+
task "objects:columnar" => "benchmark:support" do
|
162
|
+
require "benchmarks/object_counts"
|
91
163
|
Benchmarks::ObjectCounts.report(columnar: true)
|
92
164
|
end
|
165
|
+
|
166
|
+
desc "Columnar object counts (full load)"
|
167
|
+
task "objects:columnar:full" => "benchmark:support" do
|
168
|
+
require "benchmarks/object_counts"
|
169
|
+
Benchmarks::ObjectCounts.report(columnar: true, full: true)
|
170
|
+
end
|
93
171
|
end
|
94
172
|
|
95
|
-
namespace :
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
173
|
+
namespace :profile do
|
174
|
+
directory "tmp/profile"
|
175
|
+
|
176
|
+
CLEAN.add "tmp"
|
177
|
+
|
178
|
+
def ruby_prof(script)
|
179
|
+
require "pathname"
|
180
|
+
output = Pathname("tmp/profile").join(script)
|
181
|
+
output.mkpath
|
182
|
+
script = Pathname("support/profile").join("#{script}.rb")
|
183
|
+
|
184
|
+
args = [
|
185
|
+
"-W0",
|
186
|
+
"-Ilib",
|
187
|
+
"-S", "ruby-prof",
|
188
|
+
"-R", "mime/types",
|
189
|
+
"-s", "self",
|
190
|
+
"-p", "multi",
|
191
|
+
"-f", output.to_s,
|
192
|
+
script.to_s
|
193
|
+
]
|
194
|
+
ruby args.join(" ")
|
195
|
+
end
|
196
|
+
|
197
|
+
task full: "tmp/profile" do
|
198
|
+
ruby_prof "full"
|
199
|
+
end
|
200
|
+
|
201
|
+
task columnar: :support do
|
202
|
+
ruby_prof "columnar"
|
203
|
+
end
|
204
|
+
|
205
|
+
task "columnar:full" => :support do
|
206
|
+
ruby_prof "columnar_full"
|
100
207
|
end
|
208
|
+
end
|
101
209
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
210
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.0")
|
211
|
+
namespace :test do
|
212
|
+
desc "Run test coverage"
|
213
|
+
task :coverage do
|
214
|
+
spec.test_prelude = [
|
215
|
+
'require "simplecov"',
|
216
|
+
'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
|
217
|
+
'gem "minitest"'
|
218
|
+
].join("; ")
|
219
|
+
Rake::Task["test"].execute
|
220
|
+
end
|
106
221
|
end
|
107
222
|
end
|
108
223
|
|
109
224
|
namespace :convert do
|
110
225
|
namespace :docs do
|
111
226
|
task :setup do
|
112
|
-
gem
|
113
|
-
require
|
227
|
+
gem "rdoc"
|
228
|
+
require "rdoc/rdoc"
|
114
229
|
@doc_converter ||= RDoc::Markup::ToMarkdown.new
|
115
230
|
end
|
116
231
|
|
117
|
-
|
118
|
-
rdoc =
|
119
|
-
mark = "#{name}.md"
|
232
|
+
FileList["*.rdoc"].each do |name|
|
233
|
+
rdoc = name
|
234
|
+
mark = "#{File.basename(name, ".rdoc")}.md"
|
120
235
|
|
121
|
-
file mark => [
|
236
|
+
file mark => [rdoc, :setup] do |t|
|
122
237
|
puts "#{rdoc} => #{mark}"
|
123
|
-
File.open(t.name,
|
238
|
+
File.open(t.name, "wb") { |target|
|
124
239
|
target.write @doc_converter.convert(IO.read(t.prerequisites.first))
|
125
240
|
}
|
126
241
|
end
|
127
242
|
|
128
243
|
CLEAN.add mark
|
129
244
|
|
130
|
-
task run: [
|
245
|
+
task run: [mark]
|
131
246
|
end
|
132
247
|
end
|
133
248
|
|
134
|
-
desc
|
135
|
-
task docs:
|
136
|
-
|
137
|
-
namespace :yaml do
|
138
|
-
desc 'Convert from YAML to JSON'
|
139
|
-
task :json, [ :source, :destination, :multiple_files ] => :support do |_, args|
|
140
|
-
require 'convert'
|
141
|
-
Convert.from_yaml_to_json(args)
|
142
|
-
end
|
249
|
+
desc "Convert documentation from RDoc to Markdown"
|
250
|
+
task docs: "convert:docs:run"
|
251
|
+
end
|
143
252
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
253
|
+
namespace :deps do
|
254
|
+
task :top, [:number] => "benchmark:support" do |_, args|
|
255
|
+
require "deps"
|
256
|
+
Deps.run(args)
|
149
257
|
end
|
258
|
+
end
|
150
259
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
260
|
+
task :console do
|
261
|
+
arguments = %w[irb]
|
262
|
+
arguments.push(*spec.spec.require_paths.map { |dir| "-I#{dir}" })
|
263
|
+
arguments.push("-r#{spec.spec.name.gsub("-", File::SEPARATOR)}")
|
264
|
+
unless system(*arguments)
|
265
|
+
error "Command failed: #{show_command}"
|
266
|
+
abort
|
157
267
|
end
|
158
268
|
end
|
159
269
|
|
160
|
-
desc 'Default conversion from YAML to JSON and Columnar'
|
161
|
-
task convert: [ 'convert:yaml:json', 'convert:yaml:columnar' ]
|
162
|
-
|
163
|
-
Rake::Task['gem'].prerequisites.unshift('convert')
|
164
|
-
Rake::Task['gem'].prerequisites.unshift('git:manifest')
|
165
|
-
Rake::Task['gem'].prerequisites.unshift('gemspec')
|
166
|
-
|
167
270
|
# vim: syntax=ruby
|