Skip to content

Commit

Permalink
feat!: Ruby 2.6 EOL and Dependency Chores (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
PanisSupraOmnia authored Oct 9, 2022
1 parent 2cdc59b commit 59a7d85
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 28 deletions.
18 changes: 3 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@ commands:
- ./vendor/bundle

jobs:
test_ruby_26:
docker:
- image: ruby:2.6-alpine
steps:
- setup-env
- run:
name: Run RSpec
command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml
- store_test_results:
path: ~/rspec

test_ruby_27:
docker:
- image: ruby:2.7-alpine
Expand Down Expand Up @@ -68,11 +57,11 @@ jobs:
- setup-env
- run:
name: Run RSpec
command: bundle exec rspec
command: bundle exec rspec --format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml

rubocop:
docker:
- image: ruby:2.6-alpine
- image: ruby:2.7-alpine
steps:
- setup-env
- run:
Expand All @@ -81,7 +70,7 @@ jobs:

yard:
docker:
- image: ruby:2.6-alpine
- image: ruby:2.7-alpine
steps:
- setup-env
- attach_workspace:
Expand Down Expand Up @@ -136,7 +125,6 @@ jobs:
workflows:
test:
jobs:
- test_ruby_26
- test_ruby_27
- test_ruby_30
- test_ruby_31
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inherit_mode:

AllCops:
NewCops: enable
TargetRubyVersion: 2.6
TargetRubyVersion: 2.7

# Disable line length checks
Layout/LineLength:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ If you enjoy using the library, consider getting involved with the community to

## Dependencies

- Ruby >= 2.6 supported
- An installed build system for native extensions (on Windows, make sure you download the "Ruby+Devkit" version of [RubyInstaller](https://rubyinstaller.org/downloads/))
* Ruby >= 2.7 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

Expand Down
2 changes: 1 addition & 1 deletion discordrb-webhooks.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|

spec.add_dependency 'rest-client', '>= 2.0.0'

spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 2.7'
spec.metadata = {
'rubygems_mfa_required' => 'true'
}
Expand Down
6 changes: 3 additions & 3 deletions discordrb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ Gem::Specification.new do |spec|

spec.add_dependency 'discordrb-webhooks', '~> 3.4.2'

spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 2.7'

spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'redcarpet', '~> 3.5.0' # YARD markdown formatting
spec.add_development_dependency 'rspec', '~> 3.11.0'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5.1'
spec.add_development_dependency 'rspec-prof', '~> 0.0.7'
spec.add_development_dependency 'rubocop', '~> 1.27.0'
spec.add_development_dependency 'rubocop', '~> 1.36.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'
Expand Down
6 changes: 3 additions & 3 deletions examples/slash_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'discordrb'

bot = Discordrb::Bot.new(token: ENV['SLASH_COMMAND_BOT_TOKEN'], intents: [:server_messages])
bot = Discordrb::Bot.new(token: ENV.fetch('SLASH_COMMAND_BOT_TOKEN', nil), intents: [:server_messages])

# We need to register our application commands separately from the handlers with a special DSL.
# This example uses server specific commands so that they appear immediately for testing,
Expand All @@ -11,7 +11,7 @@
#
# You may want to have a separate script for registering your commands so you don't need to do this every
# time you start your bot.
bot.register_application_command(:example, 'Example commands', server_id: ENV['SLASH_COMMAND_BOT_SERVER_ID']) do |cmd|
bot.register_application_command(:example, 'Example commands', server_id: ENV.fetch('SLASH_COMMAND_BOT_SERVER_ID', nil)) do |cmd|
cmd.subcommand_group(:fun, 'Fun things!') do |group|
group.subcommand('8ball', 'Shake the magic 8 ball') do |sub|
sub.string('question', 'Ask a question to receive wisdom', required: true)
Expand All @@ -29,7 +29,7 @@
end
end

bot.register_application_command(:spongecase, 'Are you mocking me?', server_id: ENV['SLASH_COMMAND_BOT_SERVER_ID']) do |cmd|
bot.register_application_command(:spongecase, 'Are you mocking me?', server_id: ENV.fetch('SLASH_COMMAND_BOT_SERVER_ID', nil)) do |cmd|
cmd.string('message', 'Message to spongecase')
cmd.boolean('with_picture', 'Show the mocking sponge?')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Discordrb
Thread.current[:discordrb_name] = 'main'

# The default debug logger used by discordrb.
LOGGER = Logger.new(ENV['DISCORDRB_FANCY_LOG'])
LOGGER = Logger.new(ENV.fetch('DISCORDRB_FANCY_LOG', false))

# The Unix timestamp Discord IDs are based on
DISCORD_EPOCH = 1_420_070_400_000
Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/data/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def users
if text?
server.online_members(include_idle: true).select { |u| u.can_read_messages? self }
elsif voice?
server.voice_states.map { |id, voice_state| server.member(id) if !voice_state.voice_channel.nil? && voice_state.voice_channel.id == @id }.compact
server.voice_states.filter_map { |id, voice_state| server.member(id) if !voice_state.voice_channel.nil? && voice_state.voice_channel.id == @id }
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/discordrb/permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def initialize(bits = 0, writer = nil)
# permissions.defined_permissions #=> [:create_instant_invite, :administrator]
# @return [Array<Symbol>] the permissions
def defined_permissions
FLAGS.collect { |value, name| (@bits & (1 << value)).positive? ? name : nil }.compact
FLAGS.filter_map { |value, name| (@bits & (1 << value)).positive? ? name : nil }
end

# Comparison based on permission bits
Expand Down

0 comments on commit 59a7d85

Please sign in to comment.