refactor: Modernize codebase to idiomatic Ruby gem standards#2
Merged
refactor: Modernize codebase to idiomatic Ruby gem standards#2
Conversation
Refactored internal implementation to follow Ruby gem best practices
without changing public API or functionality. All existing tests pass.
**Technical Changes:**
- Extracted VERSION constant to lib/typewrite/version.rb (single source
of truth)
- Converted class to module (idiomatic for utility gems, backwards
compatible)
- Extracted PUNCTUATION constant to avoid array recreation on each
iteration
- Replaced split('').each with more idiomatic each_char
- Added frozen_string_literal pragma to all Ruby files
- Added comprehensive YARD documentation for public API
**Gemspec Improvements:**
- Renamed block variable s → spec (Ruby convention)
- Added required_ruby_version >= 3.0.0
- Added modern RubyGems metadata (MFA, changelog, bug tracker URIs)
- Implemented git ls-files pattern for file list
- Fixed awkward line break in homepage URL
**Benefits:**
- More efficient: PUNCTUATION constant created once, not per character
- Better maintainability: Version managed in single location
- Professional documentation: YARD comments enable auto-generated docs
- Improved security: MFA requirement for gem publishing
- Future-proof: Modern gemspec patterns and metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactored internal implementation to follow Ruby gem best practices without changing public API or functionality. All existing tests pass (9/9).
Changes
Added
lib/typewrite/version.rbwithVERSIONconstant (single source of truth)frozen_string_literal: truepragma to all Ruby filesrequired_ruby_version >= 3.0.0specificationUpdated
class Typewrite→module Typewrite(backwards compatible)PUNCTUATIONconstant (no longer recreated each iteration)split('').eachwith idiomaticeach_chars→spec(Ruby convention)git ls-filespatternBenefits
Test Plan
gem build typewrite.gemspec)Typewrite.writeworks identically)Typewrite::VERSION)Notes
The class → module change is fully backwards compatible.
Typewrite.writestill works exactly as before.