Set 2.6 as minimum ruby version for Sinatra 3 (#1699)

* Run tests for Ruby versions >= 2.6

* Remove not needed checks for methods defined

* Set required_ruby_version to >= 2.6

* Update READMEs with new Ruby versions
This commit is contained in:
Eloy Pérez 2021-10-04 02:48:38 +02:00 committed by Jordan Owens
parent 9dede30f5d
commit 9a924aa894
9 changed files with 31 additions and 66 deletions

View File

@ -15,7 +15,7 @@ jobs:
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
# TODO: Add jruby if something like allow_failures will be implemented on Actions.
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0']
ruby: [2.6, 2.7, '3.0']
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1

View File

@ -3082,9 +3082,9 @@ thin --threaded start
Die folgenden Versionen werden offiziell unterstützt:
<dl>
<dt>Ruby 2.3</dt>
<dt>Ruby 2.6</dt>
<dd>
2.3 wird vollständig unterstützt. Es gibt derzeit keine Pläne die
2.6 wird vollständig unterstützt. Es gibt derzeit keine Pläne die
offizielle Unterstützung zu beenden
</dd>
@ -3103,7 +3103,7 @@ Die folgenden Versionen werden offiziell unterstützt:
</dd>
</dl>
Versionen vor Ruby 2.2.2 werden ab Sinatra 2.0 nicht länger unterstützt.
Versionen vor Ruby 2.6 werden ab Sinatra 3.0 nicht länger unterstützt.
Nachfolgende Ruby-Versionen werden regelmäßig auf Unterstützung geprüft.

View File

@ -3075,9 +3075,9 @@ rainbows -c rainbows.conf
Las siguientes versiones de Ruby son soportadas oficialmente:
<dl>
<dt>Ruby 2.3</dt>
<dt>Ruby 2.6</dt>
<dd>
2.3 Es totalmente compatible y recomendado. Actualmente no hay planes
2.6 Es totalmente compatible y recomendado. Actualmente no hay planes
soltar el apoyo oficial para ello.
</dd>
@ -3095,7 +3095,7 @@ Las siguientes versiones de Ruby son soportadas oficialmente:
</dd>
</dl>
Las versiones de Ruby anteriores a 2.2.2 ya no son compatibles con Sinatra 2.0 .
Las versiones de Ruby anteriores a 2.6 ya no son compatibles con Sinatra 3.0 .
Siempre le prestamos atención a las nuevas versiones de Ruby.

View File

@ -3047,9 +3047,9 @@ rainbows -c rainbows.conf
The following Ruby versions are officially supported:
<dl>
<dt>Ruby 2.3</dt>
<dt>Ruby 2.6</dt>
<dd>
2.3 is fully supported and recommended. There are currently no plans to
2.6 is fully supported and recommended. There are currently no plans to
drop official support for it.
</dd>
@ -3067,7 +3067,7 @@ The following Ruby versions are officially supported:
</dd>
</dl>
Versions of Ruby before 2.3 are no longer supported as of Sinatra 2.1.0.
Versions of Ruby before 2.6 are no longer supported as of Sinatra 3.0.0.
We also keep an eye on upcoming Ruby versions.

View File

@ -3051,9 +3051,9 @@ thin --threaded start
Следующие версии Ruby официально поддерживаются:
<dl>
<dt>Ruby 2.3</dt>
<dt>Ruby 2.6</dt>
<dd>
Версия 2.3 полностью поддерживается и рекомендуется. В настоящее время нет
Версия 2.6 полностью поддерживается и рекомендуется. В настоящее время нет
планов отказаться от официальной поддержки.
</dd>
@ -3071,7 +3071,7 @@ thin --threaded start
</dd>
</dl>
Версии Ruby ниже 2.2.2 более не поддерживаются в Sinatra 2.0.
Версии Ruby ниже 2.6 более не поддерживаются в Sinatra 3.0.
Мы также следим за предстоящими к выходу версиями Ruby.

View File

@ -1,11 +1,4 @@
# frozen_string_literal: true
$stderr.puts <<EOF if !Hash.method_defined?(:slice) && !$LOAD_PATH.grep(%r{gems/activesupport}).empty? && ENV['SINATRA_ACTIVESUPPORT_WARNING'] != 'false'
WARNING: If you plan to load any of ActiveSupport's core extensions to Hash, be
sure to do so *before* loading Sinatra::Application or Sinatra::Base. If not,
you may disregard this warning.
Set SINATRA_ACTIVESUPPORT_WARNING=false in the environment to hide this warning.
EOF
module Sinatra
# A poor man's ActiveSupport::HashWithIndifferentAccess, with all the Rails-y
@ -112,19 +105,19 @@ module Sinatra
def dig(key, *other_keys)
super(convert_key(key), *other_keys)
end if method_defined?(:dig) # Added in Ruby 2.3
end
def fetch_values(*keys)
keys.map!(&method(:convert_key))
super(*keys)
end if method_defined?(:fetch_values) # Added in Ruby 2.3
end
def slice(*keys)
keys.map!(&method(:convert_key))
self.class[super(*keys)]
end if method_defined?(:slice) # Added in Ruby 2.5
end
def values_at(*keys)
keys.map!(&method(:convert_key))
@ -158,26 +151,22 @@ module Sinatra
super(other_hash.is_a?(self.class) ? other_hash : self.class[other_hash])
end
if method_defined?(:transform_values!) # Added in Ruby 2.4
def transform_values(&block)
dup.transform_values!(&block)
end
def transform_values!
super
super(&method(:convert_value))
end
def transform_values(&block)
dup.transform_values!(&block)
end
if method_defined?(:transform_keys!) # Added in Ruby 2.5
def transform_keys(&block)
dup.transform_keys!(&block)
end
def transform_values!
super
super(&method(:convert_value))
end
def transform_keys!
super
super(&method(:convert_key))
end
def transform_keys(&block)
dup.transform_keys!(&block)
end
def transform_keys!
super
super(&method(:convert_key))
end
def select(*args, &block)

View File

@ -34,7 +34,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
EOF
end
s.required_ruby_version = '>= 2.3.0'
s.required_ruby_version = '>= 2.6.0'
s.add_dependency "sinatra", version
s.add_dependency "mustermann", "~> 1.0"

View File

@ -40,7 +40,7 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
EOF
end
s.required_ruby_version = '>= 2.3.0'
s.required_ruby_version = '>= 2.6.0'
s.add_dependency 'rack', '~> 2.2'
s.add_dependency 'tilt', '~> 2.0'

View File

@ -4,10 +4,6 @@
#
require 'minitest/autorun' unless defined?(Minitest)
# Suppress the ActiveSupport warning when this test is executed independently,
# outside of the full suite, on older Rubies.
ENV['SINATRA_ACTIVESUPPORT_WARNING'] = 'false'
require_relative '../lib/sinatra/indifferent_hash'
class TestIndifferentHashBasics < Minitest::Test
@ -69,10 +65,6 @@ class TestIndifferentHashBasics < Minitest::Test
end
class TestIndifferentHash < Minitest::Test
def skip_if_lacking(meth)
skip "Hash##{meth} not supported on this Ruby" unless Hash.method_defined?(meth)
end
def setup
@hash = Sinatra::IndifferentHash[:a=>:a, ?b=>:b, 3=>3,
:simple_nested=>{ :a=>:a, ?b=>:b },
@ -158,8 +150,6 @@ class TestIndifferentHash < Minitest::Test
end
def test_dig
skip_if_lacking :dig
assert_equal :a, @hash.dig(:a)
assert_equal :b, @hash.dig(?b)
assert_nil @hash.dig(:d)
@ -174,8 +164,6 @@ class TestIndifferentHash < Minitest::Test
end
def test_slice
skip_if_lacking :slice
assert_equal Sinatra::IndifferentHash[a: :a], @hash.slice(:a)
assert_equal Sinatra::IndifferentHash[b: :b], @hash.slice(?b)
assert_equal Sinatra::IndifferentHash[3 => 3], @hash.slice(3)
@ -186,8 +174,6 @@ class TestIndifferentHash < Minitest::Test
end
def test_fetch_values
skip_if_lacking :fetch_values
assert_raises(KeyError) { @hash.fetch_values(3, :d) }
assert_equal [:a, :b, 3, ?D], @hash.fetch_values(:a, ?b, 3, :d) { |k| k.upcase }
end
@ -225,16 +211,12 @@ class TestIndifferentHash < Minitest::Test
end
def test_transform_values!
skip_if_lacking :transform_values!
@hash.transform_values! { |v| v.is_a?(Hash) ? Hash[v.to_a] : v }
assert_instance_of Sinatra::IndifferentHash, @hash[:simple_nested]
end
def test_transform_values
skip_if_lacking :transform_values
hash2 = @hash.transform_values { |v| v.respond_to?(:upcase) ? v.upcase : v }
refute_equal @hash, hash2
@ -243,8 +225,6 @@ class TestIndifferentHash < Minitest::Test
end
def test_transform_keys!
skip_if_lacking :transform_keys!
@hash.transform_keys! { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
assert_equal :a, @hash[:a]
@ -252,8 +232,6 @@ class TestIndifferentHash < Minitest::Test
end
def test_transform_keys
skip_if_lacking :transform_keys
hash2 = @hash.transform_keys { |k| k.respond_to?(:upcase) ? k.upcase : k }
refute_equal @hash, hash2
@ -300,8 +278,6 @@ class TestIndifferentHash < Minitest::Test
end
def test_compact
skip_if_lacking :compact
hash_with_nil_values = @hash.merge({?z => nil})
compacted_hash = hash_with_nil_values.compact
assert_equal @hash, compacted_hash