From da87e94c819087fda1f69c373b427855dee39b1d Mon Sep 17 00:00:00 2001 From: Dakurei Date: Thu, 30 Mar 2023 16:40:28 +0200 Subject: [PATCH] Ruby 2.7 EOL and Dependency Chores --- .github/workflows/github-pages.yml | 4 ++-- .github/workflows/rspec.yml | 2 +- .github/workflows/rubocop.yml | 4 ++-- .github/workflows/yard.yml | 4 ++-- .rubocop.yml | 2 +- README.md | 2 +- discordrb-webhooks.gemspec | 2 +- discordrb.gemspec | 8 ++++---- lib/discordrb/commands/parser.rb | 2 +- lib/discordrb/data/embed.rb | 2 +- lib/discordrb/data/emoji.rb | 2 +- lib/discordrb/data/reaction.rb | 2 +- lib/discordrb/data/server.rb | 6 +++--- lib/discordrb/voice/encoder.rb | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index a9def4743..0a983fd42 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -28,10 +28,10 @@ jobs: sudo apt update sudo apt install -y git openssh-client - - name: Setup Ruby 2.7 + - name: Setup Ruby 3.0 uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.0' bundler-cache: true - name: Checkout repository for Github Pages diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 64ad119ad..3f2073743 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - versions: [ '2.7', '3.0', '3.1', '3.2' ] + versions: [ '3.0', '3.1', '3.2' ] steps: - name: Checkout repository diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index bf1634633..dd541120f 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -22,10 +22,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup Ruby 2.7 + - name: Setup Ruby 3.0 uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.0' bundler-cache: true - name: Run bundle install diff --git a/.github/workflows/yard.yml b/.github/workflows/yard.yml index 1b7cea63f..0f006d274 100644 --- a/.github/workflows/yard.yml +++ b/.github/workflows/yard.yml @@ -22,10 +22,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup Ruby 2.7 + - name: Setup Ruby 3.0 uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.0' bundler-cache: true - name: Run bundle install diff --git a/.rubocop.yml b/.rubocop.yml index cbe94c83a..e2a834865 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ inherit_mode: AllCops: NewCops: enable - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 # Disable line length checks Layout/LineLength: diff --git a/README.md b/README.md index 72c627b9c..6ac522be6 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ If you enjoy using the library, consider getting involved with the community to ## Dependencies -* Ruby >= 2.7 supported +* Ruby >= 3.0 supported * An installed build system for native extensions (on Windows, make sure you download the "Ruby+Devkit" version of [RubyInstaller](https://rubyinstaller.org/downloads/)) ### Voice dependencies diff --git a/discordrb-webhooks.gemspec b/discordrb-webhooks.gemspec index 7705c97f8..1036ab065 100644 --- a/discordrb-webhooks.gemspec +++ b/discordrb-webhooks.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'rest-client', '>= 2.0.0' - spec.required_ruby_version = '>= 2.7' + spec.required_ruby_version = '>= 3.0' spec.metadata = { 'rubygems_mfa_required' => 'true' } diff --git a/discordrb.gemspec b/discordrb.gemspec index 90ed9aba2..67a1542e4 100644 --- a/discordrb.gemspec +++ b/discordrb.gemspec @@ -31,17 +31,17 @@ Gem::Specification.new do |spec| spec.add_dependency 'discordrb-webhooks', '~> 3.4.2' - spec.required_ruby_version = '>= 2.7' + spec.required_ruby_version = '>= 3.0' spec.add_development_dependency 'bundler', '>= 1.10', '< 3' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'redcarpet', '~> 3.6.0' # YARD markdown formatting spec.add_development_dependency 'rspec', '~> 3.12.0' - spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5.1' + spec.add_development_dependency 'rspec_junit_formatter', '~> 0.6.0' spec.add_development_dependency 'rspec-prof', '~> 0.0.7' - spec.add_development_dependency 'rubocop', '~> 1.36.0' + spec.add_development_dependency 'rubocop', '~> 1.48.0' spec.add_development_dependency 'rubocop-performance', '~> 1.0' spec.add_development_dependency 'rubocop-rake', '~> 0.6.0' - spec.add_development_dependency 'simplecov', '~> 0.21.0' + spec.add_development_dependency 'simplecov', '~> 0.22.0' spec.add_development_dependency 'yard', '~> 0.9.9' end diff --git a/lib/discordrb/commands/parser.rb b/lib/discordrb/commands/parser.rb index 2d9574690..d96f21778 100644 --- a/lib/discordrb/commands/parser.rb +++ b/lib/discordrb/commands/parser.rb @@ -159,7 +159,7 @@ def execute_bare(event) escaped = false hacky_delim, hacky_space, hacky_prev, hacky_newline = [0xe001, 0xe002, 0xe003, 0xe004].pack('U*').chars - @chain.each_char.each_with_index do |char, index| + @chain.each_char.with_index do |char, index| # Escape character if char == '\\' && !escaped escaped = true diff --git a/lib/discordrb/data/embed.rb b/lib/discordrb/data/embed.rb index 546c57bd7..578285700 100644 --- a/lib/discordrb/data/embed.rb +++ b/lib/discordrb/data/embed.rb @@ -68,7 +68,7 @@ def initialize(data, message) @provider = data['provider'].nil? ? nil : EmbedProvider.new(data['provider'], self) @thumbnail = data['thumbnail'].nil? ? nil : EmbedThumbnail.new(data['thumbnail'], self) @author = data['author'].nil? ? nil : EmbedAuthor.new(data['author'], self) - @fields = data['fields'].nil? ? nil : data['fields'].map { |field| EmbedField.new(field, self) } + @fields = data['fields']&.map { |field| EmbedField.new(field, self) } end end diff --git a/lib/discordrb/data/emoji.rb b/lib/discordrb/data/emoji.rb index dc26aee58..5d81d7183 100644 --- a/lib/discordrb/data/emoji.rb +++ b/lib/discordrb/data/emoji.rb @@ -25,7 +25,7 @@ def initialize(data, bot, server = nil) @name = data['name'] @server = server - @id = data['id'].nil? ? nil : data['id'].to_i + @id = data['id']&.to_i @animated = data['animated'] process_roles(data['roles']) if server diff --git a/lib/discordrb/data/reaction.rb b/lib/discordrb/data/reaction.rb index 202d5795b..491f5eb49 100644 --- a/lib/discordrb/data/reaction.rb +++ b/lib/discordrb/data/reaction.rb @@ -19,7 +19,7 @@ class Reaction def initialize(data) @count = data['count'] @me = data['me'] - @id = data['emoji']['id'].nil? ? nil : data['emoji']['id'].to_i + @id = data['emoji']['id']&.to_i @name = data['emoji']['name'] end diff --git a/lib/discordrb/data/server.rb b/lib/discordrb/data/server.rb index 0313dd98f..24aff4f9e 100644 --- a/lib/discordrb/data/server.rb +++ b/lib/discordrb/data/server.rb @@ -829,11 +829,11 @@ def update_data(new_data = nil) @afk_timeout = new_data[:afk_timeout] || new_data['afk_timeout'] || @afk_timeout afk_channel_id = new_data[:afk_channel_id] || new_data['afk_channel_id'] || @afk_channel - @afk_channel_id = afk_channel_id.nil? ? nil : afk_channel_id.resolve_id + @afk_channel_id = afk_channel_id&.resolve_id widget_channel_id = new_data[:widget_channel_id] || new_data['widget_channel_id'] || @widget_channel - @widget_channel_id = widget_channel_id.nil? ? nil : widget_channel_id.resolve_id + @widget_channel_id = widget_channel_id&.resolve_id system_channel_id = new_data[:system_channel_id] || new_data['system_channel_id'] || @system_channel - @system_channel_id = system_channel_id.nil? ? nil : system_channel_id.resolve_id + @system_channel_id = system_channel_id&.resolve_id @widget_enabled = new_data[:widget_enabled] || new_data['widget_enabled'] @splash = new_data[:splash_id] || new_data['splash_id'] || @splash_id diff --git a/lib/discordrb/voice/encoder.rb b/lib/discordrb/voice/encoder.rb index 508848ae9..6e98ddb24 100644 --- a/lib/discordrb/voice/encoder.rb +++ b/lib/discordrb/voice/encoder.rb @@ -63,7 +63,7 @@ def adjust_volume(buf, mult) sample *= mult # clamp to s16 range - [32_767, [-32_768, sample].max].min + sample.clamp(-32_768, 32_767) end # After modification, make it s16le again