Skip to content

Conversation

@olbrich
Copy link
Owner

@olbrich olbrich commented Dec 24, 2025

Refactor methods to enhance readability and clarity by adopting keyword arguments and pattern matching. Update the required Ruby version to 3.2 and ensure configuration initialization aligns with these changes. Additionally, address minor quality fixes.

This will introduce a major version bump due to the requirement for ruby 3.2+

@olbrich olbrich self-assigned this Dec 24, 2025
@olbrich olbrich added the Major incompatible API changes label Dec 24, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the ruby-units gem to enhance code clarity by adopting modern Ruby 3.2+ features including pattern matching, keyword arguments, and endless method definitions. The Ruby version requirement is updated from 2.7 to 3.2, necessitating a major version bump to 5.0.0.

Key Changes:

  • Refactored Unit#initialize to use pattern matching with case/in syntax for cleaner type handling
  • Updated Configuration#initialize to accept keyword arguments with sensible defaults
  • Modernized method definitions using Ruby 3.2+ features (endless methods, shorthand hash syntax, argument forwarding with ...)

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ruby-units.gemspec Updated minimum Ruby version requirement from 2.7 to 3.2
lib/ruby_units/version.rb Bumped version from 4.1.0 to 5.0.0 for major release
lib/ruby_units/configuration.rb Refactored initialize to use keyword arguments (separator, format) with forward-compatible **_options
spec/ruby_units/configuration_spec.rb Added comprehensive tests for new Configuration initialization with keyword arguments
lib/ruby_units/unit.rb Refactored initialize using pattern matching; updated multiple methods (abs, ceil, floor, round, truncate, succ, pred) to use keyword argument syntax and argument forwarding; applied shorthand hash syntax in eliminate_terms
lib/ruby_units/definition.rb Converted prefix? and unity? methods to endless method definitions
README.md Added Ruby 3.2+ requirement notice and keyword arguments usage example
Gemfile.qlty New file for qlty-specific development gems (rubocop, rubocop-rake, rubocop-rspec)
Gemfile Moved rubocop gems to Gemfile.qlty and added eval_gemfile to load them
.qlty/qlty.toml Added rubocop and reek plugin configurations
.github/workflows/tests.yml Removed commented-out CodeClimate coverage code
Gemfile.lock Updated dependency versions and removed some platform-specific entries; changed bundler version from 4.0.2 to 2.7.2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

unit = object.to_unit # convert any object using object.to_s
unit = Unit.new('1/4 cup') # Rational number
unit = Unit.new('1+1i mm') # Complex Number
unit = Unit.new(scalar: 1.5, numerator: ["<meter>"], denominator: ["<second>"]) # keyword arguments
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

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

The README shows an example of using keyword arguments to create a Unit (line 57), but this constructor pattern lacks test coverage. Consider adding a test to verify that Unit.new(scalar: 1.5, numerator: ["<meter>"], denominator: ["<second>"]) works as expected and produces the correct unit.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Contributor

Copilot AI commented Dec 24, 2025

@olbrich I've opened a new pull request, #378, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: olbrich <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@olbrich olbrich merged commit f25fb3d into master Dec 24, 2025
9 of 10 checks passed
@olbrich olbrich deleted the ruby-3.2-features branch December 24, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Major incompatible API changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants