# frozen_string_literal: true

source 'https://rubygems.org'
gemspec

gem 'rake'

rack_version = ENV['rack'].to_s
rack_version = nil if rack_version.empty? || (rack_version == 'stable')
rack_version = { github: 'rack/rack' } if rack_version == 'head'
gem 'rack', rack_version

rack_session_version = ENV['rack_session'].to_s
rack_session_version = nil if rack_session_version.empty? || (rack_session_version == 'stable')
rack_session_version = { github: 'rack/rack-session' } if rack_session_version == 'head'
gem 'rack-session', rack_session_version

gem 'rackup'

puma_version = ENV['puma'].to_s
puma_version = nil if puma_version.empty? || (puma_version == 'stable')
puma_version = { github: 'puma/puma' } if puma_version == 'head'
gem 'puma', puma_version

zeitwerk_version = ENV['zeitwerk'].to_s
zeitwerk_version = nil if zeitwerk_version.empty? || (zeitwerk_version == 'stable')
gem 'zeitwerk', zeitwerk_version

gem 'minitest', '~> 5.0'
gem 'rack-test'

gem 'rack-protection', path: 'rack-protection'
gem 'sinatra-contrib', path: 'sinatra-contrib'

# in Ruby 4.1, so they fail to compile there. Their tests skip without them.
legacy_c_api = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('4.1')

gem 'asciidoctor'
gem 'builder'
gem 'childprocess', '>= 5'
gem 'erubi'
gem 'kramdown'
gem 'nokogiri', '> 1.5.0'
gem 'ostruct'
gem 'rdiscount', platforms: [:ruby]
gem 'rdoc'
gem 'webrick'

# sass-embedded depends on google-protobuf
# which fails to be installed on JRuby and TruffleRuby under aarch64
# https://github.com/jruby/jruby/issues/8062
# https://github.com/protocolbuffers/protobuf/issues/11935
java    = %w(jruby truffleruby).include?(RUBY_ENGINE)
aarch64 = RbConfig::CONFIG["target_cpu"] == 'aarch64'
# sass-embedded has no prebuilt gems for Ruby 3.1, and building it from source
# in this bundle fails as Ruby 3.1's own psych and json get mixed with the
# newer psych and json gems. The sass tests skip without it.
ruby31 = RUBY_VERSION.start_with?('3.1.')
gem 'sass-embedded', '~> 1.54' unless (java && aarch64) || ruby31

#
# jruby does not support native extensions
# https://github.com/truffleruby/truffleruby/issues/3396#issuecomment-3694252552
#
# it is not a guarantee that the rust gems magnus and rb-sys have been updated for ruby-head
# example for 4.1 dev https://github.com/matsadler/magnus/pull/164, https://github.com/oxidize-rb/rb-sys/pull/697
#
# ones are compiled from source there, and their bundled oniguruma fails to
# build with GCC 15 (C23 by default), as on ubuntu-26.04.
ruby_head = RUBY_PATCHLEVEL == -1
