diff options
author | Austin Ziegler <austin@zieglers.ca> | 2021-06-02 10:42:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 10:42:23 -0400 |
commit | 6c8324d2396e7698296bbecf376a4a647b258057 (patch) | |
tree | 8310377885377e1f44526f69c8588c759b3aa215 /lib/mime/types/registry.rb | |
parent | b8db65ac00b8f23d4274ed47aada475a65cc24d0 (diff) | |
download | mime-types-6c8324d2396e7698296bbecf376a4a647b258057.tar.gz |
Convert to standardrb (#156)
- I mostly don’t care about this, but there are a couple of things that
Standard does that I disagree with. They are inherited from Rubocop,
but Standard fixes many of Rubocop’s nonsense rules.
- Array literal wrappers %i[], %w[], etc. are just ugly and never
should have become any sort of standard. I would be happier if this
part of standard were just completely disabled, because it‘s
unnecessary and wrong.
- Quote literals having to be %q() is equally wrong. I’ve avoided the
issue here because the generated gemspec uses both "unnecessary"
quote literals (it’s necessary if I say it’s necessary) and the
wrong wrappers (I wouldn’t use %q<>, but this is generated code).
- I still think that short hashes can be `{ foo: "bar" }`, but I’m
mostly using Elixir these days, so I don’t mind `%{foo: "bar"}`, so
I can get used to it in Ruby. It still feels wrong, almost 20 years
in.
- There are semantic differences between and / &&, or / ||, but in some
cases the reformatted code is substantially _worse_ to read. Again,
I mostly don’t _care_ about this difference, but Rubocop’s insistence
is silly; these should only be replaced where there _is_ ambiguity.
- Replacing `x = foo or next` should never be replaced with `(x = foo)
|| next`. That’s replacing something that is somewhat readable with
something damned-near unreadable. Both should be replaced with:
```ruby
x = foo
next unless x
```
- YAML.safe_load works differently between Psych 2.x and Psych 3.x, so
some updates have been made to make that work cleanly.
Overall, this introduces a lot of churn, but I think will be easier to
deal with updates to `standardrb` instead of the rapid churn that has
been Rubocop.
Diffstat (limited to 'lib/mime/types/registry.rb')
-rw-r--r-- | lib/mime/types/registry.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/mime/types/registry.rb b/lib/mime/types/registry.rb index 5c8e5c7..8d92d65 100644 --- a/lib/mime/types/registry.rb +++ b/lib/mime/types/registry.rb @@ -33,7 +33,7 @@ class << MIME::Types def type_for(filename) __types__.type_for(filename) end - alias of type_for + alias_method :of, :type_for # MIME::Types#add against the default MIME::Types registry. def add(*types) @@ -43,22 +43,22 @@ class << MIME::Types private def lazy_load? - return unless ENV.key?('RUBY_MIME_TYPES_LAZY_LOAD') + return unless ENV.key?("RUBY_MIME_TYPES_LAZY_LOAD") - MIME::Types.logger.warn <<-WARNING.chomp -Lazy loading ($RUBY_MIME_TYPES_LAZY_LOAD) is deprecated and will be removed. + MIME::Types.logger.warn <<~WARNING.chomp + Lazy loading ($RUBY_MIME_TYPES_LAZY_LOAD) is deprecated and will be removed. WARNING - (lazy = ENV['RUBY_MIME_TYPES_LAZY_LOAD']) && (lazy != 'false') + (lazy = ENV["RUBY_MIME_TYPES_LAZY_LOAD"]) && (lazy != "false") end def __types__ - (defined?(@__types__) and @__types__) or load_default_mime_types + (defined?(@__types__) && @__types__) || load_default_mime_types end unless private_method_defined?(:load_mode) def load_mode - { columnar: true } + {columnar: true} end end |