Skip to content

Extract shared casing helpers - #1309

Merged
jwils merged 4 commits into
mainfrom
joshuaw/casing-support
Jul 15, 2026
Merged

Extract shared casing helpers#1309
jwils merged 4 commits into
mainfrom
joshuaw/casing-support

Conversation

@jwils

@jwils jwils commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Why

Casing conversions currently live behind private schema-artifact helpers, while protobuf generation needs the same shared behavior.

What

  • Add ElasticGraph::Support::Casing with snake, camel, and upper-snake conversions
  • Replace existing private converter usages with the shared helper
  • Preserve existing snake/camel semantics and cover acronym-aware upper-snake conversion

Risk Assessment

Low — existing behavior is preserved, and the affected gem suites retain 100% line and branch coverage.

References


Update Jul 15, 15:54 CDT: Addressed casing review feedback

  • Made camel, title, and uncapitalize conversions Unicode-aware while preserving consecutive underscores.
  • Added coverage for anchoring, digit boundaries, Unicode casing, and GraphQL __typename.
  • Mutation-checked every previously surviving case; support and schema-definition suites retain 100% coverage.
  • Risk remains low: the shared helper now has more explicit behavior and broader regression coverage.

Comment thread elasticgraph-support/spec/unit/elastic_graph/support/casing_spec.rb
Comment thread elasticgraph-support/lib/elastic_graph/support/casing.rb
Comment thread elasticgraph-support/lib/elastic_graph/support/casing.rb Outdated
jwils added 2 commits July 15, 2026 11:25
- Move `TypeReference#to_title_case` into `Support::Casing.to_title`.
- Document how `to_snake` and `to_upper_snake` differ beyond upcasing
  (acronym splitting and the leading underscore), with spec coverage of
  the exact inputs where they diverge.
- Cover digit handling (the `\d` in `to_upper_snake`'s regex) and
  UPPER_SNAKE_CASE inputs across all the conversion methods.
`HasIndices#to_field_name` downcased a type name's leading capital
inline. Move that into `Support::Casing.uncapitalize` (the mirror of
the capitalization inside `to_title`) so all identifier casing
manipulation lives in one place.
Comment thread elasticgraph-support/lib/elastic_graph/support/casing.rb Outdated
Comment thread elasticgraph-support/lib/elastic_graph/support/casing.rb Outdated
Comment thread elasticgraph-support/spec/unit/elastic_graph/support/casing_spec.rb

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@jwils
jwils merged commit 75fabbe into main Jul 15, 2026
24 checks passed
@jwils
jwils deleted the joshuaw/casing-support branch July 15, 2026 23:23
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