Hello community,
here is the log from the commit of package rubygem-mime-types for
openSUSE:Factory checked in at 2016-05-29 03:12:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-mime-types (Old)
and /work/SRC/openSUSE:Factory/.rubygem-mime-types.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-mime-types"
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-mime-types/rubygem-mime-types.changes
2015-12-14 10:13:48.000000000 +0100
+++
/work/SRC/openSUSE:Factory/.rubygem-mime-types.new/rubygem-mime-types.changes
2016-05-29 03:13:08.000000000 +0200
@@ -1,0 +2,35 @@
+Mon May 23 04:35:21 UTC 2016 - [email protected]
+
+- updated to version 3.1
+ see installed History.rdoc
+
+ == 3.1 / 2016-05-22
+
+ * 1 documentation change:
+
+ * Tim Smith (@tas50) updated the build badges to be SVGs to improve
+ readability on high-density (retina) screens with pull request
+ {#112}[https://github.com/mime-types/ruby-mime-types/pull/112].
+
+ * 3 bug fixes
+
+ * A test for MIME::Types::Cache fails under Ruby 2.3 because of frozen
+ strings,
{#118}[https://github.com/mime-types/ruby-mime-types/issues/118].
+ This has been fixed.
+
+ * The JSON data has been incorrectly encoded since the release of
mime-types
+ 3 on the +xrefs+ field, because of the switch to using a Set to store
+ cross-reference information. This has been fixed.
+
+ * A tentative fix for
+ {#117}[https://github.com/mime-types/ruby-mime-types/issues/117] has been
+ applied, removing the only circular require dependencies that exist (and
+ for which there was code to prevent, but the current fix is simpler).
+ I have no way to verify this fix and depending on how things are loaded
by
+ +delayed_job+, this fix may not be sufficient.
+
+ * 1 governance change
+
+ * Updated to {Contributor Covenant 1.4}[Code-of-Conduct_rdoc.html].
+
+-------------------------------------------------------------------
Old:
----
mime-types-3.0.gem
New:
----
mime-types-3.1.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-mime-types.spec ++++++
--- /var/tmp/diff_new_pack.Ng74yy/_old 2016-05-29 03:13:09.000000000 +0200
+++ /var/tmp/diff_new_pack.Ng74yy/_new 2016-05-29 03:13:09.000000000 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-mime-types
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
#
Name: rubygem-mime-types
-Version: 3.0
+Version: 3.1
Release: 0
%define mod_name mime-types
%define mod_full_name %{mod_name}-%{version}
++++++ mime-types-3.0.gem -> mime-types-3.1.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.autotest new/.autotest
--- old/.autotest 2015-11-21 16:32:46.000000000 +0100
+++ new/.autotest 1970-01-01 01:00:00.000000000 +0100
@@ -1,35 +0,0 @@
-# -*- ruby -*-
-
-require 'autotest/bundler'
-require 'autotest/restart'
-require 'autotest/timestamp'
-
-def require_plugin(resource)
- require resource
-rescue LoadError
- false
-end
-
-require_plugin 'autotest/clear'
-
-Autotest.add_hook :initialize do |at|
- # at.testlib = "minitest/unit"
- #
- # at.extra_files << "../some/external/dependency.rb"
- #
- # at.libs << ":../some/external"
- #
- # at.add_exception "vendor"
- #
- # at.add_mapping(/dependency.rb/) do |f, _|
- # at.files_matching(/test_.*rb$/)
- # end
- #
- # %w(TestA TestB).each do |klass|
- # at.extra_class_map[klass] = "test/test_misc.rb"
- # end
-end
-
-# Autotest.add_hook :run_command do |at|
-# system "rake build"
-# end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.gitignore new/.gitignore
--- old/.gitignore 2015-11-21 16:32:46.000000000 +0100
+++ new/.gitignore 1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-*.md
-*.swp
-*~
-.rake_tasks~
-.source_index
-.vagrant
-Gemfile.lock
-Vagrantfile
-coverage
-doc
-html
-pkg
-publish
-test/cache.tst
-tmp/
-.rubocop.yml
-.byebug_history
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.hoerc new/.hoerc
--- old/.hoerc 2015-11-21 16:32:46.000000000 +0100
+++ new/.hoerc 1970-01-01 01:00:00.000000000 +0100
@@ -1,20 +0,0 @@
----
-exclude: !ruby/regexp '/
- \.(tmp|swp)$
- |
- (CVS|tmp)\/
- |
- (?i:TAGS)
- |
- \.(svn|git|hg|DS_Store|idea|vagrant)\/
- |
- Gemfile(?:\.lock)?
- |
- \.(rubocop|coveralls|pullreview|travis).yml$
- |
- \.gemspec
- |
- \.byebug_history
- |
- Vagrantfile
- /x'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Code-of-Conduct.rdoc new/Code-of-Conduct.rdoc
--- old/Code-of-Conduct.rdoc 2015-11-21 16:32:46.000000000 +0100
+++ new/Code-of-Conduct.rdoc 2016-05-22 23:00:39.000000000 +0200
@@ -1,41 +1,74 @@
-== Contributor Code of Conduct
+== Contributor Covenant Code of Conduct
-As contributors and maintainers of this project, and in the interest of
-fostering an open and welcoming community, we pledge to respect all people who
-contribute through reporting issues, posting feature requests, updating
-documentation, submitting pull requests or patches, and other activities.
-
-We are committed to making participation in this project a harassment-free
-experience for everyone, regardless of level of experience, gender, gender
-identity and expression, sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age,
+body size, disability, ethnicity, gender identity and expression, level of
+experience, nationality, personal appearance, race, religion, or sexual
+identity and orientation.
+
+=== Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
+* The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
-* Publishing other's private information, such as physical or electronic
- addresses, without explicit permission
-* Other unethical or unprofessional conduct.
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+=== Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct. By adopting this Code of Conduct,
-project maintainers commit themselves to fairly and consistently applying these
-principles to every aspect of managing this project. Project maintainers who do
-not follow or enforce the Code of Conduct may be permanently removed from the
-project team.
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+=== Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an
+appointed representative at an online or offline event. Representation of a
+project may be further defined and clarified by project maintainers.
-This code of conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
+=== Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by opening an issue or contacting one or more of the project
-maintainers.
+reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an
+incident. Further details of specific enforcement policies may be posted
+separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+=== Attribution
-This Code of Conduct is adapted from the
-{Contributor Covenant}[http://contributor-covenant.org], version 1.2.0,
+This Code of Conduct is adapted from the {Contributor
+Covenant}[http://contributor-covenant.org], version 1.4,
available at
-{http://contributor-covenant.org/version/1/2/0/}[http://contributor-covenant.org/version/1/2/0/].
+{http://contributor-covenant.org/version/1/4/}[http://contributor-covenant.org/version/1/4/].
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Contributing.rdoc new/Contributing.rdoc
--- old/Contributing.rdoc 2015-11-21 16:32:46.000000000 +0100
+++ new/Contributing.rdoc 2016-05-22 23:00:39.000000000 +0200
@@ -18,48 +18,9 @@
=== Adding or Modifying MIME Types
-The mime-types registry is loaded from encoded files in +data+. These are not
-editable and cannot be compared meaningfully in a pull request; pull requests
-that include changes to these files will require amendment to revert these
-files.
-
-New or modified MIME types should be edited in the appropriate YAML file under
-+type-lists+. The format is as shown below for the +application/xml+ MIME type
-in +type-lists/application.yml+.
-
- - !ruby/object:MIME::Type
- content-type: application/xml
- encoding: 8bit
- extensions:
- - xml
- - xsl
- xrefs: !ruby/hash:MIME::Types::Container
- rfc:
- - rfc3023
- registered: true
-
-There are other fields that can be added, matching the fields discussed in the
-documentation for MIME::Type. Pull requests for MIME types should just contain
-the changes to the YAML files for the new or modified MIME types; I will
-convert the YAML files to JSON prior to a new release. I would rather not have
-to verify that the JSON matches the YAML changes, which is why it is not
-necessary to convert for the pull request.
-
-If you are making a change for a private fork, use <tt>rake
-convert:yaml:json</tt> to convert the YAML to JSON, or <tt>rake
-convert:yaml:columnar</tt> to convert it to the new columnar format.
-
-==== Updating Types from the IANA or Apache Lists
-
-If you are maintaining a private fork and wish to update your copy of the MIME
-types registry used by this gem, you can do this with the rake tasks:
-
- $ rake mime:iana
- $ rake mime:apache
-
-Both of these require
-{Nokogiri}[http://www.nokogiri.org/tutorials/installing_nokogiri.html], which
-is not installed by default. Install it in the usual way for your Ruby.
+The mime-types registry is no longer contained in mime-types, but in
+{mime-types-data}[https://github.com/mime-types/mime-types-data]. Please see
+that project for contributions there.
=== Test Dependencies
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/History.rdoc new/History.rdoc
--- old/History.rdoc 2015-11-21 16:32:46.000000000 +0100
+++ new/History.rdoc 2016-05-22 23:00:39.000000000 +0200
@@ -1,3 +1,32 @@
+== 3.1 / 2016-05-22
+
+* 1 documentation change:
+
+ * Tim Smith (@tas50) updated the build badges to be SVGs to improve
+ readability on high-density (retina) screens with pull request
+ {#112}[https://github.com/mime-types/ruby-mime-types/pull/112].
+
+* 3 bug fixes
+
+ * A test for MIME::Types::Cache fails under Ruby 2.3 because of frozen
+ strings, {#118}[https://github.com/mime-types/ruby-mime-types/issues/118].
+ This has been fixed.
+
+ * The JSON data has been incorrectly encoded since the release of mime-types
+ 3 on the +xrefs+ field, because of the switch to using a Set to store
+ cross-reference information. This has been fixed.
+
+ * A tentative fix for
+ {#117}[https://github.com/mime-types/ruby-mime-types/issues/117] has been
+ applied, removing the only circular require dependencies that exist (and
+ for which there was code to prevent, but the current fix is simpler).
+ I have no way to verify this fix and depending on how things are loaded by
+ +delayed_job+, this fix may not be sufficient.
+
+* 1 governance change
+
+ * Updated to {Contributor Covenant 1.4}[Code-of-Conduct_rdoc.html].
+
== 3.0 / 2015-11-21
* 2 governance changes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Licence.rdoc new/Licence.rdoc
--- old/Licence.rdoc 2015-11-21 16:32:46.000000000 +0100
+++ new/Licence.rdoc 2016-05-22 23:00:39.000000000 +0200
@@ -1,6 +1,6 @@
== Licence
-* Copyright 2003–2015 Austin Ziegler.
+* Copyright 2003–2015 Austin Ziegler and contributors.
The software in this repository is made available under the MIT license.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Manifest.txt new/Manifest.txt
--- old/Manifest.txt 2015-11-21 16:32:46.000000000 +0100
+++ new/Manifest.txt 2016-05-22 23:00:39.000000000 +0200
@@ -1,7 +1,3 @@
-.autotest
-.gemtest
-.gitignore
-.hoerc
Code-of-Conduct.rdoc
Contributing.rdoc
History.rdoc
@@ -13,6 +9,7 @@
lib/mime/type.rb
lib/mime/type/columnar.rb
lib/mime/types.rb
+lib/mime/types/_columnar.rb
lib/mime/types/cache.rb
lib/mime/types/columnar.rb
lib/mime/types/container.rb
@@ -21,12 +18,6 @@
lib/mime/types/loader.rb
lib/mime/types/logger.rb
lib/mime/types/registry.rb
-support/benchmarks/load.rb
-support/benchmarks/load_allocations.rb
-support/benchmarks/object_counts.rb
-support/profile/columnar.rb
-support/profile/columnar_full.rb
-support/profile/full.rb
test/bad-fixtures/malformed
test/fixture/json.json
test/fixture/old-data
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.rdoc new/README.rdoc
--- old/README.rdoc 2015-11-21 16:32:46.000000000 +0100
+++ new/README.rdoc 2016-05-22 23:00:39.000000000 +0200
@@ -4,8 +4,8 @@
code :: https://github.com/mime-types/ruby-mime-types/
bugs :: https://github.com/mime-types/ruby-mime-types/issues
rdoc :: http://rdoc.info/gems/mime-types/
-continuous integration :: {<img
src="https://travis-ci.org/mime-types/ruby-mime-types.png"
/>}[https://travis-ci.org/mime-types/ruby-mime-types]
-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]
+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]
+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]
== Description
@@ -83,8 +83,8 @@
puts text == 'text/x-plain' # => false
puts 'text/x-plain' == text # => false
- puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
- puts MIME::Type.i18n_key('x-appl/x-zip') # => 'appl.zip'
+ puts MIME::Type.simplified('x-appl/x-zip') # => 'x-appl/x-zip'
+ puts MIME::Type.i18n_key('x-appl/x-zip') # => 'x-appl.x-zip'
puts text.like?('text/x-plain') # => true
puts text.like?(MIME::Type.new('x-text/x-plain')) # => true
@@ -111,7 +111,7 @@
xwingz = MIME::Types['application/x-Wingz'].first # => application/x-Wingz
puts xwingz.content_type # => 'application/x-Wingz'
- puts xwingz.simplified # => 'application/wingz'
+ puts xwingz.simplified # => 'application/x-wingz'
=== Columnar Store
@@ -183,19 +183,17 @@
incremented, MINOR will be set to zero, and PATCH will be reset to the
implied zero.
-2. If an API (code) feature is added that does not break compatibilty OR if
- there are MIME types added, removed, or changed in the registry, the MINOR
- version will be incremented and PATCH will be reset to the implied zero.
+2. If an API (code) feature is added that does not break compatibilty, the
+ MINOR version will be incremented and PATCH will be reset to the implied
zero.
3. If there is a bugfix to a feature added in the most recent MAJOR.MINOR
- release, OR if purely typographical errors are fixed in MIME types, the
- implied PATCH value will be incremented resulting in MAJOR.MINOR.PATCH.
+ release, the implied PATCH value will be incremented resulting in
+ MAJOR.MINOR.PATCH.
-In practical terms, there should be a MINOR release roughly monthly to track
-updated or changed MIME types from the official IANA registry. This does not
-indicate when new API features have been added, but all minor versions of
-mime-types 2.x will be backwards compatible; the interfaces marked deprecated
-will be removed in mime-types 3.x.
+In practical terms, there will be fewer releases of mime-types focussing on
+features because of the existence of the [mime-types-data][] gem, and if
+features are marked deprecated in the course of mime-types 3.x, they will not
+be removed until mime-types 4.x or possibly later.
:include: Code-of-Conduct.rdoc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Rakefile new/Rakefile
--- old/Rakefile 2015-11-21 16:32:46.000000000 +0100
+++ new/Rakefile 2016-05-22 23:00:39.000000000 +0200
@@ -33,6 +33,7 @@
extra_dev_deps << ['minitest-autotest', '~> 1.0']
extra_dev_deps << ['minitest-focus', '~> 1.0']
extra_dev_deps << ['minitest-bonus-assertions', '~> 2.0']
+ extra_dev_deps << ['minitest-hooks', '~> 1.4']
extra_dev_deps << ['rake', '~> 10.0']
extra_dev_deps << ['fivemat', '~> 1.3' ]
extra_dev_deps << ['minitest-rg', '~> 5.2']
@@ -188,8 +189,8 @@
end
FileList['*.rdoc'].each do |name|
- rdoc = "#{name}.rdoc"
- mark = "#{name}.md"
+ rdoc = name
+ mark = "#{File.basename(name, '.rdoc')}.md"
file mark => [ rdoc, :setup ] do |t|
puts "#{rdoc} => #{mark}"
@@ -208,6 +209,38 @@
task docs: 'convert:docs:run'
end
+task 'deps:top', [ :number ] do |_, args|
+ require 'net/http'
+ require 'json'
+
+ def rubygems_get(gem_name: '', endpoint: '')
+ path = File.join('/api/v1/gems/', gem_name, endpoint).chomp('/') + '.json'
+ Net::HTTP.start('rubygems.org', use_ssl: true) do |http|
+ JSON.parse(http.get(path).body)
+ end
+ end
+
+ results = rubygems_get(
+ gem_name: 'mime-types',
+ endpoint: 'reverse_dependencies'
+ )
+
+ weighted_results = {}
+ results.each do |name|
+ begin
+ weighted_results[name] = rubygems_get(gem_name: name)['downloads']
+ rescue => e
+ puts "#{name} #{e.message}"
+ end
+ end
+
+ weighted_results.sort { |(_k1, v1), (_k2, v2)|
+ v2 <=> v1
+ }.first(args.number || 50).each_with_index do |(k, v), i|
+ puts "#{i}) #{k}: #{v}"
+ end
+end
+
task :console do
arguments = %w(pry)
arguments.push(*spec.spec.require_paths.map { |dir| "-I#{dir}" })
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/mime/type.rb new/lib/mime/type.rb
--- old/lib/mime/type.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/lib/mime/type.rb 2016-05-22 23:00:39.000000000 +0200
@@ -55,7 +55,7 @@
end
# The released version of the mime-types library.
- VERSION = '3.0'
+ VERSION = '3.1'
include Comparable
@@ -450,7 +450,14 @@
coder['obsolete'] = obsolete?
coder['use-instead'] = use_instead if use_instead
end
- coder['xrefs'] = xrefs unless xrefs.empty?
+ unless xrefs.empty?
+ {}.tap do |hash|
+ xrefs.each do |k, v|
+ hash[k] = v.sort.to_a
+ end
+ coder['xrefs'] = hash
+ end
+ end
coder['registered'] = registered?
coder['signature'] = signature? if signature?
coder
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/mime/types/_columnar.rb
new/lib/mime/types/_columnar.rb
--- old/lib/mime/types/_columnar.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/mime/types/_columnar.rb 2016-05-22 23:00:39.000000000 +0200
@@ -0,0 +1,135 @@
+require 'mime/type/columnar'
+
+# MIME::Types::Columnar is used to extend a MIME::Types container to load data
+# by columns instead of from JSON or YAML. Column loads of MIME types loaded
+# through the columnar store are synchronized with a Mutex.
+#
+# MIME::Types::Columnar is not intended to be used directly, but will be added
+# to an instance of MIME::Types when it is loaded with
+# MIME::Types::Loader#load_columnar.
+module MIME::Types::Columnar
+ LOAD_MUTEX = Mutex.new # :nodoc:
+
+ def self.extended(obj) # :nodoc:
+ super
+ obj.instance_variable_set(:@__mime_data__, [])
+ obj.instance_variable_set(:@__files__, Set.new)
+ end
+
+ # Load the first column data file (type and extensions).
+ def load_base_data(path) #:nodoc:
+ @__root__ = path
+
+ each_file_line('content_type', false) do |line|
+ line = line.split
+ content_type = line.shift
+ extensions = line
+ # content_type, *extensions = line.split
+
+ type = MIME::Type::Columnar.new(self, content_type, extensions)
+ @__mime_data__ << type
+ add(type)
+ end
+
+ self
+ end
+
+ private
+
+ def each_file_line(name, lookup = true)
+ LOAD_MUTEX.synchronize do
+ next if @__files__.include?(name)
+
+ i = -1
+ column = File.join(@__root__, "mime.#{name}.column")
+
+ IO.readlines(column, encoding: 'UTF-8'.freeze).each do |line|
+ line.chomp!
+
+ if lookup
+ type = @__mime_data__[i += 1] or next
+ yield type, line
+ else
+ yield line
+ end
+ end
+
+ @__files__ << name
+ end
+ end
+
+ def load_encoding
+ each_file_line('encoding') do |type, line|
+ pool ||= {}
+ line.freeze
+ type.instance_variable_set(:@encoding, (pool[line] ||= line))
+ end
+ end
+
+ def load_docs
+ each_file_line('docs') do |type, line|
+ type.instance_variable_set(:@docs, opt(line))
+ end
+ end
+
+ def load_preferred_extension
+ each_file_line('pext') do |type, line|
+ type.instance_variable_set(:@preferred_extension, opt(line))
+ end
+ end
+
+ def load_flags
+ each_file_line('flags') do |type, line|
+ line = line.split
+ type.instance_variable_set(:@obsolete, flag(line.shift))
+ type.instance_variable_set(:@registered, flag(line.shift))
+ type.instance_variable_set(:@signature, flag(line.shift))
+ end
+ end
+
+ def load_xrefs
+ each_file_line('xrefs') { |type, line|
+ type.instance_variable_set(:@xrefs, dict(line, array: true))
+ }
+ end
+
+ def load_friendly
+ each_file_line('friendly') { |type, line|
+ type.instance_variable_set(:@friendly, dict(line))
+ }
+ end
+
+ def load_use_instead
+ each_file_line('use_instead') do |type, line|
+ type.instance_variable_set(:@use_instead, opt(line))
+ end
+ end
+
+ def dict(line, array: false)
+ if line == '-'.freeze
+ {}
+ else
+ line.split('|'.freeze).each_with_object({}) { |l, h|
+ k, v = l.split('^'.freeze)
+ v = nil if v.empty?
+ h[k] = array ? Array(v) : v
+ }
+ end
+ end
+
+ def arr(line)
+ if line == '-'.freeze
+ []
+ else
+ line.split('|'.freeze).flatten.compact.uniq
+ end
+ end
+
+ def opt(line)
+ line unless line == '-'.freeze
+ end
+
+ def flag(line)
+ line == '1'.freeze ? true : false
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/mime/types/columnar.rb
new/lib/mime/types/columnar.rb
--- old/lib/mime/types/columnar.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/lib/mime/types/columnar.rb 2016-05-22 23:00:39.000000000 +0200
@@ -1,142 +1 @@
-module MIME
- class Types
- end
-end
-
-require 'mime/type/columnar'
-
-# MIME::Types::Columnar is used to extend a MIME::Types container to load data
-# by columns instead of from JSON or YAML. Column loads of MIME types loaded
-# through the columnar store are synchronized with a Mutex.
-#
-# MIME::Types::Columnar is not intended to be used directly, but will be added
-# to an instance of MIME::Types when it is loaded with
-# MIME::Types::Loader#load_columnar.
-module MIME::Types::Columnar
- LOAD_MUTEX = Mutex.new # :nodoc:
-
- def self.extended(obj) # :nodoc:
- super
- obj.instance_variable_set(:@__mime_data__, [])
- obj.instance_variable_set(:@__files__, Set.new)
- end
-
- # Load the first column data file (type and extensions).
- def load_base_data(path) #:nodoc:
- @__root__ = path
-
- each_file_line('content_type', false) do |line|
- line = line.split
- content_type = line.shift
- extensions = line
- # content_type, *extensions = line.split
-
- type = MIME::Type::Columnar.new(self, content_type, extensions)
- @__mime_data__ << type
- add(type)
- end
-
- self
- end
-
- private
-
- def each_file_line(name, lookup = true)
- LOAD_MUTEX.synchronize do
- next if @__files__.include?(name)
-
- i = -1
- column = File.join(@__root__, "mime.#{name}.column")
-
- IO.readlines(column, encoding: 'UTF-8'.freeze).each do |line|
- line.chomp!
-
- if lookup
- type = @__mime_data__[i += 1] or next
- yield type, line
- else
- yield line
- end
- end
-
- @__files__ << name
- end
- end
-
- def load_encoding
- each_file_line('encoding') do |type, line|
- pool ||= {}
- line.freeze
- type.instance_variable_set(:@encoding, (pool[line] ||= line))
- end
- end
-
- def load_docs
- each_file_line('docs') do |type, line|
- type.instance_variable_set(:@docs, opt(line))
- end
- end
-
- def load_preferred_extension
- each_file_line('pext') do |type, line|
- type.instance_variable_set(:@preferred_extension, opt(line))
- end
- end
-
- def load_flags
- each_file_line('flags') do |type, line|
- line = line.split
- type.instance_variable_set(:@obsolete, flag(line.shift))
- type.instance_variable_set(:@registered, flag(line.shift))
- type.instance_variable_set(:@signature, flag(line.shift))
- end
- end
-
- def load_xrefs
- each_file_line('xrefs') { |type, line|
- type.instance_variable_set(:@xrefs, dict(line, array: true))
- }
- end
-
- def load_friendly
- each_file_line('friendly') { |type, line|
- type.instance_variable_set(:@friendly, dict(line))
- }
- end
-
- def load_use_instead
- each_file_line('use_instead') do |type, line|
- type.instance_variable_set(:@use_instead, opt(line))
- end
- end
-
- def dict(line, array: false)
- if line == '-'.freeze
- {}
- else
- line.split('|'.freeze).each_with_object({}) { |l, h|
- k, v = l.split('^'.freeze)
- v = nil if v.empty?
- h[k] = array ? Array(v) : v
- }
- end
- end
-
- def arr(line)
- if line == '-'.freeze
- []
- else
- line.split('|'.freeze).flatten.compact.uniq
- end
- end
-
- def opt(line)
- line unless line == '-'.freeze
- end
-
- def flag(line)
- line == '1'.freeze ? true : false
- end
-end
-
-require 'mime/types' unless defined?(MIME::Types::VERSION)
+require 'mime/types'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/mime/types/full.rb new/lib/mime/types/full.rb
--- old/lib/mime/types/full.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/lib/mime/types/full.rb 2016-05-22 23:00:39.000000000 +0200
@@ -10,8 +10,8 @@
{ columnar: false }
end
end
-
- require 'mime/types'
end
end
end
+
+require 'mime/types'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/mime/types.rb new/lib/mime/types.rb
--- old/lib/mime/types.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/lib/mime/types.rb 2016-05-22 23:00:39.000000000 +0200
@@ -5,11 +5,7 @@
end
end
-require 'mime/types/logger'
-require 'mime/types/container'
require 'mime/type'
-require 'mime/types/cache'
-require 'mime/types/loader'
# MIME::Types is a registry of MIME types. It is both a class (created with
# MIME::Types.new) and a default registry (loaded automatically or through
@@ -224,5 +220,9 @@
end
end
-require 'mime/types/columnar' unless defined?(MIME::Types::Columnar)
+require 'mime/types/cache'
+require 'mime/types/container'
+require 'mime/types/loader'
+require 'mime/types/logger'
+require 'mime/types/_columnar'
require 'mime/types/registry'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2015-11-21 16:32:46.000000000 +0100
+++ new/metadata 2016-05-22 23:00:39.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: mime-types
version: !ruby/object:Gem::Version
- version: '3.0'
+ version: '3.1'
platform: ruby
authors:
- Austin Ziegler
autorequire:
bindir: bin
cert_chain: []
-date: 2015-11-21 00:00:00.000000000 Z
+date: 2016-05-22 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: mime-types-data
@@ -30,14 +30,14 @@
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '5.8'
+ version: '5.9'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '5.8'
+ version: '5.9'
- !ruby/object:Gem::Dependency
name: rdoc
requirement: !ruby/object:Gem::Requirement
@@ -165,6 +165,20 @@
- !ruby/object:Gem::Version
version: '2.0'
- !ruby/object:Gem::Dependency
+ name: minitest-hooks
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - "~>"
+ - !ruby/object:Gem::Version
+ version: '1.4'
+ type: :development
+ prerelease: false
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - "~>"
+ - !ruby/object:Gem::Version
+ version: '1.4'
+- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
requirements:
@@ -226,14 +240,14 @@
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '3.14'
+ version: '3.15'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '3.14'
+ version: '3.15'
description: |-
The mime-types library provides a library and registry for information about
MIME content type definitions. It can be used to determine defined filename
@@ -259,10 +273,6 @@
- Manifest.txt
- README.rdoc
files:
-- ".autotest"
-- ".gemtest"
-- ".gitignore"
-- ".hoerc"
- Code-of-Conduct.rdoc
- Contributing.rdoc
- History.rdoc
@@ -274,6 +284,7 @@
- lib/mime/type.rb
- lib/mime/type/columnar.rb
- lib/mime/types.rb
+- lib/mime/types/_columnar.rb
- lib/mime/types/cache.rb
- lib/mime/types/columnar.rb
- lib/mime/types/container.rb
@@ -282,12 +293,6 @@
- lib/mime/types/loader.rb
- lib/mime/types/logger.rb
- lib/mime/types/registry.rb
-- support/benchmarks/load.rb
-- support/benchmarks/load_allocations.rb
-- support/benchmarks/object_counts.rb
-- support/profile/columnar.rb
-- support/profile/columnar_full.rb
-- support/profile/full.rb
- test/bad-fixtures/malformed
- test/fixture/json.json
- test/fixture/old-data
@@ -321,7 +326,7 @@
version: '0'
requirements: []
rubyforge_project:
-rubygems_version: 2.4.8
+rubygems_version: 2.6.4
signing_key:
specification_version: 4
summary: The mime-types library provides a library and registry for
information about
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/support/benchmarks/load.rb
new/support/benchmarks/load.rb
--- old/support/benchmarks/load.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/support/benchmarks/load.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,65 +0,0 @@
-# -*- ruby encoding: utf-8 -*-
-
-require 'benchmark'
-require 'mime/types'
-
-module Benchmarks
- class Load
- def self.report(load_path, repeats)
- new(load_path, repeats.to_i).report
- end
-
- def initialize(load_path, repeats = nil)
- @cache_file = File.expand_path('../cache.mtc', __FILE__)
- @repeats = repeats.to_i
- @repeats = 50 if @repeats <= 0
- @load_path = load_path
- end
-
- def reload_mime_types(repeats = 1, force: false, columnar: false, cache:
false)
- loader = MIME::Types::Loader.new
-
- repeats.times {
- types = MIME::Types::Cache.load if cache
- unless types
- types = loader.load(columnar: columnar)
- MIME::Types::Cache.save(types) if cache
- end
- types.first.to_h if force
- }
- end
-
- def report
- remove_cache
-
- Benchmark.bm(30) do |mark|
- mark.report('Normal') { reload_mime_types(@repeats) }
- mark.report('Columnar') {
- reload_mime_types(@repeats, columnar: true)
- }
- mark.report('Columnar Full') {
- reload_mime_types(@repeats, columnar: true, force: true)
- }
-
- ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
- mark.report('Cache Initialize') { reload_mime_types(cache: true) }
- mark.report('Cached') { reload_mime_types(@repeats, cache: true) }
-
- remove_cache
- ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
- mark.report('Columnar Cache Initialize') {
- reload_mime_types(columnar: true, cache: true)
- }
- mark.report('Columnar Cached') {
- reload_mime_types(@repeats, columnar: true, cache: true)
- }
- end
- ensure
- remove_cache
- end
-
- def remove_cache
- File.unlink(@cache_file) if File.exist?(@cache_file)
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/support/benchmarks/load_allocations.rb
new/support/benchmarks/load_allocations.rb
--- old/support/benchmarks/load_allocations.rb 2015-11-21 16:32:46.000000000
+0100
+++ new/support/benchmarks/load_allocations.rb 1970-01-01 01:00:00.000000000
+0100
@@ -1,90 +0,0 @@
-# -*- ruby encoding: utf-8 -*-
-
-if RUBY_VERSION < '2.1'
- $stderr.puts "Cannot count allocations on #{RUBY_VERSION}."
- exit 1
-end
-
-begin
- require 'allocation_tracer'
-rescue LoadError
- $stderr.puts "Allocation tracking requires the gem 'allocation_tracer'."
- exit 1
-end
-
-module Benchmarks
- class LoadAllocations
- def self.report(columnar: false, full: false, top_x: nil, mime_types_only:
false)
- new(
- columnar: columnar,
- top_x: top_x,
- mime_types_only: mime_types_only,
- full: full
- ).report
- end
-
- def initialize(columnar: false, full: false, top_x: nil, mime_types_only:
false)
- @columnar = !!columnar
- @full = !!full
- @mime_types_only = !!mime_types_only
-
- @top_x = top_x
-
- return unless @top_x
- @top_x = top_x.to_i
- @top_x = 10 if @top_x <= 0
- end
-
- def report
- collect
- report_top_x if @top_x
- puts "TOTAL Allocations: #{@count}"
- end
-
- private
-
- def report_top_x
- table = @allocations.sort_by { |_, v| v.first }.reverse.first(@top_x)
- table.map! { |(location, allocs)|
- next if @mime_types_only and location.first !~ %r{mime-types/lib}
- [ location.join(':').gsub(%r{^#{Dir.pwd}/}, ''), *allocs ]
- }.compact!
-
- head = (ObjectSpace::AllocationTracer.header - [ :line ]).map {|h|
- h.to_s.split(/_/).map(&:capitalize).join(' ')
- }
- table.unshift head
-
- max_widths = [].tap do |mw|
- table.map { |row| row.lazy.map(&:to_s).map(&:length).to_a }.tap do |w|
- w.first.each_index do |i|
- mw << w.lazy.map { |r| r[i] }.max
- end
- end
- end
-
- pattern = [ '%%-%ds' ]
- pattern << ([ '%% %ds' ] * (max_widths.length - 1))
- pattern = pattern.join("\t") % max_widths
- table.each { |row| puts pattern % row }
- puts
- end
-
- def collect
- if @columnar
- @allocations = ObjectSpace::AllocationTracer.trace do
- require 'mime/types'
-
- MIME::Types.first.to_h if @full
- end
- else
- @allocations = ObjectSpace::AllocationTracer.trace do
- require 'mime/types/full'
- end
- end
-
- @count = ObjectSpace::AllocationTracer.allocated_count_table.values.
- inject(:+)
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/support/benchmarks/object_counts.rb
new/support/benchmarks/object_counts.rb
--- old/support/benchmarks/object_counts.rb 2015-11-21 16:32:46.000000000
+0100
+++ new/support/benchmarks/object_counts.rb 1970-01-01 01:00:00.000000000
+0100
@@ -1,43 +0,0 @@
-# -*- ruby encoding: utf-8 -*-
-
-module Benchmarks
- class ObjectCounts
- def self.report(columnar: false, full: false)
- new(columnar: columnar).report
- end
-
- def initialize(columnar: false, full: false)
- @columnar = columnar
- @full = full
- end
-
- def report
- collect
- @before.keys.grep(/T_/).map { |key|
- [ key, @after[key] - @before[key] ]
- }.sort_by { |_, delta| -delta }.each { |key, delta|
- puts '%10s +%6d' % [ key, delta ]
- }
- end
-
- private
-
- def collect
- @before = count_objects
-
- if @columnar
- require 'mime/types'
- MIME::Types.first.to_h if @full
- else
- require 'mime/types/full'
- end
-
- @after = count_objects
- end
-
- def count_objects
- GC.start
- ObjectSpace.count_objects
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/support/profile/columnar.rb
new/support/profile/columnar.rb
--- old/support/profile/columnar.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/support/profile/columnar.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-loader = MIME::Types::Loader.new
-
-50.times do
- loader.load(columnar: true)
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/support/profile/columnar_full.rb
new/support/profile/columnar_full.rb
--- old/support/profile/columnar_full.rb 2015-11-21 16:32:46.000000000
+0100
+++ new/support/profile/columnar_full.rb 1970-01-01 01:00:00.000000000
+0100
@@ -1,5 +0,0 @@
-loader = MIME::Types::Loader.new
-
-50.times do
- loader.load(columnar: true).first.to_h
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/support/profile/full.rb new/support/profile/full.rb
--- old/support/profile/full.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/support/profile/full.rb 1970-01-01 01:00:00.000000000 +0100
@@ -1,5 +0,0 @@
-loader = MIME::Types::Loader.new
-
-50.times do
- loader.load(columnar: false)
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/minitest_helper.rb new/test/minitest_helper.rb
--- old/test/minitest_helper.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/test/minitest_helper.rb 2016-05-22 23:00:40.000000000 +0200
@@ -8,5 +8,6 @@
require 'minitest/focus'
require 'minitest/rg'
require 'minitest-bonus-assertions'
+require 'minitest/hooks'
ENV['RUBY_MIME_TYPES_LAZY_LOAD'] = 'yes'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_mime_types.rb new/test/test_mime_types.rb
--- old/test/test_mime_types.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/test/test_mime_types.rb 2016-05-22 23:00:40.000000000 +0200
@@ -43,7 +43,7 @@
end
end
- describe '#\[]' do
+ describe '#[]' do
it 'can be searched with a MIME::Type' do
text_plain = MIME::Type.new('text/plain')
assert_includes mime_types[text_plain], 'text/plain'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_mime_types_cache.rb
new/test/test_mime_types_cache.rb
--- old/test/test_mime_types_cache.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/test/test_mime_types_cache.rb 2016-05-22 23:00:40.000000000 +0200
@@ -4,16 +4,23 @@
require 'minitest_helper'
describe MIME::Types::Cache do
- def setup
+ include Minitest::Hooks
+
+ MUTEX = Mutex.new
+
+ def around
require 'fileutils'
- @cache_file = File.expand_path('../cache.tst', __FILE__)
- ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
- clear_cache_file
- end
- def teardown
- clear_cache_file
- ENV.delete('RUBY_MIME_TYPES_CACHE')
+ MUTEX.synchronize do
+ @cache_file = File.expand_path('../cache.tst', __FILE__)
+ ENV['RUBY_MIME_TYPES_CACHE'] = @cache_file
+ clear_cache_file
+
+ super
+
+ clear_cache_file
+ ENV.delete('RUBY_MIME_TYPES_CACHE')
+ end
end
def reset_mime_types
@@ -36,10 +43,12 @@
end
it 'outputs an error when there is an invalid version' do
- v = MIME::Types::Data::VERSION.dup
- MIME::Types::Data::VERSION.gsub!(/.*/, '0.0')
+ v = MIME::Types::Data::VERSION
+ MIME::Types::Data.send(:remove_const, :VERSION)
+ MIME::Types::Data.const_set(:VERSION, '0.0')
MIME::Types::Cache.save
- MIME::Types::Data::VERSION.gsub!(/.*/, v)
+ MIME::Types::Data.send(:remove_const, :VERSION)
+ MIME::Types::Data.const_set(:VERSION, v)
MIME::Types.instance_variable_set(:@__types__, nil)
assert_output '', /MIME::Types cache: invalid version/ do
MIME::Types['text/html']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/test/test_mime_types_class.rb
new/test/test_mime_types_class.rb
--- old/test/test_mime_types_class.rb 2015-11-21 16:32:46.000000000 +0100
+++ new/test/test_mime_types_class.rb 2016-05-22 23:00:40.000000000 +0200
@@ -29,7 +29,7 @@
end
end
- describe '.\[]' do
+ describe '.[]' do
it 'can be searched with a MIME::Type' do
text_plain = MIME::Type.new('text/plain')
assert_includes MIME::Types[text_plain], 'text/plain'