Rakefile in mini_mime-1.0.2 vs Rakefile in mini_mime-1.0.3
- old
+ new
@@ -1,15 +1,16 @@
+# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb']
end
-task :default => :test
+task default: :test
def pad(array)
max = []
array.each do |row|
i = 0
@@ -34,15 +35,15 @@
puts "Generating mime type DB"
require 'mime/types'
index = {}
MIME::Types.each do |type|
- type.extensions.each {|ext| (index[ext.downcase] ||= []) << type}
+ type.extensions.each { |ext| (index[ext.downcase] ||= []) << type }
end
- index.each do |k,list|
- list.sort!{|a,b| a.priority_compare(b)}
+ index.each do |k, list|
+ list.sort! { |a, b| a.priority_compare(b) }
end
buffer = []
index.each do |ext, list|
@@ -52,21 +53,21 @@
buffer << [ext.dup, mime_type.content_type.dup, mime_type.encoding.dup]
end
pad(buffer)
- buffer.sort!{|a,b| a[0] <=> b[0]}
+ buffer.sort! { |a, b| a[0] <=> b[0] }
- File.open("lib/db/ext_mime.db", File::CREAT|File::TRUNC|File::RDWR) do |f|
+ File.open("lib/db/ext_mime.db", File::CREAT | File::TRUNC | File::RDWR) do |f|
buffer.each do |row|
f.write "#{row[0]} #{row[1]} #{row[2]}\n"
end
end
puts "#{buffer.count} rows written to lib/db/ext_mime.db"
- buffer.sort!{|a,b| [a[1], a[0]] <=> [b[1], b[0]]}
+ buffer.sort! { |a, b| [a[1], a[0]] <=> [b[1], b[0]] }
# strip cause we are going to re-pad
buffer.each do |row|
row.each do |col|
col.strip!
@@ -78,10 +79,10 @@
row[0] = MIME::Types.type_for("xyz.#{row[0].strip}")[0].extensions[0].dup
end
pad(buffer)
- File.open("lib/db/content_type_mime.db", File::CREAT|File::TRUNC|File::RDWR) do |f|
+ File.open("lib/db/content_type_mime.db", File::CREAT | File::TRUNC | File::RDWR) do |f|
last = nil
count = 0
buffer.each do |row|
unless last == row[1]
f.write "#{row[0]} #{row[1]} #{row[2]}\n"