Skip to content

Commit

Permalink
Merge pull request mimemagicrb#87 from aliismayilov/frozen-string-lit…
Browse files Browse the repository at this point in the history
…erals

Ensure that frozen string literals used throughout the code
  • Loading branch information
minad authored Jul 28, 2020
2 parents 01f92d8 + 295ded4 commit a45a137
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
31 changes: 16 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- ruby-head
- jruby-19mode
- rbx-3
jobs:
include:
- rvm: 1.9.3
- rvm: 2.0.0
- rvm: 2.1
- rvm: 2.2
- rvm: 2.3
- rvm: 2.4
env: RUBYOPT="--enable-frozen-string-literal"
- rvm: 2.5
env: RUBYOPT="--enable-frozen-string-literal"
- rvm: ruby-head
env: RUBYOPT="--enable-frozen-string-literal"
before_install:
# 1. The pre-installed Bundler version on Travis is very old; causes 1.9.3 build issues
# 2. Bundler 2.0 is not supported by the whole matrix
- gem install bundler -v'< 2'
matrix:
allow_failures:
- rvm: ruby-head
- rvm: rbx-3

script:
- bundle exec rake
4 changes: 3 additions & 1 deletion lib/mimemagic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'mimemagic/tables'
require 'mimemagic/version'

Expand Down Expand Up @@ -113,7 +115,7 @@ def self.magic_match(io, method)

io.binmode if io.respond_to?(:binmode)
io.set_encoding(Encoding::BINARY) if io.respond_to?(:set_encoding)
buffer = "".force_encoding(Encoding::BINARY)
buffer = "".encode(Encoding::BINARY)

MAGIC.send(method) { |type, matches| magic_match_io(io, matches, buffer) }
end
Expand Down
2 changes: 1 addition & 1 deletion test/mimemagic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_have_hierarchy
end

def test_have_extensions
assert_equal %w(htm html), MimeMagic.new('text/html').extensions
assert_equal %w(html htm), MimeMagic.new('text/html').extensions
end

def test_have_comment
Expand Down

0 comments on commit a45a137

Please sign in to comment.