Skip to content

[cnpj-utils] Create package to consolidate itilities for CNPJ - #25

Merged
juliolmuller merged 27 commits into
mainfrom
feat/cnpj-utilities
Jul 24, 2026
Merged

[cnpj-utils] Create package to consolidate itilities for CNPJ#25
juliolmuller merged 27 commits into
mainfrom
feat/cnpj-utilities

Conversation

@juliolmuller

@juliolmuller juliolmuller commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Resolves #6

Summary by CodeRabbit

  • New Features
    • Added a class-based CnpjUtils façade with a shared CnpjUtils::DEFAULT, configurable instances, and per-call override behavior.
    • Added re-exported formatter/generator/validator surfaces under CnpjUtils, along with scoped error types for misuse.
  • Documentation
    • Added/expanded English and Portuguese guides for CnpjUtils, plus aggregator re-export conventions.
    • Updated changelogs and refreshed Ruby examples in component READMEs (formatting-only).
  • Tests
    • Replaced the previous spec with a comprehensive RSpec suite covering façade behavior and delegation.
  • Chores
    • Updated gem packaging metadata and file lists; tightened cnpj-utilities version/dependency bounds.

juliolmuller and others added 7 commits July 23, 2026 13:57
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Introduced a new class structure for CNPJ formatting, generation, and validation.
- Added nested modules for CNPJ formatter, generator, and validator.
- Implemented error handling for argument combinations.
- Updated versioning and documentation for the new API structure.

Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Removed outdated `cnpj_utilities.spec.rb` file.
- Added a new `cnpj_utils.spec.rb` file containing a complete behavioral suite for CnpjUtils.
- The new tests cover formatting, generation, and validation functionalities with various option handling scenarios.
- Enhanced structure and clarity of tests to align with the unified API for CNPJ handling.

Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Documented structure and conventions for re-export files in aggregator gems like `*-utilities` and `br-utilities`.
- Included specifications for default singleton and class helpers, emphasizing mutable constants and class-method aliases.
- Provided a reference example with `cnpj-utilities` to illustrate the implementation.

Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@juliolmuller
juliolmuller requested a review from a team as a code owner July 23, 2026 17:03
@juliolmuller juliolmuller added the enhancement New minor or major features. label Jul 23, 2026
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 47966b5e-5a70-4899-a9c9-236ead18e018

📥 Commits

Reviewing files that changed from the base of the PR and between c4e79fa and 8efbd45.

📒 Files selected for processing (21)
  • packages/cnpj-dv/README.md
  • packages/cnpj-dv/README.pt.md
  • packages/cnpj-fmt/README.md
  • packages/cnpj-fmt/README.pt.md
  • packages/cnpj-gen/README.md
  • packages/cnpj-gen/README.pt.md
  • packages/cnpj-utilities/CHANGELOG.md
  • packages/cnpj-utilities/README.md
  • packages/cnpj-utilities/README.pt.md
  • packages/cnpj-utilities/src/cnpj-utilities/cnpj_utils.rb
  • packages/cnpj-utilities/tests/cnpj_utils.spec.rb
  • packages/cnpj-val/README.md
  • packages/cnpj-val/README.pt.md
  • packages/cpf-dv/README.md
  • packages/cpf-dv/README.pt.md
  • packages/cpf-fmt/README.md
  • packages/cpf-fmt/README.pt.md
  • packages/cpf-gen/README.md
  • packages/cpf-gen/README.pt.md
  • packages/cpf-val/README.md
  • packages/cpf-val/README.pt.md

📝 Walkthrough

Walkthrough

Adds the CnpjUtils class façade for formatting, generation, and validation, with configurable components, DEFAULT-backed helpers, nested re-exports, structured errors, tests, package metadata, and English and Portuguese documentation.

Changes

CnpjUtils façade

Layer / File(s) Summary
Façade bootstrap and exports
packages/cnpj-utilities/src/cnpj-utilities.rb, packages/cnpj-utilities/src/cnpj-utilities/errors.rb, packages/cnpj-utilities/src/cnpj-utilities/cnpj_fmt.rb, cnpj_gen.rb, cnpj_val.rb
Initializes the class façade, loads components, preserves VERSION, defines package-scoped errors, and re-exports component namespaces.
Configuration and delegated operations
packages/cnpj-utilities/src/cnpj-utilities/cnpj_utils.rb
Supports component instances, option objects, hashes, keywords, delegated operations, mutable DEFAULT, setters, and argument validation.
Behavioral and integration coverage
packages/cnpj-utilities/tests/cnpj_utils.spec.rb
Tests façade exports, configuration, delegation, DEFAULT behavior, error handling, component identity, and package smoke flows.
Façade documentation and release metadata
AGENTS.md, packages/cnpj-utilities/README.md, README.pt.md, CHANGELOG.md, cnpj-utilities.gemspec, packages/*/*.gemspec
Documents the API and release, updates cnpj-utilities dependencies, and expands packaged documentation files.
Component documentation examples
packages/cnpj-dv/*, packages/cnpj-fmt/*, packages/cnpj-gen/*, packages/cnpj-val/*, packages/cpf-dv/*, packages/cpf-fmt/*, packages/cpf-gen/*, packages/cpf-val/*
Reformats or extends component README examples without changing the corresponding library implementations.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related issues

Possibly related PRs

Poem

A rabbit hops through CNPJ rows,
Formats, validates, then grows.
DEFAULT shares its gentle tune,
While custom burrows stay immune.
Three component friends align—
A tidy façade, by design.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also changes many CPF README/gemspec files and AGENTS.md documentation that are unrelated to the cnpj-utilities package scope. Remove the unrelated CPF/docs/gemspec edits or split them into separate PRs focused on cnpj-utilities.
Docstring Coverage ⚠️ Warning Docstring coverage is 44.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title names the new cnpj-utils package and its CNPJ utility consolidation, which matches the main change.
Linked Issues check ✅ Passed The new class-based cnpj-utilities package now formats, generates, and validates CNPJ, including alphanumeric support.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cnpj-utilities

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cnpj-utilities/cnpj-utilities.gemspec`:
- Line 17: Update the gemspec’s spec.files definition to include README.pt.md
alongside the existing packaged documentation files, while preserving the
existing file-existence filtering and source inclusion behavior.

In `@packages/cnpj-utilities/README.pt.md`:
- Line 81: Corrija o fragmento do link interno na seção sobre tabelas de opções
para usar o slug gerado pelo título “Pacotes incluídos”, alterando
`#pacotes-incluidos` para `#pacotes-incluídos` e preservando o restante do
texto.

In `@packages/cnpj-utilities/src/cnpj-utilities/cnpj_utils.rb`:
- Around line 58-59: Replace the raw TypeError raised by normalize_settings with
the package’s TypeMismatchError, preserving the existing message and Hash
validation. Define TypeMismatchError in errors.rb as a TypeError subclass
including the CnpjUtils::Error marker, and add this exception to the `@raise`
documentation for initialize.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e4ccefc3-f58c-4cea-a6b6-c9ad7624a92a

📥 Commits

Reviewing files that changed from the base of the PR and between 975fc9f and b632e19.

📒 Files selected for processing (14)
  • AGENTS.md
  • packages/cnpj-utilities/CHANGELOG.md
  • packages/cnpj-utilities/README.md
  • packages/cnpj-utilities/README.pt.md
  • packages/cnpj-utilities/cnpj-utilities.gemspec
  • packages/cnpj-utilities/src/cnpj-utilities.rb
  • packages/cnpj-utilities/src/cnpj-utilities/cnpj_fmt.rb
  • packages/cnpj-utilities/src/cnpj-utilities/cnpj_gen.rb
  • packages/cnpj-utilities/src/cnpj-utilities/cnpj_utils.rb
  • packages/cnpj-utilities/src/cnpj-utilities/cnpj_val.rb
  • packages/cnpj-utilities/src/cnpj-utilities/errors.rb
  • packages/cnpj-utilities/src/cnpj-utilities/version.rb
  • packages/cnpj-utilities/tests/cnpj_utilities.spec.rb
  • packages/cnpj-utilities/tests/cnpj_utils.spec.rb
💤 Files with no reviewable changes (1)
  • packages/cnpj-utilities/tests/cnpj_utilities.spec.rb

Comment thread packages/cnpj-utilities/cnpj-utilities.gemspec Outdated
Comment thread packages/cnpj-utilities/README.pt.md Outdated
Comment thread packages/cnpj-utilities/src/cnpj-utilities/cnpj_utils.rb Outdated
juliolmuller and others added 9 commits July 23, 2026 14:25
… files

- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
…files

- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
…iles

- Added 'README.pt.md' and 'CHANGELOG.md' to the list of files in the gemspec for better documentation accessibility.
Fix as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…ings

Fix as per @coderabbitai review comment at hhttps://github.com//pull/25#discussion_r3640031712.

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cnpj-utilities/README.md`:
- Around line 280-284: Update the public custom-error documentation in
packages/cnpj-utilities/README.md (lines 280-284) and
packages/cnpj-utilities/README.pt.md (lines 265-269) to show each error’s
complete inheritance chain, including explicit CnpjUtils::Error marker-module
inclusion, before the category, trigger, examples, and rescue/callback guidance.
Keep the English and Portuguese documentation aligned while preserving their
respective languages.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ab299edf-3bfd-48de-afe5-5700a918731a

📥 Commits

Reviewing files that changed from the base of the PR and between b632e19 and 9813225.

📒 Files selected for processing (13)
  • packages/br-utilities/br-utilities.gemspec
  • packages/cnpj-utilities/CHANGELOG.md
  • packages/cnpj-utilities/README.md
  • packages/cnpj-utilities/README.pt.md
  • packages/cnpj-utilities/cnpj-utilities.gemspec
  • packages/cnpj-utilities/src/cnpj-utilities/cnpj_utils.rb
  • packages/cnpj-utilities/src/cnpj-utilities/errors.rb
  • packages/cnpj-utilities/tests/cnpj_utils.spec.rb
  • packages/cpf-dv/cpf-dv.gemspec
  • packages/cpf-fmt/cpf-fmt.gemspec
  • packages/cpf-gen/cpf-gen.gemspec
  • packages/cpf-utilities/cpf-utilities.gemspec
  • packages/cpf-val/cpf-val.gemspec

Comment thread packages/cnpj-utilities/README.md Outdated
Adjustment as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cnpj-utilities/README.md`:
- Around line 284-287: Complete the public error documentation in
packages/cnpj-utilities/README.md (lines 284-287) and apply the equivalent
Portuguese correction in packages/cnpj-utilities/README.pt.md (lines 269-272).
For both files, document each error’s full inheritance through StandardError,
explicit Error marker inclusion, precise non-nil trigger conditions, usage
examples, and rescue/callback guidance at four granularity levels; distinguish
CnpjUtils::Error from component errors that propagate unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 40f4e31f-16e4-405e-a5aa-f650840db55e

📥 Commits

Reviewing files that changed from the base of the PR and between 9813225 and dfb9b03.

📒 Files selected for processing (3)
  • packages/cnpj-utilities/CHANGELOG.md
  • packages/cnpj-utilities/README.md
  • packages/cnpj-utilities/README.pt.md

Comment thread packages/cnpj-utilities/README.md Outdated
…vior

Adjustment as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cnpj-utilities/README.md`:
- Around line 286-289: Update resolve_settings to guard with an explicit nil
check so false is treated as provided settings input and undergoes type-mismatch
and ambiguous-keyword validation. Add regression coverage for
CnpjUtils.new(false), and update the corresponding documentation in
packages/cnpj-utilities/README.md (lines 286-289) and
packages/cnpj-utilities/README.pt.md (lines 271-274) so both English and
Portuguese pages reflect the non-nil settings contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 79f1663b-6af7-4128-bf21-ebc48b34e4a4

📥 Commits

Reviewing files that changed from the base of the PR and between dfb9b03 and c4e79fa.

📒 Files selected for processing (3)
  • packages/cnpj-utilities/CHANGELOG.md
  • packages/cnpj-utilities/README.md
  • packages/cnpj-utilities/README.pt.md

Comment thread packages/cnpj-utilities/README.md
@juliolmuller
juliolmuller merged commit cea7d8c into main Jul 24, 2026
71 checks passed
@juliolmuller
juliolmuller deleted the feat/cnpj-utilities branch July 24, 2026 19:18
juliolmuller added a commit that referenced this pull request Jul 24, 2026
Fix as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 24, 2026
…ings

Fix as per @coderabbitai review comment at hhttps://github.com//pull/25#discussion_r3640031712.

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 24, 2026
Adjustment as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 24, 2026
…vior

Adjustment as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
juliolmuller added a commit that referenced this pull request Jul 24, 2026
Adjustment as per @coderabbitai review comment at #25 (comment).

Co-authored-by: CodeRabbit AI <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Cursor Grok 4.5 <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New minor or major features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement package cnpj-utilities

1 participant