Skip to content

Commit

Permalink
Update minimum ruby version and fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
alebruck committed Oct 12, 2019
1 parent ecdd65e commit b720530
Show file tree
Hide file tree
Showing 35 changed files with 47 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AllCops:
Exclude:
- 'vendor/**/*'
- 'tmp/**/*'
TargetRubyVersion: '2.2'
TargetRubyVersion: '2.3'

# This doesn't take into account retrying from an exception
Lint/HandleExceptions:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

# Specify your gem's dependencies in bootsnap.gemspec
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('rake/extensiontask')
require('bundler/gem_tasks')

Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require("bundler/setup")
require("bootsnap")
Expand Down
3 changes: 2 additions & 1 deletion bootsnap.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
# frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require('bootsnap/version')
Expand Down Expand Up @@ -26,7 +27,7 @@ Gem::Specification.new do |spec|
end
spec.require_paths = %w(lib)

spec.required_ruby_version = '>= 2.0.0'
spec.required_ruby_version = '>= 2.3.0'

if RUBY_PLATFORM =~ /java/
spec.platform = 'java'
Expand Down
1 change: 1 addition & 0 deletions ext/bootsnap/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require("mkmf")
$CFLAGS << ' -O3 '
$CFLAGS << ' -std=c99'
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative('bootsnap/version')
require_relative('bootsnap/bundler')
require_relative('bootsnap/load_path_cache')
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/bundler.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
extend(self)

Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/compile_cache.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
module CompileCache
Error = Class.new(StandardError)
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/compile_cache/iseq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('bootsnap/bootsnap')
require('zlib')

Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/compile_cache/yaml.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('bootsnap/bootsnap')

module Bootsnap
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/explicit_require.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
module ExplicitRequire
ARCHDIR = RbConfig::CONFIG['archdir']
Expand Down
4 changes: 2 additions & 2 deletions lib/bootsnap/load_path_cache/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def find(feature)
# native dynamic extension, e.g. .bundle or .so), we know it was a
# failure and there's nothing more we can do to find the file.
# no extension, .rb, (.bundle or .so)
when '', *CACHED_EXTENSIONS # rubocop:disable Performance/CaseWhenSplat
when '', *CACHED_EXTENSIONS
nil
# Ruby allows specifying native extensions as '.so' even when DLEXT
# is '.bundle'. This is where we handle that case.
Expand Down Expand Up @@ -144,7 +144,7 @@ def push_paths_locked(*paths)
expanded_path = p.expanded_path
entries, dirs = p.entries_and_dirs(@store)
# push -> low precedence -> set only if unset
dirs.each { |dir| @dirs[dir] ||= path }
dirs.each { |dir| @dirs[dir] ||= path }
entries.each { |rel| @index[rel] ||= expanded_path }
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/load_path_cache/change_observer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
module LoadPathCache
module ChangeObserver
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/load_path_cache/core_ext/active_support.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
module LoadPathCache
module CoreExt
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/load_path_cache/core_ext/kernel_require.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
module LoadPathCache
module CoreExt
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/load_path_cache/core_ext/loaded_features.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class << $LOADED_FEATURES
alias_method(:delete_without_bootsnap, :delete)
def delete(key)
Expand Down
6 changes: 3 additions & 3 deletions lib/bootsnap/load_path_cache/loaded_features_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def register(short, long = nil)

# Do we have a filename with an elidable extension, e.g.,
# 'bundler.rb', or 'libgit2.so'?
altname = if is_extension_elidable(short)
altname = if extension_elidable?(short)
# Strip the extension off, e.g. 'bundler.rb' -> 'bundler'.
strip_extension_if_elidable(short)
elsif long && (ext = File.extname(long))
Expand Down Expand Up @@ -132,12 +132,12 @@ def register(short, long = nil)
# with callling a Ruby file 'x.dylib.rb' and then requiring it as 'x.dylib'.)
#
# See <https://ruby-doc.org/core-2.6.4/Kernel.html#method-i-require>.
def is_extension_elidable(f)
def extension_elidable?(f)
f.end_with?('.rb', '.so', '.o', '.dll', '.dylib')
end

def strip_extension_if_elidable(f)
if is_extension_elidable(f)
if extension_elidable?(f)
f.sub(STRIP_EXTENSION, '')
else
f
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/load_path_cache/path.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative('path_scanner')

module Bootsnap
Expand Down
11 changes: 6 additions & 5 deletions lib/bootsnap/load_path_cache/store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative('../explicit_require')

Bootsnap::ExplicitRequire.with_gems('msgpack') { require('msgpack') }
Expand Down Expand Up @@ -63,11 +64,11 @@ def commit_transaction
def load_data
@data = begin
MessagePack.load(File.binread(@store_path))
# handle malformed data due to upgrade incompatability
rescue Errno::ENOENT, MessagePack::MalformedFormatError, MessagePack::UnknownExtTypeError, EOFError
{}
rescue ArgumentError => e
e.message =~ /negative array size/ ? {} : raise
# handle malformed data due to upgrade incompatability
rescue Errno::ENOENT, MessagePack::MalformedFormatError, MessagePack::UnknownExtTypeError, EOFError
{}
rescue ArgumentError => e
e.message =~ /negative array size/ ? {} : raise
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/setup.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative('../bootsnap')

env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
Expand Down
1 change: 1 addition & 0 deletions lib/bootsnap/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Bootsnap
VERSION = "1.4.5"
end
1 change: 1 addition & 0 deletions test/bundler_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

class BundlerTest < Minitest::Test
Expand Down
1 change: 1 addition & 0 deletions test/compile_cache_handler_errors_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

class CompileCacheHandlerErrorsTest < Minitest::Test
Expand Down
7 changes: 4 additions & 3 deletions test/compile_cache_key_format_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')
require('tempfile')
require('tmpdir')
Expand Down Expand Up @@ -35,10 +36,10 @@ def test_key_compile_option_stable

def test_key_ruby_revision
key = cache_key_for_file(__FILE__)
if RUBY_REVISION.is_a?(String)
exp = [Help.fnv1a_64(RUBY_REVISION) >> 32].pack("L")
exp = if RUBY_REVISION.is_a?(String)
[Help.fnv1a_64(RUBY_REVISION) >> 32].pack("L")
else
exp = [RUBY_REVISION].pack("L")
[RUBY_REVISION].pack("L")
end
assert_equal(exp, key[R[:ruby_revision]])
end
Expand Down
1 change: 1 addition & 0 deletions test/compile_cache_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

class CompileCacheTest < Minitest::Test
Expand Down
1 change: 1 addition & 0 deletions test/helper_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

class HelperTest < MiniTest::Test
Expand Down
1 change: 1 addition & 0 deletions test/load_path_cache/cache_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

module Bootsnap
Expand Down
1 change: 1 addition & 0 deletions test/load_path_cache/change_observer_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

module Bootsnap
Expand Down
1 change: 1 addition & 0 deletions test/load_path_cache/loaded_features_index_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

module Bootsnap
Expand Down
1 change: 1 addition & 0 deletions test/load_path_cache/path_scanner_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')

module Bootsnap
Expand Down
1 change: 1 addition & 0 deletions test/load_path_cache/path_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')
require('bootsnap/load_path_cache')

Expand Down
1 change: 1 addition & 0 deletions test/load_path_cache/store_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require('test_helper')
require('tmpdir')
require('fileutils')
Expand Down
1 change: 1 addition & 0 deletions test/minimal_support/bootsnap_setup.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
require('bundler/setup')
require('bootsnap/setup')
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require('bundler/setup')
require('bootsnap')
Expand Down

0 comments on commit b720530

Please sign in to comment.