Skip to content

Commit

Permalink
feat(ruby): upgrade versions & dependencies (#1067)
Browse files Browse the repository at this point in the history
| 🚥 Resolves #1050, #1048  |
| :------------------- |

## 🧰 Changes

- Dropped support for Ruby 2.7 and 3.0
- Added support for Ruby 3.2
- Added support for Ruby 3.3
- Upgraded dependencies
- Fixed failing tests
- Re-enabled Ruby for Dependabot
  • Loading branch information
AndriiAndreiev authored Sep 18, 2024
1 parent 7359d64 commit 6139934
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 73 deletions.
26 changes: 13 additions & 13 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ updates:
versions:
- '>= 4'

# - package-ecosystem: bundler
# directory: "/packages/ruby"
# schedule:
# interval: monthly
# allow:
# - dependency-type: production
# open-pull-requests-limit: 10
# labels:
# - dependencies
# - ruby
# commit-message:
# prefix: chore(deps)
# prefix-development: chore(deps-dev)
- package-ecosystem: bundler
directory: '/packages/ruby'
schedule:
interval: monthly
allow:
- dependency-type: production
open-pull-requests-limit: 10
labels:
- dependencies
- ruby
commit-message:
prefix: chore(deps)
prefix-development: chore(deps-dev)

- package-ecosystem: composer
directory: '/packages/php'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
matrix:
ruby-version:
# https://endoflife.date/ruby
- 2.7 # EOL: March 31st, 2023
- '3.0' # EOL: March 31st, 2024
- 3.1 # EOL: December 25th, 2025
- 3.1 # EOL: March 31th, 2025
- 3.2 # EOL: March 31th, 2026
- 3.3 # EOL: March 31th, 2027
rack-version:
# This will install the latest v2
- -v '>= 2.2' -v '< 3'
Expand Down
102 changes: 55 additions & 47 deletions packages/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,77 @@ PATH
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
diff-lcs (1.4.4)
hashdiff (1.0.1)
httparty (0.21.0)
bigdecimal (3.1.8)
crack (1.0.0)
bigdecimal
rexml
csv (3.3.0)
diff-lcs (1.5.1)
hashdiff (1.1.1)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
json (2.6.2)
json-schema (2.8.1)
addressable (>= 2.4)
json (2.7.2)
json-schema (5.0.0)
addressable (~> 2.8)
language_server-protocol (3.17.0.3)
mini_mime (1.1.5)
multi_xml (0.6.0)
parallel (1.22.1)
parser (3.1.2.1)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
public_suffix (4.0.6)
rack (2.2.3.1)
rack-test (1.1.0)
rack (>= 1.0, < 3)
racc
public_suffix (6.0.1)
racc (1.8.1)
rack (3.1.7)
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (12.3.3)
regexp_parser (2.5.0)
rexml (3.3.6)
regexp_parser (2.9.2)
rexml (3.3.5)
strscan
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rubocop (1.36.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
rubocop-performance (1.14.3)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rspec (2.12.1)
rubocop (~> 1.31)
ruby-progressbar (1.11.0)
safe_yaml (1.0.5)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.1)
parser (>= 3.3.1.0)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (3.0.4)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
strscan (3.1.0)
unicode-display_width (2.2.0)
webmock (3.8.3)
addressable (>= 2.3.6)
unicode-display_width (2.5.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

Expand Down
22 changes: 14 additions & 8 deletions packages/ruby/lib/readme/http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,9 @@ def headers

def body
if IS_RACK_V3
body = @input.read
@input.rewind
body
read_body(@input)
else
@request.body.rewind
content = @request.body.read
@request.body.rewind

content
read_body(@request.body)
end
end

Expand Down Expand Up @@ -134,5 +128,17 @@ def host_header
'Host' => @request.host
}.compact
end

def read_body(io)
return '' if io.nil?

io.rewind if io.respond_to?(:rewind)
content = io.read || ''
io.rewind if io.respond_to?(:rewind)
content
rescue => e
Readme::Metrics.logger.warn "Error reading request body: #{e.message}"
''
end
end
end
4 changes: 2 additions & 2 deletions packages/ruby/readme-metrics.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_runtime_dependency 'httparty', '~> 0.18'
spec.add_runtime_dependency 'rack', '>= 2.2', '< 4'
spec.add_dependency 'httparty', '~> 0.18'
spec.add_dependency 'rack', '>= 2.2', '< 4'
end
10 changes: 10 additions & 0 deletions packages/ruby/spec/readme/http_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
expect(request.body).to eq '[BODY]'
expect(request.body).to eq '[BODY]'
end

it 'returns an empty string if an error occurs while reading the body' do
io = instance_double(StringIO, read: nil)
allow(io).to receive(:rewind).and_raise(StandardError.new('Test Error'))

env = { 'rack.input' => io }
request = described_class.new(env)

expect(request.body).to eq ''
end
end

describe '#parsed_form_data' do
Expand Down

0 comments on commit 6139934

Please sign in to comment.