Skip to content

Updating gem to fix APIs add 3.x support#10

Merged
dchapman1988 merged 12 commits into
masterfrom
modernize-ruby-3
Dec 19, 2025
Merged

Updating gem to fix APIs add 3.x support#10
dchapman1988 merged 12 commits into
masterfrom
modernize-ruby-3

Conversation

@dchapman1988

@dchapman1988 dchapman1988 commented Nov 26, 2025

Copy link
Copy Markdown
Owner

Why

Updating gem to fix deprecated Ruby APIs and add Ruby 3.x support.

The old version used:

  • Deprecated URI.encode/URI.decode (removed in Ruby 3.2+)
  • curb gem (unmaintained, C-extension issues)
  • method_missing for attribute access (performance overhead, hard to debug)
  • Old RuboCop config syntax

Breaking Changes

Ruby Version

  • Now requires Ruby >= 3.0.0
  • Was previously Ruby 2.x compatible

HTTP Client

  • Replaced curb with http gem
  • Same functionality, different gem

Method Definitions

  • Removed method_missing dynamic methods
  • All restaurant/search attributes now explicitly defined
  • Same method names, just defined differently

Example - No API changes needed:

# This still works exactly the same
restaurant = Hungrytable::Restaurant.new(12345)
restaurant.restaurant_name  # Still works
restaurant.address          # Still works

What Changed

Code:

  • Fixed URI.encode, upgraded to CGI.escape
  • Replaced curb with http gem
  • Replaced method_missing with explicit define_method
  • Fixed Config module to use class << self
  • Updated RuboCop config (plugins vs require)

Tests:

  • Added Many new tests

  • All API endpoints covered

  • WebMock for HTTP stubbing

  • Added GitHub Actions CI

  • Tests Ruby 3.0, 3.1, 3.2, 3.3

  • Added bundler-audit security scanning

Testing with OpenTable

Prerequisites:

Setup:

  export OT_PARTNER_ID=<your_partner_id>
  export OT_OAUTH_KEY=<your_oauth_key>
  export OT_OAUTH_SECRET=<your_oauth_secret>

Run tests:

  bundle exec rake test

Manual testing flow:

  require 'hungrytable'

  # 1. Get restaurant
  restaurant = Hungrytable::Restaurant.new(82591)
  puts restaurant.restaurant_name

  # 2. Search availability
  search = Hungrytable::RestaurantSearch.new(
    restaurant,
    date_time: 3.days.from_now.change(hour: 19),
    party_size: 2
  )
  puts search.ideal_time

  # 3. Lock slot
  slotlock = Hungrytable::RestaurantSlotlock.new(search)
  puts slotlock.slotlock_id

  # 4. Make reservation
  reservation = Hungrytable::ReservationMake.new(
    slotlock,
    email_address: 'test@example.com',
    firstname: 'Test',
    lastname: 'User',
    phone: '5551234567'
  )
  puts reservation.confirmation_number

  # 5. Check status
  status = Hungrytable::ReservationStatus.new(
    restaurant_id: 82591,
    confirmation_number: reservation.confirmation_number
  )
  puts status.status

  # 6. Cancel
  cancel = Hungrytable::ReservationCancel.new(
    restaurant_id: 82591,
    confirmation_number: reservation.confirmation_number,
    email_address: 'test@example.com'
  )
  puts cancel.successful?

Without OpenTable access:

  • All tests use WebMock stubs
  • Run bundle exec rake test to verify
  • Tests validate request formatting and error handling

Note

Modernizes the gem for Ruby 3+, replaces curb with http, removes method_missing in favor of explicit methods, adds reservation status, robust error/HTTP handling, extensive tests, and CI.

  • Core/Runtime:
    • Require Ruby >= 3.0; bump version to 1.0.0 and modernize gemspec/runtime deps (http, oauth, activesupport).
    • Replace deprecated URI.encode/decode with CGI.escape/unescape.
    • Replace curb with http client and refactor request flow (GetRequest, PostRequest, Request#handle_http_errors).
  • API Changes:
    • Remove method_missing; explicitly define accessors for Restaurant and RestaurantSearch attributes.
    • Add ReservationStatus with status and reservation_details.
    • Improve ReservationMake, ReservationCancel, RestaurantSlotlock with clearer params, result parsing, and validations.
  • Config/Errors:
    • Rework Config (ENV or programmatic setters, reset!, valid?).
    • Introduce structured error classes (ConfigurationError, HTTPError hierarchy, APIError, validations).
  • Tooling/Quality:
    • Add GitHub Actions CI (multi-Ruby), Codecov, RuboCop config, SimpleCov/LCOV; ignore coverage/.
    • Add comprehensive Minitest suite with WebMock; new Guardfile; README and release notes updated.

Written by Cursor Bugbot for commit f1773d8. This will update automatically on new commits. Configure here.

- Lots of breaking changes
- Upgraded to modern Ruby 3.x. support
- Replaced curb with http
- Removed dynamic methods
- More resturant/search attributes now defined
- GH Actions
- Adds bundler-audit

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Comment thread lib/hungrytable/post_request.rb
Comment thread lib/hungrytable/reservation_make.rb
  - Escape confirmation_number in cancel/status URLs to handle special chars
  - Validate slotlock has available times before creating request
  - Validate date_time is Time/DateTime object before calling strftime
  - Validate party_size is integer between 1-20 per API limits
  - Add .to_s to error ID comparisons for JSON integer compatibility
  - Add 30-second HTTP timeout to prevent indefinite hangs
@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@dchapman1988 dchapman1988 merged commit 3d2ad1a into master Dec 19, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants